Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
J
jekyll-scholar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
caesr-pub
jekyll-scholar
Commits
004f7d08
Commit
004f7d08
authored
May 22, 2014
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add max option
parent
6c6b1142
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
+46
-2
features/filter.feature
features/filter.feature
+34
-0
lib/jekyll/scholar/tags/bibliography.rb
lib/jekyll/scholar/tags/bibliography.rb
+2
-0
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+10
-2
No files found.
features/filter.feature
View file @
004f7d08
...
...
@@ -37,3 +37,37 @@ Feature: BibTeX
And
the
"_site/scholar.html"
file should exist
And
I should see
"Programming Ruby"
in
"_site/scholar.html"
And
I should not see
"The Ruby Programming Language"
in
"_site/scholar.html"
@tags
@max
Scenario
:
Limit number of entries
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
@book{pickaxe,
title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
author = {Thomas, Dave and Fowler, Chad and Hunt, Andy},
year = {2009},
edition = 3,
publisher = {Pragmatic Bookshelf}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography --max 1 %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should not see
"Programming Ruby"
in
"_site/scholar.html"
And
I should see
"The Ruby Programming Language"
in
"_site/scholar.html"
lib/jekyll/scholar/tags/bibliography.rb
View file @
004f7d08
...
...
@@ -21,6 +21,8 @@ module Jekyll
cited_references
.
include?
e
.
key
end
if
cited_only?
references
=
references
.
take
(
max
.
to_i
)
if
limit_entries?
bibliography
=
references
.
each_with_index
.
map
{
|
entry
,
index
|
reference
=
bibliography_tag
(
entry
,
index
+
1
)
...
...
lib/jekyll/scholar/utilities.rb
View file @
004f7d08
...
...
@@ -15,7 +15,7 @@ module Jekyll
module
Utilities
attr_reader
:config
,
:site
,
:query
,
:context
,
:prefix
,
:keys
,
:text
:context
,
:prefix
,
:keys
,
:text
,
:max
def
split_arguments
(
arguments
)
...
...
@@ -56,6 +56,10 @@ module Jekyll
locators
<<
locator
end
opts
.
on
(
'-m'
,
'--max MAX'
)
do
|
max
|
@max
=
max
end
opts
.
on
(
'-s'
,
'--style STYLE'
)
do
|
style
|
@style
=
style
end
...
...
@@ -65,7 +69,7 @@ module Jekyll
end
end
argv
=
arguments
.
split
(
/(\B-[cfqptTsl
]|\B--(?:cited|file|query|prefix|text|style|template|locator
|))/
)
argv
=
arguments
.
split
(
/(\B-[cfqptTsl
m]|\B--(?:cited|file|query|prefix|text|style|template|locator|max
|))/
)
parser
.
parse
argv
.
map
(
&
:strip
).
reject
(
&
:empty?
)
end
...
...
@@ -119,6 +123,10 @@ module Jekyll
sort
bibliography
[
query
||
config
[
'query'
]]
end
def
limit_entries?
!
max
.
nil?
end
def
sort
(
unsorted
)
return
unsorted
if
config
[
'sort_by'
]
==
'none'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment