Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
caesr-pub
jekyll-scholar
Commits
7c1651b4
Commit
7c1651b4
authored
Sep 21, 2015
by
Sylvester Keil
Browse files
Merge pull request #86 from iiegn/feature-offset_filter
Add --offset filter option to accompany --max
parents
77209ea1
6373f86c
Changes
3
Hide whitespace changes
Inline
Side-by-side
features/filter.feature
View file @
7c1651b4
...
...
@@ -106,6 +106,40 @@ Feature: BibTeX
And
I should not see
"Programming Ruby"
in
"_site/scholar.html"
And
I should see
"The Ruby Programming Language"
in
"_site/scholar.html"
@tags
@offset
Scenario
:
Start listing entries with an offset
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 --offset 1 %}
"""
When
I run jekyll
Then
the _site directory should exist
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
@urls
Scenario
:
URLs as text
Given I have a scholar configuration with
:
...
...
lib/jekyll/scholar/tags/bibliography.rb
View file @
7c1651b4
...
...
@@ -42,7 +42,7 @@ module Jekyll
cited_keys
.
clear
end
items
=
items
.
take
(
max
.
to_i
)
if
limit_entries?
items
=
items
[
offset
..
max
]
if
limit_entries?
bibliography
=
items
.
each_with_index
.
map
{
|
entry
,
index
|
reference
=
bibliography_tag
(
entry
,
index
+
1
)
...
...
lib/jekyll/scholar/utilities.rb
View file @
7c1651b4
...
...
@@ -14,7 +14,7 @@ module Jekyll
# #site readers
module
Utilities
attr_reader
:config
,
:site
,
:context
,
:prefix
,
:text
,
:max
attr_reader
:config
,
:site
,
:context
,
:prefix
,
:text
,
:offset
,
:max
def
split_arguments
(
arguments
)
...
...
@@ -63,8 +63,12 @@ module Jekyll
locators
<<
locator
end
opts
.
on
(
'-o'
,
'--offset OFFSET'
)
do
|
offset
|
@offset
=
offset
.
to_i
end
opts
.
on
(
'-m'
,
'--max MAX'
)
do
|
max
|
@max
=
max
@max
=
max
.
to_i
end
opts
.
on
(
'-s'
,
'--style STYLE'
)
do
|
style
|
...
...
@@ -76,7 +80,7 @@ module Jekyll
end
end
argv
=
arguments
.
split
(
/(\B-[cCfqptTslmA]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|template|locator|max|suppress_author|))/
)
argv
=
arguments
.
split
(
/(\B-[cCfqptTsl
o
mA]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|template|locator|
offset|
max|suppress_author|))/
)
parser
.
parse
argv
.
map
(
&
:strip
).
reject
(
&
:empty?
)
end
...
...
@@ -135,8 +139,16 @@ module Jekyll
sort
bibliography
[
query
||
config
[
'query'
]]
end
def
offset
@offset
||=
0
end
def
max
@max
.
nil?
?
-
1
:
@max
+
offset
-
1
end
def
limit_entries?
!
max
.
nil?
!
offset
.
nil?
||
!
max
.
nil?
end
def
sort
(
unsorted
)
...
...
Write
Preview
Supports
Markdown
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