diff options
| -rw-r--r-- | _config.yml.example | 12 | ||||
| -rw-r--r-- | _site_build/_includes/post_excerpt.html | 3 | ||||
| -rw-r--r-- | _site_build/_layouts/category_index.html | 10 | ||||
| -rw-r--r-- | _site_build/_layouts/post.html | 3 | ||||
| -rw-r--r-- | _site_build/_plugins/category_indexes.rb | 63 | ||||
| -rw-r--r-- | _site_build/css/style.css | 30 | ||||
| -rw-r--r-- | _site_build/index.html | 2 | ||||
| -rw-r--r-- | templates/post.markdown | 1 |
8 files changed, 105 insertions, 19 deletions
diff --git a/_config.yml.example b/_config.yml.example index 248c858..e46d2bc 100644 --- a/_config.yml.example +++ b/_config.yml.example @@ -68,3 +68,15 @@ permalink: /archives/:year/:month/:day/:title/ # Directory where plugins are located. plugins: _site_build/_plugins + +# Set to true to have Jekyll generate category pages for posts. +#generate_category_indexes: true + +# The directory where categories will be served from. Defaults to categories +#category_dir: + +# String prefixed to the title of the category page. Defaults to Category: +#category_title_prefix: + +# String prefixed to the meta description of the category page. Defaults to Category: +#category_meta_description_prefix: diff --git a/_site_build/_includes/post_excerpt.html b/_site_build/_includes/post_excerpt.html index 461cb55..48e4a1e 100644 --- a/_site_build/_includes/post_excerpt.html +++ b/_site_build/_includes/post_excerpt.html @@ -2,6 +2,9 @@ <header> <h1><a href="{{ post.url }}" rel="bookmark" target="_self" title="{{ post.title }}">{{ post.title }}</a></h1> <time datetime="{{ post.date | date: '%Y-%m-%d' }}" pubdate>{{ post.date | date: '%A' }} {{ post.date | ordinalize }} {{ post.date | date: '%B, %Y' }}</time> + {% if post.categories.size != 0 %} + <div class="categories">Posted in {{ post.categories | category_links }}</div> + {% endif %} </header> {{ post.content | truncate }} </article> diff --git a/_site_build/_layouts/category_index.html b/_site_build/_layouts/category_index.html new file mode 100644 index 0000000..729ff2e --- /dev/null +++ b/_site_build/_layouts/category_index.html @@ -0,0 +1,10 @@ +--- +layout: default +robots: follow, noindex, noodp, noydir, noarchive +--- +<section id="category"> + <h1>{{ page.title }}</h1> + {% for post in site.categories[page.category] %} + {% include post_excerpt.html %} + {% endfor %} +</section> diff --git a/_site_build/_layouts/post.html b/_site_build/_layouts/post.html index e45ca24..61f0d09 100644 --- a/_site_build/_layouts/post.html +++ b/_site_build/_layouts/post.html @@ -5,6 +5,9 @@ layout: default <header> <h1>{{ page.title }}</h1> <time datetime="{{ page.date | date: '%Y-%m-%d' }}" pubdate>{{ page.date | date: '%A' }} {{ page.date | ordinalize }} {{ page.date | date: '%B, %Y' }}</time> + {% if page.categories.size != 0 %} + <div class="categories">Posted in {{ page.categories | category_links }}</div> + {% endif %} </header> {{ content }} <footer> diff --git a/_site_build/_plugins/category_indexes.rb b/_site_build/_plugins/category_indexes.rb new file mode 100644 index 0000000..10dae02 --- /dev/null +++ b/_site_build/_plugins/category_indexes.rb @@ -0,0 +1,63 @@ +module Jekyll + # Monkey patch so that both GenerateCategoryIndexes and CategoryFilter have access to this method. + class Site + # A very simple implementation. + def parameterize(string, sep = '-') + string.downcase.gsub(/[^a-z0-9\-_]+/, sep) + end + end + + class CategoryIndex < Page + def initialize(site, base, dir, category) + @site = site + @base = base + @dir = dir + @name = 'index.html' + + self.process(@name) + self.read_yaml(File.join(base, '_layouts'), 'category_index.html') + self.data['category'] = category + + title_prefix = site.config['category_title_prefix'] || 'Category: ' + self.data['title'] = "#{title_prefix}#{category}" + + description_prefix = site.config['category_meta_description_prefix'] || 'Category: ' + self.data['description'] = "#{description_prefix}#{category}" + end + end + + class GenerateCategoryIndexes < Generator + safe true + priority :low + + def generate(site) + if site.config['generate_category_indexes'] && site.layouts.key?('category_index') + dir = site.config['category_dir'] || 'categories' + site.categories.keys.each do |category| + write_category_index(site, File.join("/#{dir}", site.parameterize(category)), category) + end + end + end + + def write_category_index(site, dir, category) + index = CategoryIndex.new(site, site.source, dir, category) + index.render(site.layouts, site.site_payload) + index.write(site.dest) + site.pages << index + end + end + + module CategoryFilter + def category_links(categories) + site = @context.registers[:site] + directory = site.config['category_dir'] || 'categories' + categories = categories.sort.map do |item| + '<a href="/' + directory + '/' + site.parameterize(item) + '/" rel="category tag" target="_self" title="View all posted in ' + item +'">' + item + '</a>' + end + categories.join(', ') + end + end + +end + +Liquid::Template.register_filter(Jekyll::CategoryFilter) diff --git a/_site_build/css/style.css b/_site_build/css/style.css index 1c85690..af0f67a 100644 --- a/_site_build/css/style.css +++ b/_site_build/css/style.css @@ -159,10 +159,14 @@ h1, h2, h3, h4, h5, h6 { padding: 0; } -article h1, section#about h1, section#archives h1 { +article h1, section#about h1, section#archives h1, section#category > h1 { font-size: 1.461538462em; /* 19 / 13 */ } +section#about h1, section#archives h1, section#category > h1 { + margin-bottom: 1em; +} + article h2, section#about h2, section#archives h2 { font-size: 1.1538461538em; /* 15 / 13 */ } @@ -206,16 +210,20 @@ article h2, section#about h2, section#archives h2 { text-transform: lowercase; } -li.prev-article a, li.next-article a { +article.excerpt { + margin-bottom: 2em; +} + +article li.prev-article a, article li.next-article a { display: block; } -li.prev-article { +article li.prev-article { float: left; width: 50%; } -li.next-article { +article li.next-article { float: right; text-align: right; width: 50%; @@ -230,24 +238,10 @@ article footer nav ul:after { visibility: hidden; } -article.excerpt { - margin-bottom: 2em; -} - -section#archives h1 { - margin-bottom: 1em; -} - section#archives ol { list-style-type: disc; } -section#archives time { - display: inline-block; - width: 4em; -} - - /* ==|== non-semantic helper classes ======================================== */ .ir { display: block; border: 0; text-indent: -999em; overflow: hidden; background-color: transparent; background-repeat: no-repeat; text-align: left; direction: ltr; } .ir br { display: none; } diff --git a/_site_build/index.html b/_site_build/index.html index 7b96318..71a3e34 100644 --- a/_site_build/index.html +++ b/_site_build/index.html @@ -3,7 +3,7 @@ layout: default title: Home robots: follow, noindex, noodp, noydir, noarchive --- -<section id="excerpts"> +<section id="recent-posts"> {% for post in site.posts limit:site.max_recent_posts %} {% include post_excerpt.html %} {% endfor %} diff --git a/templates/post.markdown b/templates/post.markdown index 9c1ae66..549e9bf 100644 --- a/templates/post.markdown +++ b/templates/post.markdown @@ -3,6 +3,7 @@ layout: post title: :title author: description: +categories: [Rails Plugins, Javascript, Ruby] --- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et tellus ac sem vestibulum tristique ac at magna. Proin eros ipsum, egestas sit amet rutrum non, fringilla ut tellus. Sed facilisis rhoncus libero ornare interdum. Morbi a dui id quam dignissim mollis at sit amet purus. Ut pretium malesuada dolor, eu luctus lorem bibendum id. Mauris cursus cursus est sit amet lobortis. Quisque sit amet dui quis sapien fringilla tempus et convallis lectus. Integer pretium tristique sollicitudin. Fusce at ante et tellus vulputate congue. Aliquam nec ligula est. Vestibulum aliquet scelerisque neque, ut elementum neque mattis id. Sed non mauris quam. Vivamus id augue felis. Etiam eleifend, erat sit amet tempor tempor, nibh neque tristique lorem, pretium adipiscing nulla lorem sit amet lacus. Vestibulum odio mauris, hendrerit non dictum sit amet, consequat in mi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est nulla, pulvinar eget volutpat quis, placerat nec metus. Vivamus tristique elit ac lectus vestibulum bibendum. Phasellus ac diam purus, cursus imperdiet lorem. Sed a nulla nec velit placerat tempus. |
