mirror of
https://github.com/WatchOutNewsAgency/wona.github.com.git
synced 2026-01-01 01:16:26 +00:00
Cleaned out public from repository, updated gitignore, added syntax
highlighting tests, improved syntax highlighting and styling of pre blocks. Overriding dynamic gist styling. Added a plugin for pygments caching which should speed things up terrifically. added ender.js as a lightweight way of scripting the DOM, events, etc. Some general typography and semantic html improvements.
This commit is contained in:
65
_plugins/category.rb
Normal file
65
_plugins/category.rb
Normal file
@ -0,0 +1,65 @@
|
||||
module Jekyll
|
||||
|
||||
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
|
||||
|
||||
category_title_prefix = site.config['category_title_prefix'] || 'Category: '
|
||||
self.data['title'] = "#{category_title_prefix}#{category}"
|
||||
end
|
||||
end
|
||||
|
||||
class CategoryList < Page
|
||||
def initialize(site, base, dir, categories)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
@name = 'index.html'
|
||||
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(base, '_layouts'), 'category_list.html')
|
||||
self.data['categories'] = categories
|
||||
end
|
||||
end
|
||||
|
||||
class CategoryGenerator < Generator
|
||||
safe true
|
||||
|
||||
def generate(site)
|
||||
if site.layouts.key? 'category_index'
|
||||
dir = site.config['category_dir'] || 'categories'
|
||||
site.categories.keys.each do |category|
|
||||
write_category_index(site, File.join(dir, category.gsub(/\s/, "-").gsub(/[^\w-]/, '').downcase), category)
|
||||
end
|
||||
end
|
||||
|
||||
if site.layouts.key? 'category_list'
|
||||
dir = site.config['category_dir'] || 'categories'
|
||||
write_category_list(site, dir, site.categories.keys.sort)
|
||||
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.static_files << index
|
||||
end
|
||||
|
||||
def write_category_list(site, dir, categories)
|
||||
index = CategoryList.new(site, site.source, dir, categories)
|
||||
index.render(site.layouts, site.site_payload)
|
||||
index.write(site.dest)
|
||||
site.static_files << index
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user