middleman-citation 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +86 -0
- data/LICENSE +20 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/lib/middleman-citation/version.rb +7 -0
- data/lib/middleman-citation.rb +51 -0
- data/middleman-citation.gemspec +30 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f55657e35c57b39ea3cf99d18502348145e533fc
|
4
|
+
data.tar.gz: de38334ee3122e3becfae88985479d610d016b57
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0748e82b0a09b4dd9378beb55fb924bc5b142b76260dab2ed53230ea13541399fb41a6961f57255d6824343e554bee272a198dcc9bb06bdf1f8b916dee456e1e
|
7
|
+
data.tar.gz: 72347790ff25cbecd205dc9eadddd17d6bf8fbab77585a9b5a7b2afd60c1a688a07b46d4b5b27eae2986f61adb65edc1d2c1c6f212220de1b4f9f5dead80c548
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
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
|
+
|
80
|
+
PLATFORMS
|
81
|
+
ruby
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
bundler (~> 1.3)
|
85
|
+
middleman-citation!
|
86
|
+
rake
|
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,56 @@
|
|
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
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
In your `config.rb` file for your site add:
|
28
|
+
|
29
|
+
require 'middleman-citation'
|
30
|
+
|
31
|
+
activate :citation do |options|
|
32
|
+
options.bibtex = "/Users/tom/Dropbox/Research/all.bib" # full path to a bibtex file
|
33
|
+
options.style = "ieee" # or whatever style you want from citeproc-styles
|
34
|
+
end
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
This adds the following helper methods you can use in your Middleman
|
39
|
+
templates.
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
* `cite_full(key)`: given the BibTeX citation key return a formatted string
|
44
|
+
for the citation according to how the `style` option is set.
|
45
|
+
* `find_pubs(search_key, author)`: Search the BibTeX file for all citations
|
46
|
+
of a certain type for a # certain author.
|
47
|
+
Returns a list of citation keys you can send
|
48
|
+
to `cite_full`.
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "middleman-citation/version"
|
2
|
+
require "middleman-core"
|
3
|
+
require "bibtex"
|
4
|
+
require "citeproc"
|
5
|
+
|
6
|
+
module Middleman
|
7
|
+
class CitationExtension < Middleman::Extension
|
8
|
+
option :bibtex, "", "The path to the bibtex file to use"
|
9
|
+
option :style, "chicago-author-date", "The citation style to use"
|
10
|
+
|
11
|
+
def initialize(app, options_hash={}, &block)
|
12
|
+
super
|
13
|
+
|
14
|
+
@@bibtex = BibTeX.open(options.bibtex)
|
15
|
+
# for some reason the options function is the one from
|
16
|
+
# middleman-deploy in the helper methods below...
|
17
|
+
@@cite_style = options.style
|
18
|
+
end
|
19
|
+
|
20
|
+
helpers do
|
21
|
+
# Given a BibTeX citation return a formatted string according to
|
22
|
+
# how the setting of the style option
|
23
|
+
# Params:
|
24
|
+
# +key+:: bibtex key located in the BibTeX file defined in the config
|
25
|
+
def cite_full(key)
|
26
|
+
# need to convert latex special characters, like {\"o} to unicode
|
27
|
+
@@bibtex[key].convert_latex
|
28
|
+
CiteProc.process(@@bibtex[key].to_citeproc, :style => @@cite_style)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Search the BibTeX file for all citations of a certain type for a
|
32
|
+
# certain author. Returns a list of citation keys you can send to
|
33
|
+
# +cite_full+.
|
34
|
+
# Params:
|
35
|
+
# +search_key+:: filter keys for the BibTeX file, e.g. @book, @article,
|
36
|
+
# etc.
|
37
|
+
# +author+:: The full author name to search for
|
38
|
+
def find_pubs(search_key, author)
|
39
|
+
bib_name = BibTeX::Name.parse(author)
|
40
|
+
results = @@bibtex.query(search_key) do |e|
|
41
|
+
e.respond_to?(:author) and e.author and e.author.include? bib_name
|
42
|
+
end
|
43
|
+
results.sort! {|x,y| y.year.to_i-x.year.to_i}
|
44
|
+
results.map {|x| x.key}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
::Middleman::Extensions.register(:citation, Middleman::CitationExtension)
|
51
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'middleman-citation/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "middleman-citation"
|
8
|
+
spec.version = Middleman::Citation::VERSION
|
9
|
+
spec.authors = ["Thomas Torsney-Weir"]
|
10
|
+
spec.email = ["torsneyt@gmail.com"]
|
11
|
+
spec.description = <<-EOF
|
12
|
+
A middleman extension that gives helpers for
|
13
|
+
creating citations using citeproc
|
14
|
+
EOF
|
15
|
+
spec.summary = %q{Middleman extension for citeproc}
|
16
|
+
spec.homepage = "https://github.com/gabysbrain/middleman-citation"
|
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
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-citation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Torsney-Weir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-22 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
|
+
description: |2
|
84
|
+
A middleman extension that gives helpers for
|
85
|
+
creating citations using citeproc
|
86
|
+
email:
|
87
|
+
- torsneyt@gmail.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- lib/middleman-citation.rb
|
99
|
+
- lib/middleman-citation/version.rb
|
100
|
+
- middleman-citation.gemspec
|
101
|
+
homepage: https://github.com/gabysbrain/middleman-citation
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.0.3
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Middleman extension for citeproc
|
125
|
+
test_files: []
|