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
7d4f6b49
Commit
7d4f6b49
authored
Feb 01, 2016
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #127 from pkok/master
Added --group_by option for bibliography tag
parents
cf3ba190
0a700967
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
6 deletions
+82
-6
features/grouping.feature
features/grouping.feature
+65
-1
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+17
-5
No files found.
features/grouping.feature
View file @
7d4f6b49
...
@@ -301,4 +301,68 @@ Feature: Grouping BibTeX Bibliographies
...
@@ -301,4 +301,68 @@ Feature: Grouping BibTeX Bibliographies
Then
I should see
"Januar"
in
"_site/scholar.html"
Then
I should see
"Januar"
in
"_site/scholar.html"
And
I should not see
"January"
in
"_site/scholar.html"
And
I should not see
"January"
in
"_site/scholar.html"
And
I should see
"Dezember"
in
"_site/scholar.html"
And
I should see
"Dezember"
in
"_site/scholar.html"
And
I should not see
"December"
in
"_site/scholar.html"
And
I should not see
"December"
in
"_site/scholar.html"
\ No newline at end of file
@tags
@grouping
Scenario
:
Local grouping override - no grouping
Given I have a scholar configuration with
:
|
group_by
|
year
|
And
I
have
a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby1,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
@book{ruby2,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2007},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography -f references --group_by none %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
Then
I should not see
"<h2 class=\"
bibliography\">2007
</h2>
" in "
_site/scholar.html"
And
I should not see
"<h2 class=\"
bibliography\">2008
</h2>
" in "
_site/scholar.html"
@tags
@grouping
Scenario
:
Local grouping override - grouping by year
Given I have a scholar configuration with
:
|
group_by
|
none
|
And
I
have
a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby1,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
@book{ruby2,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2007},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography -f references --group_by none %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
Then
I should see
"<h2 class=\"
bibliography\">2007
</h2>
" in "
_site/scholar.html"
And
I should see
"<h2 class=\"
bibliography\">2008
</h2>
" in "
_site/scholar.html"
lib/jekyll/scholar/utilities.rb
View file @
7d4f6b49
...
@@ -18,7 +18,7 @@ module Jekyll
...
@@ -18,7 +18,7 @@ module Jekyll
module
Utilities
module
Utilities
attr_reader
:config
,
:site
,
:context
,
:prefix
,
:text
,
:offset
,
:max
,
:relative
attr_reader
:config
,
:site
,
:context
,
:prefix
,
:text
,
:offset
,
:max
,
:relative
,
:group_by
...
@@ -85,12 +85,16 @@ module Jekyll
...
@@ -85,12 +85,16 @@ module Jekyll
@style
=
style
@style
=
style
end
end
opts
.
on
(
'-g'
,
'--group_by GROUP'
)
do
|
group_by
|
@group_by
=
group_by
end
opts
.
on
(
'-T'
,
'--template TEMPLATE'
)
do
|
template
|
opts
.
on
(
'-T'
,
'--template TEMPLATE'
)
do
|
template
|
@bibliography_template
=
template
@bibliography_template
=
template
end
end
end
end
argv
=
arguments
.
split
(
/(\B-[cCfqrptTs
lomA]|\B--(?:cited(_in_order)?|file|query|relative|prefix|text|style
|template|locator|offset|max|suppress_author|))/
)
argv
=
arguments
.
split
(
/(\B-[cCfqrptTs
glomA]|\B--(?:cited(_in_order)?|file|query|relative|prefix|text|style|group_by
|template|locator|offset|max|suppress_author|))/
)
parser
.
parse
argv
.
map
(
&
:strip
).
reject
(
&
:empty?
)
parser
.
parse
argv
.
map
(
&
:strip
).
reject
(
&
:empty?
)
end
end
...
@@ -198,10 +202,18 @@ module Jekyll
...
@@ -198,10 +202,18 @@ module Jekyll
.
flatten
.
flatten
end
end
def
group?
def
group_by
config
[
'group_by'
]
!=
'none'
if
group_by
.
nil?
||
group_by
.
empty?
@group_by
=
config
[
'group_by'
]
else
@group_by
=
'none'
end
end
end
def
group?
group_by
!=
'none'
end
def
group
(
ungrouped
)
def
group
(
ungrouped
)
def
grouper
(
items
,
keys
,
order
)
def
grouper
(
items
,
keys
,
order
)
groups
=
items
groups
=
items
...
@@ -222,7 +234,7 @@ module Jekyll
...
@@ -222,7 +234,7 @@ module Jekyll
def
group_keys
def
group_keys
return
@group_keys
unless
@group_keys
.
nil?
return
@group_keys
unless
@group_keys
.
nil?
@group_keys
=
Array
(
config
[
'group_by'
]
)
@group_keys
=
Array
(
group_by
)
.
map
{
|
key
|
key
.
to_s
.
split
(
/\s*,\s*/
)
}
.
map
{
|
key
|
key
.
to_s
.
split
(
/\s*,\s*/
)
}
.
flatten
.
flatten
.
map
{
|
key
|
key
==
'month'
?
'month_numeric'
:
key
}
.
map
{
|
key
|
key
==
'month'
?
'month_numeric'
:
key
}
...
...
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