-
-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds: - a tag cloud page that lists all the tags, - a link at the left of the search bar to access the tag page, - a page for each tag, listing the products having the tag, - a link on each tag of product pages to access corresponding tag page.
- Loading branch information
1 parent
92077bd
commit 0c2c2c2
Showing
10 changed files
with
225 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{%- assign product_icon_url = include.product.iconUrl %} | ||
{%- assign product_icon_description = include.product.title %} | ||
{%- assign product_icon_size = include.size %} | ||
{%- unless product_icon_url %} | ||
{%- assign product_icon_url = '/assets/default-product-logo.svg' | relative_url %} | ||
{%- assign product_icon_description = 'No product' %} | ||
{%- endunless %} | ||
<img class="product-logo" width="{{ product_icon_size }}" src="{{ product_icon_url }}" alt="{{ product_icon_description }} logo"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
layout: default | ||
--- | ||
<h1>{{ page.title }}</h1> | ||
|
||
{% for product in page.products %} | ||
<div class="product-list-item"> | ||
<h2 class="product-title"> | ||
{% include product-icon.html product=product size=30 %} | ||
<a href="{{ product.permalink }}">{{ product.title }}</a> | ||
</h2> | ||
<div class="product-description"> | ||
{{ product.content | extract_element:'blockquote' | first | extract_element:'p' }} | ||
</div> | ||
</div> | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
<h1>{{ page.title }}</h1> | ||
|
||
<ul class="tag-cloud" role="navigation" aria-label="Product tag cloud"> | ||
{% for tag_with_weight in page.tags %} | ||
{% assign tag = tag_with_weight | split:'|' | first %} | ||
{% assign weight = tag_with_weight | split:'|' | last %} | ||
<li><a href="/tags/{{ tag }}" data-weight="{{ weight }}">{{ tag }} ({{ weight }})</a></li> | ||
{% endfor %} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# This script create product pages for the website. | ||
|
||
require 'jekyll' | ||
|
||
module EndOfLife | ||
|
||
class ProductPagesGenerator < Jekyll::Generator | ||
safe true | ||
priority :lowest | ||
|
||
TOPIC = "Tag pages:" | ||
|
||
def generate(site) | ||
@site = site | ||
start = Time.now | ||
Jekyll.logger.info TOPIC, "Generating..." | ||
|
||
products = site.pages.select { |page| page.data['layout'] == 'product' } | ||
|
||
products_by_tag = products_by_tag(products) | ||
site.pages << TagsPage.new(site, products_by_tag) | ||
products_by_tag.each do |tag, products_for_tag| | ||
site.pages << TagPage.new(site, tag, products_for_tag) | ||
end | ||
|
||
Jekyll.logger.info TOPIC, "Done in #{(Time.now - start).round(3)} seconds." | ||
end | ||
|
||
def products_by_tag(products) | ||
products_by_tag = {} | ||
products.each do |product| | ||
product.data['tags'].each { |tag| add_to_map(products_by_tag, tag, product) } | ||
end | ||
products_by_tag | ||
end | ||
|
||
def add_to_map(map, key, page) | ||
if map.has_key? key | ||
map[key] << page | ||
else | ||
map[key] = [page] | ||
end | ||
end | ||
end | ||
|
||
class TagsPage < Jekyll::Page | ||
def initialize(site, products_by_tag) | ||
@site = site | ||
@base = site.source | ||
@dir = "tags" | ||
@name = "index.html" | ||
|
||
tags = products_by_tag.map { |tag, value| "#{tag}|#{value.size()}" }.sort | ||
@data = { | ||
"title" => "Product tags", | ||
"layout" => "product-tags", | ||
"permalink" => "/tags/", | ||
"tags" => tags, | ||
"nav_exclude"=> true | ||
} | ||
|
||
self.process(@name) | ||
end | ||
end | ||
|
||
class TagPage < Jekyll::Page | ||
def initialize(site, tag, products) | ||
@site = site | ||
@base = site.source | ||
@dir = "tags" | ||
@name = "#{tag}.html" | ||
|
||
@data = { | ||
"title" => "Products tagged with '#{tag}'", | ||
"layout" => "product-list", | ||
"permalink" => "/tags/#{tag}", | ||
"products" => products.sort_by { |product| product.data['title'] }, | ||
"nav_exclude"=> true | ||
} | ||
|
||
self.process(@name) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters