jekyll-scholar 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+ gemspec
3
+
4
+ gem 'unicode_utils'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011-2012 Sylvester Keil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the 'Software'), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ Jekyll-Scholar
2
+ ==============
3
+
4
+ Jekyll-Scholar is for all the academic bloggers out there. It is a set of
5
+ extensions to [Jekyll](http://jekyllrb.com/), the awesome, blog aware, static
6
+ site generator; it formats your bibliographies and reading lists for the web
7
+ and gives your blog posts citation super-powers.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ $ [sudo] gem install jekyll-scholar
13
+
14
+
15
+ Usage
16
+ -----
17
+
18
+ Install and setup a new [Jekyll](http://jekyllrb.com/) directory (see the
19
+ [Jekyll-Wiki](https://github.com/mojombo/jekyll/wiki/Usage) for detailed
20
+ instructions). To enable the Jekyll-Scholar add the following statement
21
+ to a file in your plugin directory (e.g., to `_plugins/ext.rb`):
22
+
23
+ require 'jekyll/scholar'
24
+
25
+ In your configuration you can now adjust the Jekyll-Scholar settings
26
+
27
+ citation_style: apa
28
+ citation_language: en
29
+
30
+ You can use any style that ships with
31
+ [CiteProc-Ruby](https://github.com/inukshuk/citeproc-ruby) by name (e.g.,
32
+ apa, mla, chicago-fullnote-bibliography), or else you can add a link
33
+ to any CSL style (e.g., you could link to any of the styles available at
34
+ the official [CSL style repository](https://github.com/citation-style-language/styles)).
35
+
36
+ The `citation_language` settings defines what language to use when formatting
37
+ your references (this typically applies to localized terms, e.g., 'Eds.' for
38
+ editors in English).
39
+
40
+ ### Bibliographies
41
+
42
+ Once you have loaded Jekyll-Scholar, all files with the extension `.bib` or
43
+ `.bibtex` will be converted when you run Jekyll (don't forget to add a YAML
44
+ header to the files); the file can contain regular HTML or Markdown and
45
+ BibTeX entries; the latter will be formatted by Jekyll-Scholar according to
46
+ the citation style and language defined in your configuration file.
47
+
48
+ For example, if you had a file `bibliography.bib` in your root directory:
49
+
50
+ ---
51
+ ---
52
+ References
53
+ ==========
54
+
55
+ @book{ruby,
56
+ title = {The Ruby Programming Language},
57
+ author = {Flanagan, David and Matsumoto, Yukihiro},
58
+ year = {2008},
59
+ publisher = {O'Reilly Media}
60
+ }
61
+
62
+ It would be converted to `bibliography.html` with the following content:
63
+
64
+ <h1 id='references'>References</h1>
65
+
66
+ <p>Flanagan, D., &#38; Matsumoto, Y. (2008). <i>The Ruby Programming Language</i>. O&#8217;Reilly Media.</p>
67
+
68
+ This makes it very easy for you to add you bibliography to your Jekyll-powered
69
+ blog or website.
70
+
71
+
72
+ ### Citations
73
+
74
+ Jekyll-Scholar will support inline citations and automatic generation of
75
+ a list of references for individual blog posts. Stay tuned.
76
+
77
+
78
+ License
79
+ -------
80
+
81
+ Jekyll-Scholar is distributed under the same license as Jekyll.
82
+
83
+ Copyright (c) 2011-2012 [Sylvester Keil](http://sylvester.keil.or.at/)
84
+
85
+ Permission is hereby granted, free of charge, to any person obtaining a copy
86
+ of this software and associated documentation files (the 'Software'), to deal
87
+ in the Software without restriction, including without limitation the rights
88
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
89
+ copies of the Software, and to permit persons to whom the Software is
90
+ furnished to do so, subject to the following conditions:
91
+
92
+ The above copyright notice and this permission notice shall be included in all
93
+ copies or substantial portions of the Software.
94
+
95
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
98
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
100
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
101
+ SOFTWARE.
@@ -0,0 +1,41 @@
1
+ Feature: BibTeX
2
+ As a scholar who likes to blog
3
+ I want to publish my BibTeX bibliography on my blog
4
+ In order to share my awesome references with my peers
5
+
6
+ Scenario: Simple Bibliography
7
+ Given I have a configuration file with "citation_style" set to "apa"
8
+ And I have a page "references.bib":
9
+ """
10
+ ---
11
+ ---
12
+ @book{ruby,
13
+ title = {The Ruby Programming Language},
14
+ author = {Flanagan, David and Matsumoto, Yukihiro},
15
+ year = {2008},
16
+ publisher = {O'Reilly Media}
17
+ }
18
+ """
19
+ When I run jekyll
20
+ Then the _site directory should exist
21
+ And the "_site/references.html" file should exist
22
+ And I should see "<i>The Ruby Programming Language</i>" in "_site/references.html"
23
+
24
+ Scenario: Markdown Formatted Bibliography
25
+ Given I have a configuration file with "citation_style" set to "apa"
26
+ And I have a page "references.bib":
27
+ """
28
+ ---
29
+ ---
30
+ References
31
+ ==========
32
+
33
+ @book{ruby,
34
+ title = {The Ruby Programming Language},
35
+ author = {Flanagan, David and Matsumoto, Yukihiro},
36
+ year = {2008},
37
+ publisher = {O'Reilly Media}
38
+ }
39
+ """
40
+ When I run jekyll
41
+ Then I should see "<h1[^>]*>References</h1>" in "_site/references.html"
@@ -0,0 +1,76 @@
1
+ Before do
2
+ FileUtils.rm_rf(TEST_DIR)
3
+ FileUtils.mkdir(TEST_DIR)
4
+ Dir.chdir(TEST_DIR)
5
+ end
6
+
7
+ After do
8
+ Dir.chdir(TEST_DIR)
9
+ FileUtils.rm_rf(TEST_DIR)
10
+ end
11
+
12
+ # Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
13
+ Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
14
+ File.open(file, 'w') do |f|
15
+ f.write <<EOF
16
+ ---
17
+ #{key || 'layout'}: #{value || 'nil'}
18
+ ---
19
+ #{text}
20
+ EOF
21
+ f.close
22
+ end
23
+ end
24
+
25
+ Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text|
26
+ File.open(file, 'w') do |f|
27
+ f.write(text)
28
+ f.close
29
+ end
30
+ end
31
+
32
+ Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
33
+ File.open('_config.yml', 'w') do |f|
34
+ f.write("#{key}: #{value}\n")
35
+ f.close
36
+ end
37
+ end
38
+
39
+ Given /^I have a configuration file with:$/ do |table|
40
+ File.open('_config.yml', 'w') do |f|
41
+ table.hashes.each do |row|
42
+ f.write("#{row["key"]}: #{row["value"]}\n")
43
+ end
44
+ f.close
45
+ end
46
+ end
47
+
48
+ Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
49
+ File.open('_config.yml', 'w') do |f|
50
+ f.write("#{key}:\n")
51
+ table.hashes.each do |row|
52
+ f.write("- #{row["value"]}\n")
53
+ end
54
+ f.close
55
+ end
56
+ end
57
+
58
+ When /^I run jekyll$/ do
59
+ run_jekyll
60
+ end
61
+
62
+ Then /^the (.*) directory should exist$/ do |dir|
63
+ assert File.directory?(dir)
64
+ end
65
+
66
+ Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
67
+ assert_match Regexp.new(text), File.open(file).readlines.join
68
+ end
69
+
70
+ Then /^the "(.*)" file should exist$/ do |file|
71
+ assert File.file?(file)
72
+ end
73
+
74
+ Then /^the "(.*)" file should not exist$/ do |file|
75
+ assert !File.exists?(file)
76
+ end
@@ -0,0 +1,6 @@
1
+
2
+ Given /^I have a page "([^"]*)":$/ do |file, string|
3
+ File.open(file, 'w') do |f|
4
+ f.write(string)
5
+ end
6
+ end
@@ -0,0 +1,25 @@
1
+ require 'rr'
2
+ require 'test/unit'
3
+
4
+ require 'jekyll/scholar'
5
+
6
+ # require 'ruby-debug'
7
+ # Debugger.start
8
+
9
+ World do
10
+ include Test::Unit::Assertions
11
+ end
12
+
13
+ TEST_DIR = File.join('/', 'tmp', 'jekyll')
14
+
15
+ def run_jekyll(options = {})
16
+
17
+ options['source'] ||= TEST_DIR
18
+ options['destination'] ||= File.join(TEST_DIR, '_site')
19
+
20
+ options = Jekyll.configuration(options)
21
+
22
+ site = Jekyll::Site.new(options)
23
+ site.process
24
+
25
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'jekyll/scholar/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'jekyll-scholar'
9
+ s.version = Jekyll::Scholar::VERSION.dup
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = ['Sylvester Keil']
12
+ s.email = 'http://sylvester.keil.or.at'
13
+ s.homepage = 'http://github.com/inukshuk/jekyll-scholar'
14
+ s.summary = 'Jekyll extensions for the academic blogger.'
15
+ s.description = 'A set of jekyll extensions for academic blogging.'
16
+ s.date = Time.now
17
+
18
+ s.required_rubygems_version = '>= 1.3.6'
19
+ s.rubyforge_project = s.name
20
+
21
+ s.add_runtime_dependency('jekyll', '~> 0.10')
22
+ s.add_runtime_dependency('citeproc-ruby', '~> 0.0.6')
23
+ s.add_runtime_dependency('bibtex-ruby', '~> 2.0.5')
24
+
25
+ s.add_development_dependency('bundler', '~> 1.1')
26
+ s.add_development_dependency('rdoc', '~> 3.12')
27
+ s.add_development_dependency('rake', '~> 0.9')
28
+ s.add_development_dependency('redgreen', ">= 1.2.2")
29
+ s.add_development_dependency('shoulda', ">= 2.11.3")
30
+ s.add_development_dependency('rr', ">= 1.0.2")
31
+ s.add_development_dependency('cucumber', ">= 0.10.0")
32
+ s.add_development_dependency('RedCloth', ">= 4.2.1")
33
+ s.add_development_dependency('rdiscount', ">= 1.6.5")
34
+
35
+ s.files = `git ls-files`.split("\n")
36
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
37
+ s.executables = []
38
+ s.require_path = 'lib'
39
+
40
+ end
41
+
42
+ # vim: syntax=ruby
@@ -0,0 +1,4 @@
1
+
2
+ require 'jekyll'
3
+ require 'jekyll/scholar/version'
4
+ require 'jekyll/scholar/converters/bibtex'
@@ -0,0 +1,43 @@
1
+ require 'bibtex'
2
+ require 'citeproc'
3
+
4
+ module Jekyll
5
+ module Scholar
6
+ class BibTeXConverter < Converter
7
+ safe true
8
+
9
+ priority :highest
10
+
11
+ DEFAULTS = Hash[*%w{
12
+ citation_style apa
13
+ citation_locale en
14
+ }].freeze
15
+
16
+ PATTERN = (/bib(tex)?$/i).freeze
17
+ EXTENSION = '.html'.freeze
18
+
19
+ def initialize (config = {})
20
+ super
21
+ @config['scholar'] = DEFAULTS.merge(@config['scholar'] || {})
22
+ @markdown = MarkdownConverter.new config
23
+ end
24
+
25
+ def matches (extension); extension =~ PATTERN; end
26
+
27
+ def output_ext (extension); EXTENSION; end
28
+
29
+ def convert (content)
30
+ content = BibTeX.parse(content, :include => [:meta_content]).map do |b|
31
+ if b.respond_to?(:to_citeproc)
32
+ CiteProc.process b.to_citeproc, :style => @config['citation_style'],
33
+ :locale => @config['citation_locale'], :format => 'html'
34
+ else
35
+ b.is_a?(BibTeX::MetaContent) ? b.to_s : ''
36
+ end
37
+ end
38
+ @markdown.convert(content.join("\n"))
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Scholar
3
+ VERSION = '0.0.1'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-scholar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sylvester Keil
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jekyll
16
+ requirement: &70277834274540 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.10'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70277834274540
25
+ - !ruby/object:Gem::Dependency
26
+ name: citeproc-ruby
27
+ requirement: &70277834273580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.6
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70277834273580
36
+ - !ruby/object:Gem::Dependency
37
+ name: bibtex-ruby
38
+ requirement: &70277834288720 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.5
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70277834288720
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &70277834287260 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70277834287260
58
+ - !ruby/object:Gem::Dependency
59
+ name: rdoc
60
+ requirement: &70277834286200 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '3.12'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70277834286200
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &70277834285300 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '0.9'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70277834285300
80
+ - !ruby/object:Gem::Dependency
81
+ name: redgreen
82
+ requirement: &70277834284200 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 1.2.2
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70277834284200
91
+ - !ruby/object:Gem::Dependency
92
+ name: shoulda
93
+ requirement: &70277834283440 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 2.11.3
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70277834283440
102
+ - !ruby/object:Gem::Dependency
103
+ name: rr
104
+ requirement: &70277834282580 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.2
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70277834282580
113
+ - !ruby/object:Gem::Dependency
114
+ name: cucumber
115
+ requirement: &70277834281600 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 0.10.0
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70277834281600
124
+ - !ruby/object:Gem::Dependency
125
+ name: RedCloth
126
+ requirement: &70277834297280 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 4.2.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70277834297280
135
+ - !ruby/object:Gem::Dependency
136
+ name: rdiscount
137
+ requirement: &70277834296260 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: 1.6.5
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *70277834296260
146
+ description: A set of jekyll extensions for academic blogging.
147
+ email: http://sylvester.keil.or.at
148
+ executables: []
149
+ extensions: []
150
+ extra_rdoc_files: []
151
+ files:
152
+ - .gitignore
153
+ - Gemfile
154
+ - LICENSE
155
+ - README.md
156
+ - features/bibtex.feature
157
+ - features/step_definitions/jekyll_steps.rb
158
+ - features/step_definitions/scholar_steps.rb
159
+ - features/support/env.rb
160
+ - jekyll-scholar.gemspec
161
+ - lib/jekyll/scholar.rb
162
+ - lib/jekyll/scholar/converters/bibtex.rb
163
+ - lib/jekyll/scholar/version.rb
164
+ homepage: http://github.com/inukshuk/jekyll-scholar
165
+ licenses: []
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: 1.3.6
182
+ requirements: []
183
+ rubyforge_project: jekyll-scholar
184
+ rubygems_version: 1.8.10
185
+ signing_key:
186
+ specification_version: 3
187
+ summary: Jekyll extensions for the academic blogger.
188
+ test_files:
189
+ - features/bibtex.feature
190
+ - features/step_definitions/jekyll_steps.rb
191
+ - features/step_definitions/scholar_steps.rb
192
+ - features/support/env.rb