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
959de535
Commit
959de535
authored
Dec 13, 2014
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for multiple sort keys
see #69
parent
c2acfaa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
features/sorting.feature
features/sorting.feature
+36
-0
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+8
-1
No files found.
features/sorting.feature
View file @
959de535
...
@@ -190,3 +190,39 @@ Feature: Sorting BibTeX Bibliographies
...
@@ -190,3 +190,39 @@ Feature: Sorting BibTeX Bibliographies
And
the
"_site/scholar.html"
file should exist
And
the
"_site/scholar.html"
file should exist
Then
"Ruby Programming"
should come before
"Smalltalk"
in
"_site/scholar.html"
Then
"Ruby Programming"
should come before
"Smalltalk"
in
"_site/scholar.html"
And
I should not see
"<i>Ruby Not Cited</i>"
in
"_site/scholar.html"
And
I should not see
"<i>Ruby Not Cited</i>"
in
"_site/scholar.html"
@tags
@sorting
@wip
Scenario
:
Sort By Year And Month
Given I have a scholar configuration with
:
|
key
|
value
|
|
sort_by
|
year,
month
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby1,
title = {December},
year = {2008},
month = dec
}
@book{ruby2,
title = {March},
year = {2008},
month = mar
}
@book{ruby3,
title = {August},
year = {2007},
month = aug
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
Then
"August"
should come before
"March"
in
"_site/scholar.html"
# And "March" should come before "December" in "_site/scholar.html"
lib/jekyll/scholar/utilities.rb
View file @
959de535
...
@@ -141,11 +141,18 @@ module Jekyll
...
@@ -141,11 +141,18 @@ module Jekyll
def
sort
(
unsorted
)
def
sort
(
unsorted
)
return
unsorted
if
skip_sort?
return
unsorted
if
skip_sort?
sorted
=
unsorted
.
sort_by
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
puts
unsorted
.
first
.
values_at
(
*
sort_keys
)
sorted
=
unsorted
.
sort_by
{
|
e
|
e
.
values_at
(
*
sort_keys
)
}
sorted
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
sorted
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
sorted
sorted
end
end
def
sort_keys
@sort_kyes
||=
Array
(
config
[
'sort_by'
]).
map
{
|
key
|
key
.
to_s
.
split
(
/\s*,\s*/
)
}.
flatten
end
def
suppress_author?
def
suppress_author?
!!
@suppress_author
!!
@suppress_author
end
end
...
...
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