diff --git a/Gruntfile.js b/Gruntfile.js index f101653f..8bd463e2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -50,7 +50,7 @@ module.exports = function(grunt){ options: { drafts: true, future: true, - limit_posts: 50 + //limit_posts: 50 } } }, @@ -164,7 +164,7 @@ module.exports = function(grunt){ }, jekyll: { files: [ - '<%= config.src %>/*.html', + '<%= config.src %>/**/*.html', '<%= config.src %>/*.xml', '<%= config.src %>/*.json', '<%= config.src %>/_includes/**', diff --git a/_src/_includes/index.html b/_src/_includes/articles.html similarity index 100% rename from _src/_includes/index.html rename to _src/_includes/articles.html diff --git a/_src/_includes/category_index.html b/_src/_includes/category_index.html new file mode 100644 index 00000000..9704983c --- /dev/null +++ b/_src/_includes/category_index.html @@ -0,0 +1,38 @@ + +{% if post.categories contains "goodies" %} + +
+
+

{{ post.title | titlecase }}

+
+ +
+ + {% if post.image %} + + {% picture {{ post.image }} class="teaser" %} + + {% else %} + {{ post.excerpt }} + {% endif %} + + + +
+
+ +{% else %} + {% include articles.html %} +{% endif %} \ No newline at end of file diff --git a/_src/_layouts/category_index.html b/_src/_layouts/category_index.html deleted file mode 100644 index b9c2f25a..00000000 --- a/_src/_layouts/category_index.html +++ /dev/null @@ -1,60 +0,0 @@ ---- -layout: base ---- - -
- -

/{{ page.category }}

- - {% if page.url contains "/photos" %} -
-
- {% endif %} - - {% for post in site.categories[page.category] %} - - {% if post.categories contains "goodies" %} - - - - {% else %} - {% include index.html %} - {% endif %} - - {% endfor %} - - {% if page.url contains "/photos" %} -
- {% endif %} - -
\ No newline at end of file diff --git a/_src/_plugins/cat_pagination.rb b/_src/_plugins/cat_pagination.rb new file mode 100644 index 00000000..5679e955 --- /dev/null +++ b/_src/_plugins/cat_pagination.rb @@ -0,0 +1,78 @@ +# +# https://gist.github.com/runemadsen/6263974 +# +# modified +# + +module Jekyll + + class Pagination < Generator + def generate(site) + end + end + + class CategoryPages < Generator + + safe true + + def generate(site) + + site.pages.dup.each do |page| + paginate(site, page) if CategoryPager.pagination_enabled?(site.config, page) + end + + end + + def paginate(site, page) + + # sort categories by descending date of publish + category_posts = site.categories[page.data['category']].sort_by { |p| -p.date.to_f } + + # calculate total number of pages + pages = CategoryPager.calculate_pages(category_posts, site.config['paginate'].to_i) + + # iterate over the total number of pages and create a physical page for each + (1..pages).each do |num_page| + + # the CategoryPager handles the paging and category data + pager = CategoryPager.new(site, num_page, category_posts, page.data['category'], pages) + + if num_page > 1 + newpage = Page.new(site, site.source, page.dir, page.name) + newpage.pager = pager + newpage.dir = File.join(page.dir, "/page/#{num_page}") + site.pages << newpage + else + page.pager = pager + end + + end + end + + end + + class CategoryPager < Pager + + attr_reader :category + + def self.pagination_enabled?(config, page) + page.name == 'index.html' && page.data.key?('category') && !config['paginate'].nil? + end + + # same as the base class, but includes the category value + def initialize(site, page, all_posts, category, num_pages = nil) + @category = category + super site, page, all_posts, num_pages + end + + # use the original to_liquid method, but add in category info + alias_method :original_to_liquid, :to_liquid + def to_liquid + x = original_to_liquid + x['category'] = @category + x + end + + end + +end \ No newline at end of file diff --git a/_src/_plugins/generate_categories.rb b/_src/_plugins/generate_categories.rb deleted file mode 100644 index 1d3b16ef..00000000 --- a/_src/_plugins/generate_categories.rb +++ /dev/null @@ -1,212 +0,0 @@ -# encoding: utf-8 -# -# Jekyll category page generator. -# http://recursive-design.com/projects/jekyll-plugins/ -# -# Version: 0.2.4 (201210160037) -# -# Copyright (c) 2010 Dave Perrett, http://recursive-design.com/ -# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) -# -# A generator that creates category pages for jekyll sites. -# -# To use it, simply drop this script into the _plugins directory of your Jekyll site. You should -# also create a file called 'category_index.html' in the _layouts directory of your jekyll site -# with the following contents (note: you should remove the leading '# ' characters): -# -# ================================== COPY BELOW THIS LINE ================================== -# --- -# layout: default -# --- -# -#

{{ page.title }}

-# -# ================================== COPY ABOVE THIS LINE ================================== -# -# You can alter the _layout_ setting if you wish to use an alternate layout, and obviously you -# can change the HTML above as you see fit. -# -# When you compile your jekyll site, this plugin will loop through the list of categories in your -# site, and use the layout above to generate a page for each one with a list of links to the -# individual posts. -# -# You can also (optionally) generate an atom.xml feed for each category. To do this, copy -# the category_feed.xml file to the _includes/custom directory of your own project -# (https://github.com/recurser/jekyll-plugins/blob/master/_includes/custom/category_feed.xml). -# You'll also need to copy the octopress_filters.rb file into the _plugins directory of your -# project as the category_feed.xml requires a couple of extra filters -# (https://github.com/recurser/jekyll-plugins/blob/master/_plugins/octopress_filters.rb). -# -# Included filters : -# - category_links: Outputs the list of categories as comma-separated links. -# - date_to_html_string: Outputs the post.date as formatted html, with hooks for CSS styling. -# -# Available _config.yml settings : -# - category_dir: The subfolder to build category pages in (default is 'categories'). -# - category_title_prefix: The string used before the category name in the page title (default is -# 'Category: '). -module Jekyll - - # The CategoryIndex class creates a single category page for the specified category. - class CategoryPage < Page - - # Initializes a new CategoryIndex. - # - # +template_path+ is the path to the layout template to use. - # +site+ is the Jekyll Site instance. - # +base+ is the String path to the . - # +category_dir+ is the String path between and the category folder. - # +category+ is the category currently being processed. - def initialize(template_path, name, site, base, category_dir, category) - @site = site - @base = base - @dir = category_dir - @name = name - - self.process(name) - - if File.exist?(template_path) - @perform_render = true - template_dir = File.dirname(template_path) - template = File.basename(template_path) - # Read the YAML data from the layout page. - self.read_yaml(template_dir, template) - self.data['category'] = category - # Set the title for this page. - title_prefix = site.config['category_title_prefix'] || 'Category: ' - self.data['title'] = "#{title_prefix}#{category}" - # Set the meta-description for this page. - meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: ' - self.data['description'] = "#{meta_description_prefix}#{category}" - else - @perform_render = false - end - end - - def render? - @perform_render - end - - end - - # The CategoryIndex class creates a single category page for the specified category. - class CategoryIndex < CategoryPage - - # Initializes a new CategoryIndex. - # - # +site+ is the Jekyll Site instance. - # +base+ is the String path to the . - # +category_dir+ is the String path between and the category folder. - # +category+ is the category currently being processed. - def initialize(site, base, category_dir, category) - template_path = File.join(base, '_layouts', 'category_index.html') - super(template_path, 'index.html', site, base, category_dir, category) - end - - end - - # The Site class is a built-in Jekyll class with access to global site config information. - class Site - - # Creates an instance of CategoryIndex for each category page, renders it, and - # writes the output to a file. - # - # +category+ is the category currently being processed. - def write_category_index(category) - target_dir = GenerateCategories.category_dir(self.config['category_dir'], category) - index = CategoryIndex.new(self, self.source, target_dir, category) - if index.render? - index.render(self.layouts, site_payload) - index.write(self.dest) - # Record the fact that this pages has been added, otherwise Site::cleanup will remove it. - self.pages << index - end - end - - # Loops through the list of category pages and processes each one. - def write_category_indexes - if self.layouts.key? 'category_index' - self.categories.keys.each do |category| - self.write_category_index(category) - end - - # Throw an exception if the layout couldn't be found. - else - throw "No 'category_index' layout found." - end - end - - end - - - # Jekyll hook - the generate method is called by jekyll, and generates all of the category pages. - class GenerateCategories < Generator - safe true - priority :low - - CATEGORY_DIR = 'categories' - - def generate(site) - site.write_category_indexes - end - - # Processes the given dir and removes leading and trailing slashes. Falls - # back on the default if no dir is provided. - def self.category_dir(base_dir, category) - base_dir = (base_dir || CATEGORY_DIR).gsub(/^\/*(.*)\/*$/, '\1') - category = category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase - File.join(base_dir, category) - end - - end - - - # Adds some extra filters used during the category creation process. - module Filters - - # Outputs a list of categories as comma-separated links. This is used - # to output the category list for each post on a category page. - # - # +categories+ is the list of categories to format. - # - # Returns string - def category_links(categories) - base_dir = @context.registers[:site].config['category_dir'] - categories = categories.sort!.map do |category| - category_dir = GenerateCategories.category_dir(base_dir, category) - # Make sure the category directory begins with a slash. - category_dir = "/#{category_dir}" unless category_dir =~ /^\// - "#{category}" - end - - case categories.length - when 0 - "" - when 1 - categories[0].to_s - else - categories.join(', ') - end - end - - # Outputs the post.date as formatted html, with hooks for CSS styling. - # - # +date+ is the date object to format as HTML. - # - # Returns string - def date_to_html_string(date) - result = '' + date.strftime('%b').upcase + ' ' - result += date.strftime('%d ') - result += date.strftime('%Y ') - result - end - - end - -end \ No newline at end of file diff --git a/_src/design/index.html b/_src/design/index.html new file mode 100644 index 00000000..4eaf772f --- /dev/null +++ b/_src/design/index.html @@ -0,0 +1,20 @@ +--- +layout: base +title: Design +description: All the design related articles, mostly about web/ui design & front-end development +category: design +--- + +
+ +

/{{ page.category }}

+ + {% for post in paginator.posts %} + + {% include category_index.html %} + + {% endfor %} + +
+ +{% include paginator.html %} \ No newline at end of file diff --git a/_src/goodies/index.html b/_src/goodies/index.html new file mode 100644 index 00000000..61eba2c3 --- /dev/null +++ b/_src/goodies/index.html @@ -0,0 +1,20 @@ +--- +layout: base +title: Goodies +description: All the goodies I've released for you to download. Those are all free for your personal use only, licensed under CC BY NC SA 3.0. Please contact me if you want to use them commercially. +category: goodies +--- + +
+ +

/{{ page.category }}

+ + {% for post in paginator.posts %} + + {% include category_index.html %} + + {% endfor %} + +
+ +{% include paginator.html %} \ No newline at end of file diff --git a/_src/index.html b/_src/index.html index 76d0e622..1daa12dc 100644 --- a/_src/index.html +++ b/_src/index.html @@ -12,7 +12,7 @@ description: 'Blog of designer & developer Matthias Kretschmann' {% for post in paginator.posts %} - {% include index.html %} + {% include articles.html %} {% endfor %} diff --git a/_src/personal/index.html b/_src/personal/index.html new file mode 100644 index 00000000..c92024c8 --- /dev/null +++ b/_src/personal/index.html @@ -0,0 +1,19 @@ +--- +layout: base +title: Personal +category: personal +--- + +
+ +

/{{ page.category }}

+ + {% for post in paginator.posts %} + + {% include category_index.html %} + + {% endfor %} + +
+ +{% include paginator.html %} \ No newline at end of file diff --git a/_src/photography/index.html b/_src/photography/index.html new file mode 100644 index 00000000..42d55fed --- /dev/null +++ b/_src/photography/index.html @@ -0,0 +1,19 @@ +--- +layout: base +title: Photography +category: photography +--- + +
+ +

/{{ page.category }}

+ + {% for post in paginator.posts %} + + {% include category_index.html %} + + {% endfor %} + +
+ +{% include paginator.html %} \ No newline at end of file diff --git a/_src/photos/index.html b/_src/photos/index.html new file mode 100644 index 00000000..a41ec53f --- /dev/null +++ b/_src/photos/index.html @@ -0,0 +1,25 @@ +--- +layout: base +title: Photos +description: My photo posts aggregated from various sources. You can find more of my photography on 500px and Flickr. +category: photos +--- + +
+ +

/{{ page.category }}

+ +
+
+ + {% for post in paginator.posts %} + + {% include category_index.html %} + + {% endfor %} + +
+ +
+ +{% include paginator.html %} \ No newline at end of file