From c71874c394bec1249891611568e8e4f2be33cd50 Mon Sep 17 00:00:00 2001 From: Tsukasa OMOTO Date: Wed, 11 Jun 2014 13:57:52 +0900 Subject: [PATCH 01/23] Support site.config["baseurl"] --- lib/jekyll/tagging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index a9019f4..78cc34b 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -104,7 +104,7 @@ def tag_link(tag, url = tag_url(tag), html_opts = nil) end def tag_url(tag, type = :page, site = Tagger.site) - url = File.join('', site.config["tag_#{type}_dir"], ERB::Util.u(tag)) + url = File.join('', "#{site.config["baseurl"]}/#{site.config["tag_#{type}_dir"]}", ERB::Util.u(tag)) site.permalink_style == :pretty ? url : url << '.html' end From a8bcbe6ca5f0c799305f1a0f2de7a299e453e1a0 Mon Sep 17 00:00:00 2001 From: Stefan Niederhauser Date: Sat, 3 Jan 2015 08:14:54 +0100 Subject: [PATCH 02/23] add configurable threshold and classifier --- lib/jekyll/tagging.rb | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 1c29a0f..8ee83fe 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -13,6 +13,20 @@ class Tagger < Generator class << self; attr_accessor :types, :site; end + @@classifiers={ + 'log'=>proc{|classes,value,min,max| + scaled = (classes*(Math.log(value) - Math.log(min))/(Math.log(max) - Math.log(min))).to_i + scaled == classes ? classes : scaled+1}, + 'linear'=>proc{|classes,value,min,max| (1..max).quantile(value, classes)} + } + + def initialize(config) + @ignored_tags=config["ignored_tags"] || [] + @threshold=(config["tag_threshold"] || '1').to_i + @permalink_style=config['tag_permalink_style'] + @classifier=config['tag_classifier'] || 'linear' + end + def generate(site) self.class.site = self.site = site @@ -50,7 +64,7 @@ def new_tag(tag, posts) end def add_tag_cloud(num = 5, name = 'tag_data') - s, t = site, { name => calculate_tag_cloud(num) } + s, t = site, { name => calculate_tag_cloud(@@classifiers[@classifier].curry[num]) } s.respond_to?(:add_payload) ? s.add_payload(t) : s.config.update(t) end @@ -58,26 +72,18 @@ def add_tag_cloud(num = 5, name = 'tag_data') # classes are: set-1..set-5. # # [[, ], ...] - def calculate_tag_cloud(num = 5) - range = 0 - - tags = active_tags.map { |tag, posts| - [tag.to_s, range < (size = posts.size) ? range = size : size] - } - - - range = 1..range - - tags.sort!.map! { |tag, size| [tag, range.quantile(size, num)] } + def calculate_tag_cloud(classifier) + tags = active_tags.map { |tag, posts| [tag, posts.size] } + min, max = tags.map { |tag, size| size }.minmax + tags.sort!.map! { |tag, size| [tag, classifier.call(size,min,max)] } end def active_tags - return site.tags unless site.config["ignored_tags"] - site.tags.reject { |t| site.config["ignored_tags"].include? t[0] } + site.tags.reject { |t,posts| @ignored_tags.include? t or posts.size < @threshold} end def pretty? - @pretty ||= (site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty') + @pretty ||= (site.permalink_style == :pretty || @permalink_style == 'pretty') end end @@ -125,12 +131,11 @@ def tags(obj) def keywords(obj) return '' if not obj['tags'] tags = obj['tags'].dup - tags.join(',') + tags.join(',') end def active_tag_data(site = Tagger.site) - return site.config['tag_data'] unless site.config["ignored_tags"] - site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag } + return site.config['tag_data'] end end From 7b78cac9fd4b6a3c6b5287f00b7ad9d5d0d490d5 Mon Sep 17 00:00:00 2001 From: Stefan Niederhauser Date: Sat, 3 Jan 2015 08:20:04 +0100 Subject: [PATCH 03/23] cosmetics --- lib/jekyll/tagging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 8ee83fe..a370248 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -79,7 +79,7 @@ def calculate_tag_cloud(classifier) end def active_tags - site.tags.reject { |t,posts| @ignored_tags.include? t or posts.size < @threshold} + site.tags.reject { |tag, posts| @ignored_tags.include? tag or posts.size < @threshold} end def pretty? From 0a294d1a3e1f3f4542ffb1d30bda69ef963b4032 Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Sat, 10 Jan 2015 06:33:14 +0200 Subject: [PATCH 04/23] Fixed pretty permalinks: added trailing slash --- lib/jekyll/tagging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 1c29a0f..6f07949 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -112,7 +112,7 @@ def tag_link(tag, url = tag_url(tag), html_opts = nil) def tag_url(tag, type = :page, site = Tagger.site) url = File.join('', site.config["tag_#{type}_dir"], ERB::Util.u(tag)) - site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url : url << '.html' + site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url << '/' : url << '.html' end def tags(obj) From 92388480e2fe589ec86e0934eec1acce9b3c2509 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Tue, 9 Jun 2015 13:22:54 +0200 Subject: [PATCH 05/23] Tidied parameters. --- lib/jekyll/tagging.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 9c91e28..0a62dde 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -111,7 +111,7 @@ def tag_link(tag, url = tag_url(tag), html_opts = nil) end def tag_url(tag, type = :page, site = Tagger.site) - url = File.join('', "#{site.config["baseurl"]}/#{site.config["tag_#{type}_dir"]}", ERB::Util.u(tag)) + url = File.join('', site.config["base_url"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(tag)) site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url << '/' : url << '.html' end @@ -125,7 +125,7 @@ def tags(obj) def keywords(obj) return '' if not obj['tags'] tags = obj['tags'].dup - tags.join(',') + tags.join(',') end def active_tag_data(site = Tagger.site) From 34b0eb9affff24713218d3c55aaca9a7052f7838 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Tue, 9 Jun 2015 13:57:34 +0200 Subject: [PATCH 06/23] Oh stupid me! m) --- lib/jekyll/tagging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 0a62dde..4b2efa2 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -111,7 +111,7 @@ def tag_link(tag, url = tag_url(tag), html_opts = nil) end def tag_url(tag, type = :page, site = Tagger.site) - url = File.join('', site.config["base_url"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(tag)) + url = File.join('', site.config["baseurl"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(tag)) site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url << '/' : url << '.html' end From 11eb1f9ff3426c270e5f5a55b1a2e8f028aea329 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Wed, 10 Jun 2015 11:59:19 +0200 Subject: [PATCH 07/23] Substitute diacritics with their ASCII equivalents, whitespaces with dashes and converts tags in tag page urls to downcase. --- lib/jekyll/tagging.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 4b2efa2..db81c72 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -1,10 +1,26 @@ require 'nuggets/range/quantile' +require 'nuggets/i18n' require 'erb' module Jekyll + module Helpers + + # call-seq: + # jekyll_tagging_slug(str) => new_str + # + # Substitutes any diacritics in _str_ with their ASCII equivalents, + # whitespaces with dashes and converts _str_ to downcase. + def jekyll_tagging_slug(str) + str.replace_diacritics.downcase.gsub(/\s/, '-') + end + + end + class Tagger < Generator + include Helpers + safe true attr_accessor :site @@ -40,7 +56,7 @@ def new_tag(tag, posts) tag_dir = site.config["tag_#{type}_dir"] tag_dir = File.join(tag_dir, (pretty? ? name : '')) - page_name = "#{pretty? ? 'index' : name}#{site.layouts[data['layout']].ext}" + page_name = "#{pretty? ? 'index' : jekyll_tagging_slug(name)}#{site.layouts[data['layout']].ext}" site.pages << TagPage.new( site, site.source, tag_dir, page_name, data @@ -99,6 +115,8 @@ def read_yaml(*) module Filters + include Helpers + def tag_cloud(site) active_tag_data.map { |tag, set| tag_link(tag, tag_url(tag), :class => "set-#{set}") @@ -111,7 +129,7 @@ def tag_link(tag, url = tag_url(tag), html_opts = nil) end def tag_url(tag, type = :page, site = Tagger.site) - url = File.join('', site.config["baseurl"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(tag)) + url = File.join('', site.config["baseurl"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(jekyll_tagging_slug(tag))) site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url << '/' : url << '.html' end From 7c87d91231592e43224e5876558c5aa30438d560 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Wed, 10 Jun 2015 12:44:55 +0200 Subject: [PATCH 08/23] v1.0.0 --- ChangeLog | 6 ++++++ jekyll-tagging.gemspec | 18 ++++++++++++------ lib/jekyll/tagging/version.rb | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index be40aad..27f9f34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +== 1.0.0 [2015-06-10] + +* Generate prettier urls for tag with whitespaces or non ASCII characters. ATTENTION: Your urls may change! +* Added support for site.config["baseurl"]. (Tsukasa ŌMOTO) +* Added trailing slashes to permalinks. (Pyry Kontio) + == 0.6.0 [2014-09-03] * Pretty permalinks for tag pages. (Steve Valaitis) diff --git a/jekyll-tagging.gemspec b/jekyll-tagging.gemspec index 571d0e2..3e970e6 100644 --- a/jekyll-tagging.gemspec +++ b/jekyll-tagging.gemspec @@ -1,23 +1,23 @@ # -*- encoding: utf-8 -*- -# stub: jekyll-tagging 0.6.0 ruby lib +# stub: jekyll-tagging 1.0.0 ruby lib Gem::Specification.new do |s| s.name = "jekyll-tagging" - s.version = "0.6.0" + s.version = "1.0.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Arne Eilermann", "Jens Wille"] - s.date = "2014-09-03" + s.date = "2015-06-10" s.description = "Jekyll plugin to automatically generate a tag cloud and tag pages." s.email = ["arne@kleinerdrei.net", "jens.wille@uni-koeln.de"] s.extra_rdoc_files = ["ChangeLog"] s.files = ["ChangeLog", "README.rdoc", "Rakefile", "lib/jekyll/tagging.rb", "lib/jekyll/tagging/version.rb"] s.homepage = "http://github.com/pattex/jekyll-tagging" s.licenses = ["MIT"] - s.post_install_message = "\njekyll-tagging-0.6.0 [2014-09-03]:\n\n* Pretty permalinks for tag pages. (Steve Valaitis)\n* Added support for keywords (allenlsy)\n\n" - s.rdoc_options = ["--title", "jekyll-tagging Application documentation (v0.6.0)", "--charset", "UTF-8", "--line-numbers", "--all", "--main", "ChangeLog"] - s.rubygems_version = "2.4.1" + s.post_install_message = "\njekyll-tagging-1.0.0 [2015-06-10]:\n\n* Generate prettier urls for tag with whitespaces or non ASCII characters. ATTENTION: Your urls may change!\n* Added support for site.config[\"baseurl\"]. (Tsukasa \u{14c}MOTO)\n* Added trailing slashes to permalinks. (Pyry Kontio)\n\n" + s.rdoc_options = ["--title", "jekyll-tagging Application documentation (v1.0.0)", "--charset", "UTF-8", "--line-numbers", "--all", "--main", "ChangeLog"] + s.rubygems_version = "2.4.6" s.summary = "Jekyll plugin to automatically generate a tag cloud and tag pages." if s.respond_to? :specification_version then @@ -25,10 +25,16 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0.8.1", "~> 0.8"]) + s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0.8.1", "~> 0.8"]) + s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0.8.1", "~> 0.8"]) + s.add_dependency(%q, [">= 0"]) end end diff --git a/lib/jekyll/tagging/version.rb b/lib/jekyll/tagging/version.rb index 3f60c88..5579865 100644 --- a/lib/jekyll/tagging/version.rb +++ b/lib/jekyll/tagging/version.rb @@ -4,8 +4,8 @@ module Tagging module Version - MAJOR = 0 - MINOR = 6 + MAJOR = 1 + MINOR = 0 TINY = 0 class << self From 73b6fa2e4750870f338c533c65b7b1664c32418f Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Thu, 11 Jun 2015 11:22:10 +0200 Subject: [PATCH 09/23] Substitution of non ASCII characters and whitespaces, also when 'tag_permalink_style: pretty'. m) --- lib/jekyll/tagging.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index db81c72..1691eef 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -52,11 +52,12 @@ def new_tag(tag, posts) name = yield data if block_given? name ||= tag + name = jekyll_tagging_slug(name) tag_dir = site.config["tag_#{type}_dir"] tag_dir = File.join(tag_dir, (pretty? ? name : '')) - page_name = "#{pretty? ? 'index' : jekyll_tagging_slug(name)}#{site.layouts[data['layout']].ext}" + page_name = "#{pretty? ? 'index' : name}#{site.layouts[data['layout']].ext}" site.pages << TagPage.new( site, site.source, tag_dir, page_name, data From a7768f2d2cfce09fe438848e1ecab5a7ed2231c1 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Thu, 11 Jun 2015 11:31:46 +0200 Subject: [PATCH 10/23] v1.0.1 --- ChangeLog | 4 ++++ jekyll-tagging.gemspec | 10 +++++----- lib/jekyll/tagging/version.rb | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27f9f34..f5b7cd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +== 1.0.1 [2015-06-11] + +* Substitution of non ASCII characters and whitespaces, also when 'tag_permalink_style: pretty'. + == 1.0.0 [2015-06-10] * Generate prettier urls for tag with whitespaces or non ASCII characters. ATTENTION: Your urls may change! diff --git a/jekyll-tagging.gemspec b/jekyll-tagging.gemspec index 3e970e6..a76905e 100644 --- a/jekyll-tagging.gemspec +++ b/jekyll-tagging.gemspec @@ -1,22 +1,22 @@ # -*- encoding: utf-8 -*- -# stub: jekyll-tagging 1.0.0 ruby lib +# stub: jekyll-tagging 1.0.1 ruby lib Gem::Specification.new do |s| s.name = "jekyll-tagging" - s.version = "1.0.0" + s.version = "1.0.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Arne Eilermann", "Jens Wille"] - s.date = "2015-06-10" + s.date = "2015-06-11" s.description = "Jekyll plugin to automatically generate a tag cloud and tag pages." s.email = ["arne@kleinerdrei.net", "jens.wille@uni-koeln.de"] s.extra_rdoc_files = ["ChangeLog"] s.files = ["ChangeLog", "README.rdoc", "Rakefile", "lib/jekyll/tagging.rb", "lib/jekyll/tagging/version.rb"] s.homepage = "http://github.com/pattex/jekyll-tagging" s.licenses = ["MIT"] - s.post_install_message = "\njekyll-tagging-1.0.0 [2015-06-10]:\n\n* Generate prettier urls for tag with whitespaces or non ASCII characters. ATTENTION: Your urls may change!\n* Added support for site.config[\"baseurl\"]. (Tsukasa \u{14c}MOTO)\n* Added trailing slashes to permalinks. (Pyry Kontio)\n\n" - s.rdoc_options = ["--title", "jekyll-tagging Application documentation (v1.0.0)", "--charset", "UTF-8", "--line-numbers", "--all", "--main", "ChangeLog"] + s.post_install_message = "\njekyll-tagging-1.0.1 [2015-06-11]:\n\n* Substitution of non ASCII characters and whitespaces, also when 'tag_permalink_style: pretty'.\n\n" + s.rdoc_options = ["--title", "jekyll-tagging Application documentation (v1.0.1)", "--charset", "UTF-8", "--line-numbers", "--all", "--main", "ChangeLog"] s.rubygems_version = "2.4.6" s.summary = "Jekyll plugin to automatically generate a tag cloud and tag pages." diff --git a/lib/jekyll/tagging/version.rb b/lib/jekyll/tagging/version.rb index 5579865..6a52705 100644 --- a/lib/jekyll/tagging/version.rb +++ b/lib/jekyll/tagging/version.rb @@ -6,7 +6,7 @@ module Version MAJOR = 1 MINOR = 0 - TINY = 0 + TINY = 1 class << self From 3790d3a1ad2813072b3b9c51d52bdda11c50da54 Mon Sep 17 00:00:00 2001 From: Wendy Smoak Date: Sun, 19 Jul 2015 08:53:11 -0400 Subject: [PATCH 11/23] Explain where to save the tag feed layout --- README.rdoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 563187d..710dcb1 100644 --- a/README.rdoc +++ b/README.rdoc @@ -9,7 +9,7 @@ jekyll-tagging is a Jekyll plugin, to add a tag cloud and per tag pages plus fee Install it: gem install jekyll-tagging - + Add this line to your Jekyll project's Gemfile: gem 'jekyll-tagging' @@ -64,6 +64,8 @@ Sometimes you don't want tag pages generated for certain pages. That's ok! Just === Example layout of an Atom feed +(Save this to _layouts/tag_feed.xml if using the _config.yml snippet above.) + --- layout: nil --- From 5275135bc44ffe34683d3ffd81964e0282a6d51b Mon Sep 17 00:00:00 2001 From: jonathanpberger Date: Thu, 19 Nov 2015 11:47:26 -0500 Subject: [PATCH 12/23] Add example code for putting tags into posts into README. --- README.rdoc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.rdoc b/README.rdoc index 563187d..d915b34 100644 --- a/README.rdoc +++ b/README.rdoc @@ -40,6 +40,28 @@ If your Jekyll permalink configuration is set to something other than < tag_permalink_style: pretty +=== Adding Tags to Posts + +Tags help organize content. Add space-delimited lowercase tags to FrontMatter, e.g. + + --- + author: John Doe + tags: inventory returns seller buyer + --- + + +=== Adding tags to the main blog page + +Put this in your `index.html` + + + +=== Adding tags to a post + +Put this in your `post.html` + + + === Ignoring tags Sometimes you don't want tag pages generated for certain pages. That's ok! Just add ignored_tags: [tags,to,ignore] to your _config.yml From ed09d3d7b6590d242fe8b57948881567cb000f0e Mon Sep 17 00:00:00 2001 From: felipe Date: Sat, 19 Dec 2015 20:31:54 -0200 Subject: [PATCH 13/23] call to_s --- lib/jekyll/tagging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 1691eef..f2d90ab 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -12,7 +12,7 @@ module Helpers # Substitutes any diacritics in _str_ with their ASCII equivalents, # whitespaces with dashes and converts _str_ to downcase. def jekyll_tagging_slug(str) - str.replace_diacritics.downcase.gsub(/\s/, '-') + str.to_s.replace_diacritics.downcase.gsub(/\s/, '-') end end From 4cfc6830ffe2a4a7f726dd9c3ad269dbb98c5cfa Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Tue, 29 Mar 2016 10:50:54 -0700 Subject: [PATCH 14/23] Add ability to append extra data to all tag pages or tag feeds. --- README.rdoc | 8 ++++++++ lib/jekyll/tagging.rb | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 563187d..1fc3b32 100644 --- a/README.rdoc +++ b/README.rdoc @@ -43,6 +43,14 @@ If your Jekyll permalink configuration is set to something other than < === Ignoring tags Sometimes you don't want tag pages generated for certain pages. That's ok! Just add ignored_tags: [tags,to,ignore] to your _config.yml + +=== Extra data on tag pages + +You can attach extra data to generated tag pages by specifying tag_page_data in _config.yml (this also works for tag_feed_data). For example, you might want to exclude tag pages from being picked up by `jekyll-sitemap`: + + tag_page_data: + sitemap: false + === Example tag page layout (Save this to _layouts/tag_page.html if using the _config.yml snippet above.) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 1691eef..b84d54c 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -48,7 +48,8 @@ def generate_tag_pages def new_tag(tag, posts) self.class.types.each { |type| if layout = site.config["tag_#{type}_layout"] - data = { 'layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag } + data = site.config["tag_#{type}_data"] || {} + data.merge!('layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag) name = yield data if block_given? name ||= tag From b5a653e24e525c63b98af049d2781422ba2d96fb Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Mon, 11 Apr 2016 14:55:44 -0400 Subject: [PATCH 15/23] Flip around the order of merging custom page data and stock data. Haven't fully figured out why yet, but doing it the previous way resulted in only the most recent (?) post being on each tagging page. You'd think the stock data taking precedence in the merge would have been safer, but apparently not. --- lib/jekyll/tagging.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index b84d54c..9b3c87e 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -48,8 +48,8 @@ def generate_tag_pages def new_tag(tag, posts) self.class.types.each { |type| if layout = site.config["tag_#{type}_layout"] - data = site.config["tag_#{type}_data"] || {} - data.merge!('layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag) + data = { 'layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag } + data.merge!(site.config["tag_#{type}_data"] || {}) name = yield data if block_given? name ||= tag From c000c98b18f702f4b212d5f98f74bc078a5c5f89 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Mon, 22 Aug 2016 13:35:01 +0200 Subject: [PATCH 16/23] Changed and removed some of jonathanpberger's additions. --- README.rdoc | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/README.rdoc b/README.rdoc index 4982a51..1e02c8b 100644 --- a/README.rdoc +++ b/README.rdoc @@ -4,6 +4,17 @@ By Arne Eilermann and Jens Wille + +Add space-delimited lowercase tags to FrontMatter, e.g. + + --- + author: Willow Rosenberg + tags: feminism anti-capitalism witchcraft + --- + == Usage Install it: @@ -40,28 +51,6 @@ If your Jekyll permalink configuration is set to something other than < tag_permalink_style: pretty -=== Adding Tags to Posts - -Tags help organize content. Add space-delimited lowercase tags to FrontMatter, e.g. - - --- - author: John Doe - tags: inventory returns seller buyer - --- - - -=== Adding tags to the main blog page - -Put this in your `index.html` - - - -=== Adding tags to a post - -Put this in your `post.html` - - - === Ignoring tags Sometimes you don't want tag pages generated for certain pages. That's ok! Just add ignored_tags: [tags,to,ignore] to your _config.yml From 56985bd4269cbda71e554c072198e701f169b20a Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Tue, 30 Aug 2016 11:23:43 +0200 Subject: [PATCH 17/23] Added tfs's "ability to append extra data to all tag pages" to the ChangeLog. --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index f5b7cd5..0f9abfd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +== 1.1.0 + +* Added ability to append extra data to all tag pages. (tfe) + == 1.0.1 [2015-06-11] * Substitution of non ASCII characters and whitespaces, also when 'tag_permalink_style: pretty'. From d58fd53c61b9f5000cd83343e0ef5db2e98d1fc9 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Thu, 1 Sep 2016 14:18:12 +0200 Subject: [PATCH 18/23] Register the new Liquid filters. --- lib/jekyll/tagging.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index f315e3a..2637751 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -115,7 +115,7 @@ def read_yaml(*) end - module Filters + module TaggingFilters include Helpers @@ -155,3 +155,5 @@ def active_tag_data(site = Tagger.site) end end + +Liquid::Template.register_filter(Jekyll::TaggingFilters) From 1e32a0152bc58f7a65b9a3eba1c9596d4c9d00f1 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Thu, 1 Sep 2016 14:29:56 +0200 Subject: [PATCH 19/23] Corrected wrong documentation. --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index d3e5174..ecc0aff 100644 --- a/README.rdoc +++ b/README.rdoc @@ -36,7 +36,7 @@ And in your _config.yml you have to define your layout used to generate This will look for _layouts/tag_page.html, and use it to generate tag pages into the _site/tag directory. -Now you have a new filter called tag_cloud which you can use with the site 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 tags filter which you can feed with a post or a site object to get a link list of all its tags. +Now you have a new filter called tag_cloud which you can use with the site 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 tags filter which you can feed with a post or a page object to get a link list of all its tags. You can optionally define a per tag Atom/RSS feed. In your _config.yml define the following: From a981f786b161938a871195afc8d19e129f13fb49 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Thu, 1 Sep 2016 14:39:28 +0200 Subject: [PATCH 20/23] Updated dependencies from ruby-nuggets to nuggets. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index c0f875c..78b841e 100644 --- a/Rakefile +++ b/Rakefile @@ -12,7 +12,7 @@ begin :email => ['arne@kleinerdrei.net', 'jens.wille@uni-koeln.de'], :license => %q{MIT}, :homepage => :pattex, - :dependencies => %w[ruby-nuggets] + :dependencies => %w[nuggets] } }} rescue LoadError => err From 76fbc51bc644c660144ed9f6a1b0a854b23ee0f8 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Tue, 7 Mar 2017 12:44:22 +0100 Subject: [PATCH 21/23] v1.1.0 --- ChangeLog | 6 +++- jekyll-tagging.gemspec | 52 +++++++++++++++++------------------ lib/jekyll/tagging/version.rb | 4 +-- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f9abfd..9d0b148 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ -== 1.1.0 +== 1.1.0 [2017-03-07] * Added ability to append extra data to all tag pages. (tfe) +* Provides compatibility to the current jekyll (3.4.1). +* A few fixes. (felipe) +* Some documentation improvements. (wsmoak, jonathanpberger) +* Prooves who is the worst open source maintainer. (pattex ^__^) == 1.0.1 [2015-06-11] diff --git a/jekyll-tagging.gemspec b/jekyll-tagging.gemspec index a76905e..e58f3fd 100644 --- a/jekyll-tagging.gemspec +++ b/jekyll-tagging.gemspec @@ -1,40 +1,40 @@ # -*- encoding: utf-8 -*- -# stub: jekyll-tagging 1.0.1 ruby lib +# stub: jekyll-tagging 1.1.0 ruby lib Gem::Specification.new do |s| - s.name = "jekyll-tagging" - s.version = "1.0.1" + s.name = "jekyll-tagging".freeze + s.version = "1.1.0" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] - s.authors = ["Arne Eilermann", "Jens Wille"] - s.date = "2015-06-11" - s.description = "Jekyll plugin to automatically generate a tag cloud and tag pages." - s.email = ["arne@kleinerdrei.net", "jens.wille@uni-koeln.de"] - s.extra_rdoc_files = ["ChangeLog"] - s.files = ["ChangeLog", "README.rdoc", "Rakefile", "lib/jekyll/tagging.rb", "lib/jekyll/tagging/version.rb"] - s.homepage = "http://github.com/pattex/jekyll-tagging" - s.licenses = ["MIT"] - s.post_install_message = "\njekyll-tagging-1.0.1 [2015-06-11]:\n\n* Substitution of non ASCII characters and whitespaces, also when 'tag_permalink_style: pretty'.\n\n" - s.rdoc_options = ["--title", "jekyll-tagging Application documentation (v1.0.1)", "--charset", "UTF-8", "--line-numbers", "--all", "--main", "ChangeLog"] - s.rubygems_version = "2.4.6" - s.summary = "Jekyll plugin to automatically generate a tag cloud and tag pages." + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Arne Eilermann".freeze, "Jens Wille".freeze] + s.date = "2017-03-07" + s.description = "Jekyll plugin to automatically generate a tag cloud and tag pages.".freeze + s.email = ["arne@kleinerdrei.net".freeze, "jens.wille@uni-koeln.de".freeze] + s.extra_rdoc_files = ["ChangeLog".freeze] + s.files = ["ChangeLog".freeze, "README.rdoc".freeze, "Rakefile".freeze, "lib/jekyll/tagging.rb".freeze, "lib/jekyll/tagging/version.rb".freeze] + s.homepage = "http://github.com/pattex/jekyll-tagging".freeze + s.licenses = ["MIT".freeze] + s.post_install_message = "\njekyll-tagging-1.1.0 [2017-03-07]:\n\n* Added ability to append extra data to all tag pages. (tfe)\n* Provides compatibility to the current jekyll (3.4.1).\n* A few fixes. (felipe)\n* Some documentation improvements. (wsmoak, jonathanpberger)\n* Prooves who is the worst open source maintainer. (pattex ^__^)\n\n".freeze + s.rdoc_options = ["--title".freeze, "jekyll-tagging Application documentation (v1.1.0)".freeze, "--charset".freeze, "UTF-8".freeze, "--line-numbers".freeze, "--all".freeze, "--main".freeze, "ChangeLog".freeze] + s.rubygems_version = "2.6.10".freeze + s.summary = "Jekyll plugin to automatically generate a tag cloud and tag pages.".freeze if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0.8.1", "~> 0.8"]) - s.add_development_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q.freeze, [">= 0"]) + s.add_development_dependency(%q.freeze, [">= 0.8.7", "~> 0.8"]) + s.add_development_dependency(%q.freeze, [">= 0"]) else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0.8.1", "~> 0.8"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q.freeze, [">= 0"]) + s.add_dependency(%q.freeze, [">= 0.8.7", "~> 0.8"]) + s.add_dependency(%q.freeze, [">= 0"]) end else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0.8.1", "~> 0.8"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q.freeze, [">= 0"]) + s.add_dependency(%q.freeze, [">= 0.8.7", "~> 0.8"]) + s.add_dependency(%q.freeze, [">= 0"]) end end diff --git a/lib/jekyll/tagging/version.rb b/lib/jekyll/tagging/version.rb index 6a52705..41bc146 100644 --- a/lib/jekyll/tagging/version.rb +++ b/lib/jekyll/tagging/version.rb @@ -5,8 +5,8 @@ module Tagging module Version MAJOR = 1 - MINOR = 0 - TINY = 1 + MINOR = 1 + TINY = 0 class << self From 6bcb17858f8ffb37ca869ef19ec76bb423ab87c0 Mon Sep 17 00:00:00 2001 From: Stefan Niederhauser Date: Sat, 3 Jan 2015 08:14:54 +0100 Subject: [PATCH 22/23] add configurable threshold and classifier --- lib/jekyll/tagging.rb | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 2637751..523482a 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -29,6 +29,20 @@ class Tagger < Generator class << self; attr_accessor :types, :site; end + @@classifiers={ + 'log'=>proc{|classes,value,min,max| + scaled = (classes*(Math.log(value) - Math.log(min))/(Math.log(max) - Math.log(min))).to_i + scaled == classes ? classes : scaled+1}, + 'linear'=>proc{|classes,value,min,max| (1..max).quantile(value, classes)} + } + + def initialize(config) + @ignored_tags=config["ignored_tags"] || [] + @threshold=(config["tag_threshold"] || '1').to_i + @permalink_style=config['tag_permalink_style'] + @classifier=config['tag_classifier'] || 'linear' + end + def generate(site) self.class.site = self.site = site @@ -68,7 +82,7 @@ def new_tag(tag, posts) end def add_tag_cloud(num = 5, name = 'tag_data') - s, t = site, { name => calculate_tag_cloud(num) } + s, t = site, { name => calculate_tag_cloud(@@classifiers[@classifier].curry[num]) } s.respond_to?(:add_payload) ? s.add_payload(t) : s.config.update(t) end @@ -76,26 +90,18 @@ def add_tag_cloud(num = 5, name = 'tag_data') # classes are: set-1..set-5. # # [[, ], ...] - def calculate_tag_cloud(num = 5) - range = 0 - - tags = active_tags.map { |tag, posts| - [tag.to_s, range < (size = posts.size) ? range = size : size] - } - - - range = 1..range - - tags.sort!.map! { |tag, size| [tag, range.quantile(size, num)] } + def calculate_tag_cloud(classifier) + tags = active_tags.map { |tag, posts| [tag, posts.size] } + min, max = tags.map { |tag, size| size }.minmax + tags.sort!.map! { |tag, size| [tag, classifier.call(size,min,max)] } end def active_tags - return site.tags unless site.config["ignored_tags"] - site.tags.reject { |t| site.config["ignored_tags"].include? t[0] } + site.tags.reject { |t,posts| @ignored_tags.include? t or posts.size < @threshold} end def pretty? - @pretty ||= (site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty') + @pretty ||= (site.permalink_style == :pretty || @permalink_style == 'pretty') end end @@ -149,8 +155,7 @@ def keywords(obj) end def active_tag_data(site = Tagger.site) - return site.config['tag_data'] unless site.config["ignored_tags"] - site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag } + return site.config['tag_data'] end end From 65443a6eacbbb323337b614d03678fe4a13d7244 Mon Sep 17 00:00:00 2001 From: Stefan Niederhauser Date: Sat, 3 Jan 2015 08:20:04 +0100 Subject: [PATCH 23/23] cosmetics --- lib/jekyll/tagging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tagging.rb b/lib/jekyll/tagging.rb index 523482a..e4164b7 100644 --- a/lib/jekyll/tagging.rb +++ b/lib/jekyll/tagging.rb @@ -97,7 +97,7 @@ def calculate_tag_cloud(classifier) end def active_tags - site.tags.reject { |t,posts| @ignored_tags.include? t or posts.size < @threshold} + site.tags.reject { |tag, posts| @ignored_tags.include? tag or posts.size < @threshold} end def pretty?