jekyll-author 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 733f79265b003f693bdd304b07da4a5193f33c45
4
+ data.tar.gz: 31b523a8adcef45d6438b05301af615e2cb584d8
5
+ SHA512:
6
+ metadata.gz: 7520de79ff5251f802a82f7f8655766a4fe99cff391a6e57997edc0773e45c9fd164b9f68dd58c1390915ca72baa7d4e5562cf0f6280d18ca3ef515cacf82fbb
7
+ data.tar.gz: 1de9c076c10165b3d446d9678fb0467a41165bfeeede95377b46fe8d0fc7f7fa78a3e71362e2f3dac675bd9300be19467218c5a41b0b6f20fdca6390695bfcfb
@@ -0,0 +1,20 @@
1
+ /vendor
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
17
+ Gemfile.lock
18
+ spec/dest
19
+ .bundle
20
+ spec/fixtures/.jekyll-metadata
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,29 @@
1
+ inherit_gem:
2
+ jekyll: .rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 1.9
6
+ Include:
7
+ - lib/*.rb
8
+
9
+ Exclude:
10
+ - .rubocop.yml
11
+ - .codeclimate.yml
12
+ - .travis.yml
13
+ - .gitignore
14
+ - .rspec
15
+
16
+ - Gemfile.lock
17
+ - CHANGELOG.md
18
+ - readme.md
19
+ - README.md
20
+ - Readme.md
21
+ - ReadMe.md
22
+ - COPYING
23
+ - LICENSE
24
+
25
+ - test/**/*
26
+ - vendor/**/*
27
+ - features/**/*
28
+ - script/**/*
29
+ - spec/**/*
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ env:
5
+ global:
6
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
7
+ cache: bundler
8
+ sudo: false
9
+ before_script: bundle update
10
+ script: ./script/cibuild
11
+ notifications:
12
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ if ENV["JEKYLL_VERSION"]
5
+ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
6
+ end
File without changes
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Garth Braithwaite
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.
@@ -0,0 +1,67 @@
1
+ # Jekyll Authors Plugin
2
+
3
+ A Jekyll plugin that manages all the author data from `_config.yml` and `_data/authors.*`
4
+
5
+ [![Build Status](https://travis-ci.org/GarthDB/jekyll-author.svg)](https://travis-ci.org/GarthDB/jekyll-author)
6
+
7
+ # Author information
8
+
9
+ A list of authors can be declared in `_config.yml` as an array in `authors` and/or in a [Jekyll data file](https://jekyllrb.com/docs/datafiles/) (ie `_data/authors.yml` or `_data/authors.json`).
10
+
11
+ *Note:* if an author slug is used in both lists (like `benbalter` in the examples below) it will keep the information from the `_config.yml` file and reject the `_data/authors.*` author data with the same slug.
12
+
13
+ Example `_config.yml`:
14
+
15
+ ```yml
16
+ timezone: UTC
17
+
18
+ authors:
19
+ garthdb:
20
+ name: Garth Braithwaite
21
+ uri: http://garthdb.com/
22
+ email: garthdb@adobe.com
23
+ twitter: garthdb
24
+ benbalter:
25
+ name: Ben Balter
26
+ uri: http://ben.balter.com/
27
+ email: ben.balter@github.com
28
+ twitter: benbalter
29
+ ```
30
+
31
+ Example `_data/authors.yml`:
32
+
33
+ ```yml
34
+ pathawks:
35
+ name: Pat Hawks
36
+ uri: https://pathawks.com
37
+ email: pat@pathawks.com
38
+ twitter: pathawks
39
+ benbalter:
40
+ name: The Ben Balter
41
+ uri: http://ben.balter.com/
42
+ email: ben.balter@github.com
43
+ twitter: benbalter
44
+ ```
45
+
46
+ The author information can then be referenced in a post by using the author slug.
47
+
48
+ For example if a post had the front matter:
49
+
50
+ ```yml
51
+ ---
52
+ title: "Super Great Post Title"
53
+ author: "benbalter"
54
+ ---
55
+ ```
56
+
57
+ The layout could use the author information from list:
58
+
59
+ ```liquid
60
+ {% if page.author.name and page.author.uri %}
61
+ <a href="{{ page.author.uri }}">{{ page.author.name }}</a>
62
+ {% else %}
63
+ {{ page.author }}
64
+ {% endif %}
65
+ ```
66
+
67
+ It is recommended to check if properties needed are available and to fallback to the author if they are not.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jekyll-author"
5
+ spec.version = "0.1.0"
6
+ spec.authors = ["Garth Braithwaite"]
7
+ spec.email = ["garthdb@adobe.com"]
8
+ spec.summary = "A Jekyll plugin to manage author data from multiple sources."
9
+ spec.homepage = "https://github.com/garthdb/jekyll-author"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = `git ls-files -z`.split("\x0")
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_development_dependency "jekyll", ">= 3.0.0", "< 3.2.0"
18
+ spec.add_development_dependency "bundler", "~> 1.6"
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "rspec", "~> 3.0"
21
+ spec.add_development_dependency "typhoeus", "~> 0.7"
22
+ spec.add_development_dependency "nokogiri", "~> 1.6"
23
+ spec.add_development_dependency "rubocop"
24
+ end
@@ -0,0 +1 @@
1
+ require "jekyll/jekyll-author"
@@ -0,0 +1,40 @@
1
+ module Jekyll
2
+ class Authors
3
+ class << self
4
+ def authors?(site)
5
+ (site.data.key?('authors') || site.config.key?('authors'))
6
+ end
7
+
8
+ def merge_authors(site)
9
+ site.config['authors'].merge!(site.data['authors']) { |_key, v1, _v2| v1 }
10
+ end
11
+
12
+ def default_author?(site)
13
+ site.config.key?('author')
14
+ end
15
+
16
+ def default_author(site)
17
+ site.config['author'] = site.config['authors'].values[0]
18
+ end
19
+
20
+ def post_author?(post)
21
+ (post.author.is_a?(String) && post.site.config['authors'].key?(post.author))
22
+ end
23
+
24
+ def attach_author(post)
25
+ post.data['author'] = post.site.config['authors'][post.author]
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Jekyll::Hooks.register :site, :post_read do |site|
32
+ Jekyll::Authors.merge_authors(site) if Jekyll::Authors.authors?(site)
33
+ if !Jekyll::Authors.default_author?(site) && Jekyll::Authors.authors?(site)
34
+ Jekyll::Authors.default_author(site)
35
+ end
36
+ end
37
+
38
+ Jekyll::Hooks.register :posts, :pre_render do |post|
39
+ Jekyll::Authors.attach_author(post) if Jekyll::Authors.post_author?(post)
40
+ end
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+
3
+ bundle install
@@ -0,0 +1,7 @@
1
+ #! /bin/bash
2
+
3
+ set -e
4
+
5
+ bundle exec rspec
6
+ bundle exec rubocop -S -D
7
+ bundle exec rake build
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ script/cibuild
7
+ bundle exec rake release
@@ -0,0 +1,13 @@
1
+ timezone: UTC
2
+
3
+ authors:
4
+ garthdb:
5
+ name: Garth Braithwaite
6
+ uri: http://garthdb.com/
7
+ email: garthdb@adobe.com
8
+ twitter: garthdb
9
+ benbalter:
10
+ name: Ben Balter
11
+ uri: http://ben.balter.com/
12
+ email: ben.balter@github.com
13
+ twitter: benbalter
@@ -0,0 +1,10 @@
1
+ pathawks:
2
+ name: Pat Hawks
3
+ uri: https://pathawks.com
4
+ email: pat@pathawks.com
5
+ twitter: pathawks
6
+ benbalter:
7
+ name: The Ben Balter
8
+ uri: http://ben.balter.com/
9
+ email: ben.balter@github.com
10
+ twitter: benbalter
@@ -0,0 +1,16 @@
1
+ ---
2
+ ---
3
+ <html>
4
+ <head>
5
+ </head>
6
+ <body>
7
+ THIS IS MY LAYOUT
8
+ <h1>{{ page.title }}</h1>
9
+ {{ content }}
10
+ {% if page.author.name and page.author.uri %}
11
+ <a href="{{ page.author.uri }}">{{ page.author.name }}</a>
12
+ {% else %}
13
+ {{ page.author }}
14
+ {% endif %}
15
+ </body>
16
+ </html>
@@ -0,0 +1,7 @@
1
+ ---
2
+ excerpt: "Foo"
3
+ image: "/image.png"
4
+ layout: "post"
5
+ author: garthdb
6
+ ---
7
+ # December the twelfth, actually.
@@ -0,0 +1,6 @@
1
+ ---
2
+ image: "/image.png"
3
+ layout: "post"
4
+ author: Tester McTesterton
5
+ ---
6
+ # This is a post
@@ -0,0 +1,10 @@
1
+ <html>
2
+ <head>
3
+ </head>
4
+ <body>
5
+
6
+ THIS IS MY LAYOUT
7
+ <h1 id="december-the-twelfth-actually">December the twelfth, actually.</h1>
8
+
9
+ </body>
10
+ </html>
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe(Jekyll::Authors) do
4
+ let(:overrides) { Hash.new }
5
+ let(:config) do
6
+ Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
7
+ "full_rebuild" => true,
8
+ "source" => source_dir,
9
+ "destination" => dest_dir,
10
+ "show_drafts" => true,
11
+ "url" => "http://example.org",
12
+ "name" => "My awesome site",
13
+ "collections" => {
14
+ "my_collection" => { "output" => true },
15
+ "other_things" => { "output" => false }
16
+ }
17
+ }, overrides))
18
+ end
19
+ let(:site) { Jekyll::Site.new(config) }
20
+ let(:generated_page) { File.read(dest_dir("2013/12/12/dec-the-second.html")) }
21
+ let(:context) { make_context(site: site) }
22
+ before(:each) do
23
+ site.process
24
+ end
25
+
26
+ it "has authors from _config.yml" do
27
+ expect(site.config['authors']['garthdb']['name']).to match(/\AGarth Braithwaite/)
28
+ end
29
+
30
+ it "has authors from _data/authors.yml" do
31
+ expect(site.config['authors']['pathawks']['name']).to match(/\APat Hawks/)
32
+ end
33
+
34
+ it "prioritizes _config.yml data" do
35
+ expect(site.config['authors']['benbalter']['name']).to match('Ben Balter')
36
+ end
37
+
38
+ it "uses authors data for page author" do
39
+ expect(generated_page).to match(/Garth Braithwaite/)
40
+ end
41
+
42
+ it "leaves the string if it doesn't match author key" do
43
+ page = File.read(dest_dir("2014/08/13/non-author.html"))
44
+ expect(page).to match(/Tester McTesterton/)
45
+ end
46
+
47
+ it "sets default author from the first author in list if not set" do
48
+ expect(site.config['author']['name']).to match('Garth Braithwaite')
49
+ end
50
+
51
+ context "a default author set in config" do
52
+ let(:author) {"Dr. Jekyll"}
53
+ let(:overrides) do
54
+ {"author" => author}
55
+ end
56
+ it "does not override config author if set" do
57
+ expect(site.config['author']).to match(author)
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,25 @@
1
+ require 'jekyll'
2
+ require File.expand_path('../lib/jekyll-author', File.dirname(__FILE__))
3
+
4
+ Jekyll.logger.log_level = :error
5
+
6
+ RSpec.configure do |config|
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ config.order = 'random'
10
+
11
+ SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
12
+ DEST_DIR = File.expand_path("../dest", __FILE__)
13
+
14
+ def source_dir(*files)
15
+ File.join(SOURCE_DIR, *files)
16
+ end
17
+
18
+ def dest_dir(*files)
19
+ File.join(DEST_DIR, *files)
20
+ end
21
+
22
+ def make_context(registers = {})
23
+ Liquid::Context.new({}, {}, { site: site }.merge(registers))
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-author
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Garth Braithwaite
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 3.2.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.2.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.6'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: typhoeus
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.7'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.7'
89
+ - !ruby/object:Gem::Dependency
90
+ name: nokogiri
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.6'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.6'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ description:
118
+ email:
119
+ - garthdb@adobe.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".gitignore"
125
+ - ".rspec"
126
+ - ".rubocop.yml"
127
+ - ".travis.yml"
128
+ - Gemfile
129
+ - History.markdown
130
+ - LICENSE
131
+ - README.md
132
+ - Rakefile
133
+ - jekyll-author.gemspec
134
+ - lib/jekyll-author.rb
135
+ - lib/jekyll/jekyll-author.rb
136
+ - script/bootstrap
137
+ - script/cibuild
138
+ - script/release
139
+ - spec/fixtures/_config.yml
140
+ - spec/fixtures/_data/authors.yml
141
+ - spec/fixtures/_layouts/post.html
142
+ - spec/fixtures/_posts/2013-12-12-dec-the-second.md
143
+ - spec/fixtures/_posts/2014-08-13-non-author.md
144
+ - spec/fixtures/_site/2013/12/12/dec-the-second.html
145
+ - spec/jekyll-author_spec.rb
146
+ - spec/spec_helper.rb
147
+ homepage: https://github.com/garthdb/jekyll-author
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.5.1
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: A Jekyll plugin to manage author data from multiple sources.
171
+ test_files:
172
+ - spec/fixtures/_config.yml
173
+ - spec/fixtures/_data/authors.yml
174
+ - spec/fixtures/_layouts/post.html
175
+ - spec/fixtures/_posts/2013-12-12-dec-the-second.md
176
+ - spec/fixtures/_posts/2014-08-13-non-author.md
177
+ - spec/fixtures/_site/2013/12/12/dec-the-second.html
178
+ - spec/jekyll-author_spec.rb
179
+ - spec/spec_helper.rb