middleman-bibtex 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a9852d3435be7ec344a056458e76090c209c3f1
4
+ data.tar.gz: dfb09c8bf2546af9632b9cce6699e678726d6dcd
5
+ SHA512:
6
+ metadata.gz: 0b261ab3a1434fb3c38ec78a023635a9aaa5037424a721ae67289edca4558dfc16e9afe24f0a07ca195cfa326282162bbbfb4ca3b254aa2a0e2b4c821e7b4dad
7
+ data.tar.gz: 44075978702c11c7a54a8cb3d599bbc62e38793a51f5573bd16cb056502d9128ba574b815ef87cc83873f17a5753f39415f8cfb4830e58a1594ef46695f40533
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .ruby-version
2
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in multimarkdown.gemspec
4
+ gemspec
5
+
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ middleman-citation (0.0.1)
5
+ bibtex-ruby
6
+ citeproc-ruby (~> 0.0.6)
7
+ middleman-core (~> 3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (4.1.5)
13
+ i18n (~> 0.6, >= 0.6.9)
14
+ json (~> 1.7, >= 1.7.7)
15
+ minitest (~> 5.1)
16
+ thread_safe (~> 0.1)
17
+ tzinfo (~> 1.1)
18
+ bibtex-ruby (4.0.3)
19
+ latex-decode (~> 0.0)
20
+ celluloid (0.15.2)
21
+ timers (~> 1.1.0)
22
+ citeproc-ruby (0.0.6)
23
+ logging (~> 1.5)
24
+ nokogiri (~> 1.5)
25
+ erubis (2.7.0)
26
+ ffi (1.9.3)
27
+ hooks (0.4.0)
28
+ uber (~> 0.0.4)
29
+ i18n (0.6.11)
30
+ json (1.8.1)
31
+ latex-decode (0.1.1)
32
+ unicode (~> 0.4)
33
+ listen (2.7.9)
34
+ celluloid (>= 0.15.2)
35
+ rb-fsevent (>= 0.9.3)
36
+ rb-inotify (>= 0.9)
37
+ little-plugger (1.1.3)
38
+ logging (1.8.2)
39
+ little-plugger (>= 1.1.3)
40
+ multi_json (>= 1.8.4)
41
+ middleman-core (3.3.5)
42
+ activesupport (~> 4.1.0)
43
+ bundler (~> 1.1)
44
+ erubis
45
+ hooks (~> 0.3)
46
+ i18n (~> 0.6.9)
47
+ listen (>= 2.7.9, < 3.0)
48
+ padrino-helpers (~> 0.12.3)
49
+ rack (>= 1.4.5, < 2.0)
50
+ rack-test (~> 0.6.2)
51
+ thor (>= 0.15.2, < 2.0)
52
+ tilt (~> 1.4.1, < 2.0)
53
+ mini_portile (0.6.0)
54
+ minitest (5.4.0)
55
+ multi_json (1.10.1)
56
+ nokogiri (1.6.3.1)
57
+ mini_portile (= 0.6.0)
58
+ padrino-helpers (0.12.3)
59
+ i18n (~> 0.6, >= 0.6.7)
60
+ padrino-support (= 0.12.3)
61
+ tilt (~> 1.4.1)
62
+ padrino-support (0.12.3)
63
+ activesupport (>= 3.1)
64
+ rack (1.5.2)
65
+ rack-test (0.6.2)
66
+ rack (>= 1.0)
67
+ rake (10.3.2)
68
+ rb-fsevent (0.9.4)
69
+ rb-inotify (0.9.5)
70
+ ffi (>= 0.5.0)
71
+ thor (0.19.1)
72
+ thread_safe (0.3.4)
73
+ tilt (1.4.1)
74
+ timers (1.1.0)
75
+ tzinfo (1.2.2)
76
+ thread_safe (~> 0.1)
77
+ uber (0.0.8)
78
+ unicode (0.4.4.1)
79
+ yard (0.8.7.4)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ bundler (~> 1.3)
86
+ middleman-citation!
87
+ rake
88
+ yard
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Tom Torsney-Weir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Middleman-citation
2
+
3
+ This is an extension for the [Middleman](http://middlemanapp.com/) static
4
+ site generator that adds functions you can use in your templates for
5
+ formating citations from BibTeX.
6
+
7
+ An example of a Middleman template using this plugin is available at
8
+ <https://github.com/gabysbrain/website/blob/master/source/cv.html.slim>.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your Gemfile:
13
+
14
+ gem 'middleman-citation'
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install middleman-citation
23
+
24
+ ## Configuration
25
+
26
+ In your `config.rb` file for your site add:
27
+
28
+ require 'middleman-citation'
29
+
30
+ activate :citation do |opts|
31
+ opts.bibtex = '/path/to/your.bib' # path to a bibtex file
32
+ opts.style = 'ieee' # style from citeproc-styles
33
+ opts.format = 'html' # output format
34
+ end
35
+
36
+ ## Usage
37
+
38
+ This adds the following helper methods you can use in your Middleman
39
+ templates.
40
+
41
+ * `citations_search(search_term, author)`: Search the BibTeX file for all
42
+ citations matching a search term (such as `'@article'`) and by the given
43
+ author. The `author` argument can be ommitted to match all authors and
44
+ a `search_term` of `nil` will match all items in the bibliography.
45
+
46
+ * `citation(key)`: Given a BibTeX citation key as returned from
47
+ `citations_search`, return a formatted string the citation according to
48
+ how the `style` and `format` options were set.
49
+
50
+ For extra control on the output, one can use:
51
+
52
+ * `citation_entry(key)`: Return the unformatted entry (a hash)
53
+ corresponding to the BibTeX citation key.
54
+
55
+ * `citation_formatted(entry)`: Format an unformatted entry.
56
+
57
+ In fact the `citation` method is implemented using these:
58
+
59
+ def citation(key)
60
+ entry = citation_entry(key)
61
+ citation_formatted(entry)
62
+ end
63
+
64
+ The point is that one can interrogate the unformatted entry to
65
+ add extra formatting: The following code adds a DOI link if the
66
+ entry matching the `key` has a `URL` field containing the DOI.
67
+
68
+ entry = citation_entry(key)
69
+ entry_html = citation_formatted(entry)
70
+ if doi_url = entry.fetch('URL', false) then
71
+ doi_link = "(%s)" % link_to('doi', doi_url)
72
+ end
73
+ [entry_html, doi_link].compact.join(' ')
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Bibtex
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,62 @@
1
+ require 'middleman-bibtex/version'
2
+ require 'middleman-core'
3
+ require 'bibtex'
4
+ require 'citeproc'
5
+
6
+ module Middleman
7
+
8
+ class BibtexExtension < Middleman::Extension
9
+
10
+ option :bibtex, nil, 'Path to the bibtex file'
11
+ option :style, 'chicago-author-date', 'BibTeX style'
12
+ option :format, 'html', 'Bibliography format'
13
+
14
+ def initialize(app, options_hash={}, &block)
15
+ super
16
+ app.set(:bibtex, BibTeX.open(options.bibtex))
17
+ app.set(:cite_style, options.style)
18
+ app.set(:cite_format, options.format)
19
+ end
20
+
21
+ helpers do
22
+
23
+ def citations_search(search_key, author = nil)
24
+ entries_matching_key = bibtex.query(search_key)
25
+ entries =
26
+ if author then
27
+ search_by_author(entries_matching_key, author)
28
+ else
29
+ entries_matching_key
30
+ end
31
+ entries.sort { |x, y| y.year.to_i <=> x.year.to_i }.map(&:key)
32
+ end
33
+
34
+ def citation_entry(key)
35
+ bibtex[key].convert_latex.to_citeproc
36
+ end
37
+
38
+ def citation_formatted(entry)
39
+ CiteProc.process(entry, :style => cite_style, :format => cite_format)
40
+ end
41
+
42
+ def citation(key)
43
+ entry = citation_entry(key)
44
+ citation_formatted(entry)
45
+ end
46
+
47
+ private
48
+
49
+ def search_by_author(entries, author)
50
+ bib_author = BibTeX::Name.parse(author)
51
+ entries.select do |e|
52
+ e.respond_to?(:author) &&
53
+ e.author &&
54
+ e.author.include?(bib_author)
55
+ end
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+
62
+ ::Middleman::Extensions.register(:bibtex, Middleman::BibtexExtension)
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'middleman-bibtex/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'middleman-bibtex'
7
+ spec.version = Middleman::Bibtex::VERSION
8
+ spec.authors = ['J. J. Green']
9
+ spec.email = ['j.j.green@gmx.co.uk']
10
+ spec.description = <<-EOF
11
+ A middleman extension that gives helpers for
12
+ creating bibtex citation, a fork from the
13
+ middleman-citation extension.
14
+ EOF
15
+ spec.summary = %q{Middleman extension for bibtex bibliographies}
16
+ spec.homepage = 'https://github.com/jjgreen/middleman-bibtex'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_runtime_dependency 'bibtex-ruby'
25
+ spec.add_runtime_dependency 'citeproc-ruby', ['~> 0.0.6']
26
+ spec.add_runtime_dependency 'middleman-core', ['~> 3']
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.3'
29
+ spec.add_development_dependency 'rake'
30
+ spec.add_development_dependency 'yard'
31
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-bibtex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - J. J. Green
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bibtex-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: citeproc-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: middleman-core
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: |2
98
+ A middleman extension that gives helpers for
99
+ creating bibtex citation, a fork from the
100
+ middleman-citation extension.
101
+ email:
102
+ - j.j.green@gmx.co.uk
103
+ executables: []
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".gitignore"
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE
111
+ - README.md
112
+ - Rakefile
113
+ - lib/middleman-bibtex.rb
114
+ - lib/middleman-bibtex/version.rb
115
+ - middleman-bibtex.gemspec
116
+ homepage: https://github.com/jjgreen/middleman-bibtex
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.2.2
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Middleman extension for bibtex bibliographies
140
+ test_files: []