h32-jekyll-tagging 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 04be951779b8a87b8e1d58e4d89b8ad98d07509fbf09e4a848be6d9ddb2ddfd3
4
+ data.tar.gz: 5ec37ca4d13379de6c598c6cc880cd485e374fb85c6bbad4c59b1d8d0dfff0b8
5
+ SHA512:
6
+ metadata.gz: b990d2f5a27202214b54f2e37069e25fced40dadb63d92b1e090427fc11d1c7ddec666f3c918ca94cbe715b24ca01c5082b47cb96cdf5292b8b3edacd1382d6b
7
+ data.tar.gz: 4fecaf176ef06dee66d9e1020774891894732ccc432a8b151e7d2be3caf44af99120b78f1273eeef8f08d99b74f28af8a7366f3c24867a978fcd9169e0a2dd15
data/ChangeLog ADDED
@@ -0,0 +1,62 @@
1
+ == 1.1.0 [2017-03-07]
2
+
3
+ * Added ability to append extra data to all tag pages. (tfe)
4
+ * Provides compatibility to the current jekyll (3.4.1).
5
+ * A few fixes. (felipe)
6
+ * Some documentation improvements. (wsmoak, jonathanpberger)
7
+ * Prooves who is the worst open source maintainer. (pattex ^__^)
8
+
9
+ == 1.0.1 [2015-06-11]
10
+
11
+ * Substitution of non ASCII characters and whitespaces, also when 'tag_permalink_style: pretty'.
12
+
13
+ == 1.0.0 [2015-06-10]
14
+
15
+ * Generate prettier urls for tag with whitespaces or non ASCII characters. ATTENTION: Your urls may change!
16
+ * Added support for site.config["baseurl"]. (Tsukasa ŌMOTO)
17
+ * Added trailing slashes to permalinks. (Pyry Kontio)
18
+
19
+ == 0.6.0 [2014-09-03]
20
+
21
+ * Pretty permalinks for tag pages. (Steve Valaitis)
22
+ * Added support for keywords (allenlsy)
23
+
24
+ == 0.5.0 [2013-06-06]
25
+
26
+ * Added rel="tag" to posts' tag links. (Brandon Hicks)
27
+ * Added support for ignored tags. (Zee Spencer)
28
+
29
+ == 0.4.0 [2012-10-22]
30
+
31
+ * Heavy refactoring to better support monkey patching.
32
+ * Fixed issue when a number is used as a tag. (Fabrice Rossi)
33
+
34
+ == 0.3.1 [2012-05-24]
35
+
36
+ * Added support for Jekyll::Site#add_payload (custom extension).
37
+
38
+ == 0.3.0 [2012-02-03]
39
+
40
+ * Feed per tag feature added.
41
+
42
+ == 0.2.0 [2011-03-10]
43
+
44
+ * Added support for pretty tag page URLs.
45
+ * Some bugs fixed.
46
+
47
+ == 0.1.2 [2011-01-31]
48
+
49
+ * Nothing to do when there are no tags.
50
+
51
+ == 0.1.1 [2010-11-26]
52
+
53
+ * Posts on tag pages are now sorted.
54
+
55
+ == 0.1.0 [2010-10-28]
56
+
57
+ * Added a <tt>tags</tt> filter.
58
+ * Ease customization by adding additional layers.
59
+
60
+ == 0.0.1 [2010-10-25]
61
+
62
+ * Here I am!
data/README.rdoc ADDED
@@ -0,0 +1,142 @@
1
+ = jekyll-tagging
2
+
3
+ By Arne Eilermann <mailto:arne@kleinerdrei.net> and Jens Wille <mailto:jens.wille@uni-koeln.de>
4
+
5
+ jekyll-tagging is a Jekyll plugin, to add a tag cloud and per tag pages plus feeds to your Jekyll generated Website.
6
+
7
+ == Tags
8
+ This plugin does not reinvent Jekyll's tagging feature. It just makes it easy to use.
9
+ <https://jekyllrb.com/docs/frontmatter/>
10
+
11
+ Add space-delimited lowercase tags to FrontMatter, e.g.
12
+
13
+ ---
14
+ author: Willow Rosenberg
15
+ tags: feminism anti-capitalism witchcraft
16
+ ---
17
+
18
+ == Usage
19
+
20
+ Install it:
21
+
22
+ gem install jekyll-tagging
23
+
24
+ Add this line to your Jekyll project's Gemfile:
25
+
26
+ gem 'jekyll-tagging'
27
+
28
+ Add the following to your <tt>_plugins/ext.rb</tt> file:
29
+
30
+ require 'jekyll/tagging'
31
+
32
+ And in your <tt>_config.yml</tt> you have to define your layout used to generate tag pages like:
33
+
34
+ tag_page_layout: tag_page
35
+ tag_page_dir: tag
36
+
37
+ This will look for <tt>_layouts/tag_page.html</tt>, and use it to generate tag pages into the <tt>_site/tag</tt> directory.
38
+
39
+ Now you have a new filter called <tt>tag_cloud</tt> which you can use with the <tt>site</tt> object as argument in your layout to get a cloud of all your site's tags. The tags are linked to their related tag page. Furthermore, you have a <tt>tags</tt> filter which you can feed with a <tt>post</tt> or a <tt>page</tt> object to get a link list of all its tags.
40
+
41
+ You can optionally define a per tag Atom/RSS feed. In your <tt>_config.yml</tt> define the following:
42
+
43
+ tag_feed_layout: tag_feed
44
+ tag_feed_dir: tag
45
+
46
+ (<tt>tag_page_dir</tt> and <tt>tag_feed_dir</tt> can have the same value.)
47
+
48
+ === Pretty page links
49
+
50
+ If your Jekyll <tt>permalink</tt> configuration is set to something other than <tt>:pretty</tt>, and you still want to have pretty tag links define the following in your <tt>_config.yml</tt>:
51
+
52
+ tag_permalink_style: pretty
53
+
54
+ === Ignoring tags
55
+
56
+ Sometimes you don't want tag pages generated for certain pages. That's ok! Just add <tt>ignored_tags: [tags,to,ignore]</tt> to your <tt>_config.yml</tt>
57
+
58
+ === Extra data on tag pages
59
+
60
+ You can attach extra data to generated tag pages by specifying <tt>tag_page_data</tt> in <tt>_config.yml</tt> (this also works for <tt>tag_feed_data</tt>). For example, you might want to exclude tag pages from being picked up by `jekyll-sitemap`:
61
+
62
+ tag_page_data:
63
+ sitemap: false
64
+
65
+ === Example tag page layout
66
+
67
+ (Save this to <tt>_layouts/tag_page.html</tt> if using the <tt>_config.yml</tt> snippet above.)
68
+
69
+ ---
70
+ layout: default
71
+ ---
72
+ <h2>{{ page.tag }}</h2>
73
+ <ul>
74
+ {% for post in page.posts %}
75
+ <li><a href="{{ post.url }}">{{ post.title }}</a> ({{ post.date | date_to_string }} | Tags: {{ post | tags }})</li>
76
+ {% endfor %}
77
+ </ul>
78
+
79
+ <div id="tag-cloud">
80
+ {{ site | tag_cloud }}
81
+ </div>
82
+
83
+
84
+ === Example layout of an Atom feed
85
+
86
+ (Save this to <tt>_layouts/tag_feed.xml</tt> if using the <tt>_config.yml</tt> snippet above.)
87
+
88
+ ---
89
+ layout: nil
90
+ ---
91
+ <?xml version="1.0" encoding="utf-8"?>
92
+ <feed xmlns="http://www.w3.org/2005/Atom">
93
+ <title>Your Title - {{ page.tag }}</title>
94
+ <link href="http://example.com{{ page.url }}" rel="self"/>
95
+ <link href="http://example.com/tag/{{ page.tag }}.html"/>
96
+ <updated>{{ site.time | date_to_xmlschema }}</updated>
97
+ <id>http://example.com/tag/{{ page.tag }}.html</id>
98
+ <author>
99
+ <name>Author Here</name>
100
+ </author>
101
+ {% for post in page.posts %}
102
+ <entry>
103
+ <title>{{ post.title }}</title>
104
+ <link href="http://example.com{{ post.url }}"/>
105
+ <updated>{{ post.date | date_to_xmlschema }}</updated>
106
+ <id>http://example.com{{ post.id }}</id>
107
+ <content type="html">{{ post.content | xml_escape }}</content>
108
+ </entry>
109
+ {% endfor %}
110
+ </feed>
111
+
112
+ == Links
113
+
114
+ <b></b>
115
+ Documentation:: <http://rubydoc.info/gems/jekyll-tagging/frames>
116
+ Source code:: <http://github.com/pattex/jekyll-tagging>
117
+ RubyGem:: <http://rubygems.org/gems/jekyll-tagging>
118
+
119
+ == License
120
+
121
+ === The MIT License
122
+
123
+ Copyright (c) 2010-2012 University of Cologne,
124
+ Albertus-Magnus-Platz, 50923 Cologne, Germany
125
+
126
+ Permission is hereby granted, free of charge, to any person obtaining a copy
127
+ of this software and associated documentation files (the "Software"), to deal
128
+ in the Software without restriction, including without limitation the rights
129
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130
+ copies of the Software, and to permit persons to whom the Software is
131
+ furnished to do so, subject to the following conditions:
132
+
133
+ The above copyright notice and this permission notice shall be included in
134
+ all copies or substantial portions of the Software.
135
+
136
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
142
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require File.expand_path(%q{../lib/jekyll/tagging/version}, __FILE__)
2
+
3
+ begin
4
+ require 'hen'
5
+
6
+ Hen.lay! {{
7
+ :gem => {
8
+ :name => %q{jekyll-tagging},
9
+ :version => Jekyll::Tagging::VERSION,
10
+ :summary => %q{Jekyll plugin to automatically generate a tag cloud and tag pages.},
11
+ :authors => ['Arne Eilermann', 'Jens Wille'],
12
+ :email => ['arne@kleinerdrei.net', 'jens.wille@uni-koeln.de'],
13
+ :license => %q{MIT},
14
+ :homepage => :pattex,
15
+ :dependencies => %w[nuggets]
16
+ }
17
+ }}
18
+ rescue LoadError => err
19
+ warn "Please install the `hen' gem. (#{err})"
20
+ end
21
+
22
+ begin
23
+ require 'jekyll/testtasks/rake'
24
+ rescue LoadError => err
25
+ warn "Please install the `jekyll-testtasks' gem. (#{err})"
26
+ end
@@ -0,0 +1,31 @@
1
+ module Jekyll
2
+
3
+ module Tagging
4
+
5
+ module Version
6
+
7
+ MAJOR = 1
8
+ MINOR = 1
9
+ TINY = 0
10
+
11
+ class << self
12
+
13
+ # Returns array representation.
14
+ def to_a
15
+ [MAJOR, MINOR, TINY]
16
+ end
17
+
18
+ # Short-cut for version string.
19
+ def to_s
20
+ to_a.join('.')
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ VERSION = Version.to_s
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,161 @@
1
+ require 'nuggets/range/quantile'
2
+ require 'nuggets/i18n'
3
+ require 'erb'
4
+ require "jekyll"
5
+
6
+ module Jekyll
7
+
8
+ module Helpers
9
+
10
+ # call-seq:
11
+ # jekyll_tagging_slug(str) => new_str
12
+ #
13
+ # Substitutes any diacritics in _str_ with their ASCII equivalents,
14
+ # whitespaces with dashes and converts _str_ to downcase.
15
+ def jekyll_tagging_slug(str)
16
+ # str.to_s.replace_diacritics.downcase.gsub(/\s/, '-')
17
+ Jekyll::Utils.slugify(str, mode:"latin")
18
+ end
19
+
20
+ end
21
+
22
+ class Tagger < Generator
23
+
24
+ include Helpers
25
+
26
+ safe true
27
+
28
+ attr_accessor :site
29
+
30
+ @types = [:page, :feed]
31
+
32
+ class << self; attr_accessor :types, :site; end
33
+
34
+ def generate(site)
35
+ self.class.site = self.site = site
36
+
37
+ generate_tag_pages
38
+ add_tag_cloud
39
+ end
40
+
41
+ private
42
+
43
+ # Generates a page per tag and adds them to all the pages of +site+.
44
+ # A <tt>tag_page_layout</tt> have to be defined in your <tt>_config.yml</tt>
45
+ # to use this.
46
+ def generate_tag_pages
47
+ active_tags.each { |tag, posts| new_tag(tag, posts) }
48
+ end
49
+
50
+ def new_tag(tag, posts)
51
+ self.class.types.each { |type|
52
+ if layout = site.config["tag_#{type}_layout"]
53
+ data = { 'layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag }
54
+ data.merge!(site.config["tag_#{type}_data"] || {})
55
+
56
+ name = yield data if block_given?
57
+ name ||= tag
58
+ name = jekyll_tagging_slug(name)
59
+
60
+ tag_dir = site.config["tag_#{type}_dir"]
61
+ tag_dir = File.join(tag_dir, (pretty? ? name : ''))
62
+
63
+ page_name = "#{pretty? ? 'index' : name}#{site.layouts[data['layout']].ext}"
64
+
65
+ site.pages << TagPage.new(
66
+ site, site.source, tag_dir, page_name, data
67
+ )
68
+ end
69
+ }
70
+ end
71
+
72
+ def add_tag_cloud(num = 5, name = 'tag_data')
73
+ s, t = site, { name => calculate_tag_cloud(num) }
74
+ s.respond_to?(:add_payload) ? s.add_payload(t) : s.config.update(t)
75
+ end
76
+
77
+ # Calculates the css class of every tag for a tag cloud. The possible
78
+ # classes are: set-1..set-5.
79
+ #
80
+ # [[<TAG>, <CLASS>], ...]
81
+ def calculate_tag_cloud(num = 5)
82
+ range = 0
83
+
84
+ tags = active_tags.map { |tag, posts|
85
+ [tag.to_s, range < (size = posts.size) ? range = size : size]
86
+ }
87
+
88
+
89
+ range = 1..range
90
+
91
+ tags.sort!.map! { |tag, size| [tag, range.quantile(size, num)] }
92
+ end
93
+
94
+ def active_tags
95
+ return site.tags unless site.config["ignored_tags"]
96
+ site.tags.reject { |t| site.config["ignored_tags"].include? t[0] }
97
+ end
98
+
99
+ def pretty?
100
+ @pretty ||= (site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty')
101
+ end
102
+
103
+ end
104
+
105
+ class TagPage < Page
106
+
107
+ def initialize(site, base, dir, name, data = {})
108
+ self.content = data.delete('content') || ''
109
+ self.data = data
110
+
111
+ super(site, base, dir[-1, 1] == '/' ? dir : '/' + dir, name)
112
+ end
113
+
114
+ def read_yaml(*)
115
+ # Do nothing
116
+ end
117
+
118
+ end
119
+
120
+ module TaggingFilters
121
+
122
+ include Helpers
123
+
124
+ def tag_cloud(site)
125
+ active_tag_data.map { |tag, set|
126
+ tag_link(tag, tag_url(tag), :class => "set-#{set}")
127
+ }.join(' ')
128
+ end
129
+
130
+ def tag_link(tag, url = tag_url(tag), html_opts = nil)
131
+ html_opts &&= ' ' << html_opts.map { |k, v| %Q{#{k}="#{v}"} }.join(' ')
132
+ %Q{<a href="#{url}"#{html_opts}>#{tag}</a>}
133
+ end
134
+
135
+ def tag_url(tag, type = :page, site = Tagger.site)
136
+ url = File.join('', site.config["baseurl"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(jekyll_tagging_slug(tag)))
137
+ site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url << '/' : url << '.html'
138
+ end
139
+
140
+ def tags(obj)
141
+ tags = obj['tags'].dup
142
+ tags.map! { |t| t.first } if tags.first.is_a?(Array)
143
+ tags.map! { |t| tag_link(t, tag_url(t), :rel => 'tag') if t.is_a?(String) }.compact!
144
+ tags.join(', ')
145
+ end
146
+
147
+ def keywords(obj)
148
+ return '' if not obj['tags']
149
+ tags = obj['tags'].dup
150
+ tags.join(',')
151
+ end
152
+
153
+ def active_tag_data(site = Tagger.site)
154
+ return site.config['tag_data'] unless site.config["ignored_tags"]
155
+ site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag }
156
+ end
157
+ end
158
+
159
+ end
160
+
161
+ Liquid::Template.register_filter(Jekyll::TaggingFilters)
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: h32-jekyll-tagging
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Arne Eilermann
8
+ - Jens Wille
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-03-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nuggets
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: jekyll
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: hen
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.8.7
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '0.8'
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 0.8.7
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ description: Jekyll plugin to automatically generate a tag cloud and tag pages.
77
+ email:
78
+ - arne@kleinerdrei.net
79
+ - jens.wille@uni-koeln.de
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files:
83
+ - ChangeLog
84
+ files:
85
+ - ChangeLog
86
+ - README.rdoc
87
+ - Rakefile
88
+ - lib/jekyll/tagging.rb
89
+ - lib/jekyll/tagging/version.rb
90
+ homepage: http://github.com/pattex/jekyll-tagging
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message: |2+
95
+
96
+ jekyll-tagging-1.1.0 [2017-03-07]:
97
+
98
+ * Added ability to append extra data to all tag pages. (tfe)
99
+ * Provides compatibility to the current jekyll (3.4.1).
100
+ * A few fixes. (felipe)
101
+ * Some documentation improvements. (wsmoak, jonathanpberger)
102
+ * Prooves who is the worst open source maintainer. (pattex ^__^)
103
+
104
+ rdoc_options:
105
+ - "--title"
106
+ - jekyll-tagging Application documentation (v1.1.0)
107
+ - "--charset"
108
+ - UTF-8
109
+ - "--line-numbers"
110
+ - "--all"
111
+ - "--main"
112
+ - ChangeLog
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubygems_version: 3.3.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Jekyll plugin to automatically generate a tag cloud and tag pages.
130
+ test_files: []