Class: Jekyll::TagsList
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::TagsList
- Defined in:
- lib/mm-jekyll-tags-list.rb
Class Method Summary collapse
- .calculate_maximum_post_count(site) ⇒ Object
- .calculate_popularity(maximum, count) ⇒ Object
- .calculate_popularity_class(site, maximum, popularity) ⇒ Object
- .generate_tags_structure(site) ⇒ Object
- .number_of_posts_for_tag(site, tag) ⇒ Object
Instance Method Summary collapse
Class Method Details
.calculate_maximum_post_count(site) ⇒ Object
28 29 30 |
# File 'lib/mm-jekyll-tags-list.rb', line 28 def self.calculate_maximum_post_count(site) max = site..map { |tag,posts| posts.count }.max end |
.calculate_popularity(maximum, count) ⇒ Object
36 37 38 |
# File 'lib/mm-jekyll-tags-list.rb', line 36 def self.calculate_popularity(maximum, count) percent = ((count.to_f / maximum) * 100).floor end |
.calculate_popularity_class(site, maximum, popularity) ⇒ Object
24 25 26 |
# File 'lib/mm-jekyll-tags-list.rb', line 24 def self.calculate_popularity_class(site, maximum, popularity) output = ((site.config['number_popularity_classes'] / 100.to_f) * popularity).round end |
.generate_tags_structure(site) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mm-jekyll-tags-list.rb', line 9 def self.(site) = Hash.new maximum = calculate_maximum_post_count(site) for tag in site..keys do [tag] = Hash.new post_count = number_of_posts_for_tag(site, tag) popularity = calculate_popularity(maximum, post_count) popularity_class = calculate_popularity_class(site, maximum, popularity) [tag]['post_count'] = post_count.to_s [tag]['popularity'] = popularity.to_s [tag]['popularity_class'] = popularity_class.to_s end end |
.number_of_posts_for_tag(site, tag) ⇒ Object
32 33 34 |
# File 'lib/mm-jekyll-tags-list.rb', line 32 def self.number_of_posts_for_tag(site, tag) count = site.[tag].length end |