bibsonomy-jekyll 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bibsonomy-jekyll.rb +40 -26
- data/lib/version.rb +1 -1
- data/spec/fixtures/page_other_style.md +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f124868f854e218c2f2f2fdc7ef9d4ae07f2bd9ea00effa0486fbb1f03ca4246
|
|
4
|
+
data.tar.gz: d64a9ecee82384fd16dc4defe06772d1aace8f6664e025cc5c89475e447ebcd3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e41882bb229e7dac6486d2136619ebb540e92205e0ddadb51c9ef0ff379ebea28454e0f3849a72fa7aa60281d78d2a0f0aab8d850732ab6d7e2168f9f5ab0020
|
|
7
|
+
data.tar.gz: acba91e497107ec8655d815349cc99fd5d6f5c324a5291b123c55644e4d2981c7f36b51ac0f46c1bb3890c6fb2b45e7235790b938b8a92f72acc50c01a046d2d
|
data/lib/bibsonomy-jekyll.rb
CHANGED
|
@@ -7,7 +7,7 @@ require 'bibsonomy/csl'
|
|
|
7
7
|
#
|
|
8
8
|
# Jekyll Tag to render posts from BibSonomy.
|
|
9
9
|
#
|
|
10
|
-
# Usage: {% bibsonomy GROUPING NAME TAG1 TAG2 ... TAGN COUNT %}
|
|
10
|
+
# Usage: {% bibsonomy [:OPTKEY OPTVAL] GROUPING NAME TAG1 TAG2 ... TAGN COUNT %}
|
|
11
11
|
# where
|
|
12
12
|
# GROUPING is either "user" or "group" and specifies the type of NAME
|
|
13
13
|
# NAME is the name of the group or user
|
|
@@ -15,6 +15,8 @@ require 'bibsonomy/csl'
|
|
|
15
15
|
# COUNT is an integer, the number of posts to return
|
|
16
16
|
#
|
|
17
17
|
# Changes:
|
|
18
|
+
# 2026-06-02 (rja)
|
|
19
|
+
# - added generic setting (and override) of csl configuration options
|
|
18
20
|
# 2018-10-08 (rja)
|
|
19
21
|
# - added liquid expansion
|
|
20
22
|
# 2017-05-31 (rja)
|
|
@@ -24,23 +26,23 @@ require 'bibsonomy/csl'
|
|
|
24
26
|
module Jekyll
|
|
25
27
|
|
|
26
28
|
class BibSonomyPostList < Liquid::Tag
|
|
29
|
+
|
|
30
|
+
# these bibsonomy/csl configuration options are supported
|
|
31
|
+
CONFIG_OPTS = ['pdf_dir', 'altmetric_badge_type', 'style', 'year_headings', 'css_class']
|
|
32
|
+
|
|
27
33
|
def initialize(tag_name, text, tokens)
|
|
28
34
|
super
|
|
29
35
|
@input = text
|
|
30
36
|
end
|
|
31
37
|
|
|
38
|
+
|
|
32
39
|
def render(context)
|
|
33
|
-
# expand liquid variables
|
|
34
40
|
rendered_input = Liquid::Template.parse(@input).render(context)
|
|
35
|
-
|
|
36
|
-
bib_config = context.registers[:site].config['bibsonomy'].clone
|
|
37
|
-
#bib_config = site.config['bibsonomy']
|
|
38
|
-
|
|
39
|
-
# parse parameters
|
|
40
41
|
parts = rendered_input.split(/\s+/)
|
|
41
|
-
# parameters starting with : can override configuration options
|
|
42
|
-
override_config(bib_config, parts)
|
|
43
42
|
|
|
43
|
+
# parameters starting with : can override csl configuration options
|
|
44
|
+
opts = get_opts(parts)
|
|
45
|
+
# use (remaining/actual) parameters
|
|
44
46
|
grouping = parts.shift
|
|
45
47
|
name = parts.shift
|
|
46
48
|
# the last element is the number of posts
|
|
@@ -48,21 +50,10 @@ module Jekyll
|
|
|
48
50
|
# everything else are the tags
|
|
49
51
|
tags = parts
|
|
50
52
|
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
csl = BibSonomy::CSL.new(bib_config['user'], bib_config['apikey'])
|
|
56
|
-
|
|
57
|
-
# target directory for PDF documents
|
|
58
|
-
csl.pdf_dir = bib_config['document_directory']
|
|
59
|
-
|
|
60
|
-
# Altmetric badge type
|
|
61
|
-
csl.altmetric_badge_type = bib_config['altmetric_badge_type']
|
|
62
|
-
|
|
63
|
-
# CSL style for rendering
|
|
64
|
-
csl.style = bib_config['style']
|
|
65
|
-
csl.year_headings = bib_config['year_headings'].to_s.downcase == "true"
|
|
53
|
+
# configure CSL
|
|
54
|
+
config = context.registers[:site].config['bibsonomy']
|
|
55
|
+
csl = BibSonomy::CSL.new(config['user'], config['apikey'])
|
|
56
|
+
configure(csl, config, opts)
|
|
66
57
|
|
|
67
58
|
html = csl.render(grouping, name, tags, count)
|
|
68
59
|
|
|
@@ -72,12 +63,35 @@ module Jekyll
|
|
|
72
63
|
return html
|
|
73
64
|
end
|
|
74
65
|
|
|
75
|
-
|
|
66
|
+
|
|
67
|
+
def get_opts(parts)
|
|
68
|
+
opts = {}
|
|
76
69
|
# parameters starting with : can override configuration options
|
|
77
70
|
# only at the beginning → the first string without : stops loop
|
|
78
71
|
while parts[0].start_with?(':')
|
|
79
|
-
|
|
72
|
+
opts[parts.shift[1..]] = parts.shift
|
|
80
73
|
end
|
|
74
|
+
return opts
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# set values in csl from config, possibly overriden by opts
|
|
80
|
+
#
|
|
81
|
+
def configure(csl, config, opts)
|
|
82
|
+
# work on a copy of the configuration and override using opts
|
|
83
|
+
config = config.clone.merge(opts)
|
|
84
|
+
# set values from config in CSL
|
|
85
|
+
(CONFIG_OPTS & config.keys()).each do |key|
|
|
86
|
+
# TODO: access attribute by string → ok or hack?
|
|
87
|
+
csl.instance_variable_set('@' + key, config[key])
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# HACK: convert the only (so far) boolean variable to boolean
|
|
91
|
+
if csl.year_headings.is_a?(String)
|
|
92
|
+
csl.year_headings = csl.year_headings.downcase == "true"
|
|
93
|
+
end
|
|
94
|
+
|
|
81
95
|
end
|
|
82
96
|
end
|
|
83
97
|
|
data/lib/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -40,7 +40,7 @@ RSpec.configure do |config|
|
|
|
40
40
|
site_config = Jekyll.configuration(CONFIG_DEFAULTS.merge(options))
|
|
41
41
|
# get api key and user name from environment (configured via
|
|
42
42
|
# .travis.yml on Travis or manually when testing locally)
|
|
43
|
-
site_config["bibsonomy"] = {"user" => ENV['BIBSONOMY_USER_NAME'], "apikey" => ENV['BIBSONOMY_API_KEY'], "style" => "springer-lecture-notes-in-computer-science"
|
|
43
|
+
site_config["bibsonomy"] = {"user" => ENV['BIBSONOMY_USER_NAME'], "apikey" => ENV['BIBSONOMY_API_KEY'], "style" => "springer-lecture-notes-in-computer-science"}
|
|
44
44
|
Jekyll::Site.new(site_config)
|
|
45
45
|
end
|
|
46
46
|
|