diff options
Diffstat (limited to '')
-rw-r--r-- | .themes/classic/source/_includes/post/date.html | 18 | ||||
-rw-r--r-- | .themes/classic/source/_layouts/post.html | 2 | ||||
-rw-r--r-- | .themes/classic/source/atom.xml | 1 | ||||
-rw-r--r-- | .themes/classic/source/robots.txt | 3 | ||||
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | plugins/backtick_code_block.rb | 7 | ||||
-rw-r--r-- | plugins/code_block.rb | 8 | ||||
-rw-r--r-- | plugins/include_code.rb | 6 | ||||
-rw-r--r-- | plugins/octopress_filters.rb | 44 | ||||
-rw-r--r-- | plugins/pygments_code.rb | 6 | ||||
-rw-r--r-- | plugins/raw.rb | 4 |
11 files changed, 46 insertions, 57 deletions
diff --git a/.themes/classic/source/_includes/post/date.html b/.themes/classic/source/_includes/post/date.html index ecf1ad71..a86953c2 100644 --- a/.themes/classic/source/_includes/post/date.html +++ b/.themes/classic/source/_includes/post/date.html @@ -1,15 +1,5 @@ -{% capture date %}{{ page.date }}{{ post.date }}{% endcapture %} -{% capture date_formatted %}{{ page.date_formatted }}{{ post.date_formatted }}{% endcapture %} -{% capture has_date %}{{ date | size }}{% endcapture %} +{% if page.date %}{% capture time %}{{ page.date_time_html }}{% endcapture %}{% endif %} +{% if post.date %}{% capture time %}{{ post.date_time_html }}{% endcapture %}{% endif %} -{% capture updated %}{{ page.updated }}{{ post.updated }}{% endcapture %} -{% capture updated_formatted %}{{ page.updated_formatted }}{{ post.updated_formatted }}{% endcapture %} -{% capture was_updated %}{{ updated | size }}{% endcapture %} - -{% if has_date != '0' %} - {% capture time %}<time datetime="{{ date | datetime | date_to_xmlschema }}" pubdate{% if updated %} data-updated="true"{% endif %}>{{ date_formatted }}</time>{% endcapture %} -{% endif %} - -{% if was_updated != '0' %} - {% capture updated %}<time datetime="{{ updated | datetime | date_to_xmlschema }}" class="updated">Updated {{ updated_formatted }}</time>{% endcapture %} -{% else %}{% assign updated = false %}{% endif %}
\ No newline at end of file +{% if page.updated %}{% capture updated %}{{ page.date_time_updated_html }}{% endcapture %}{% endif %} +{% if post.updated %}{% capture updated %}{{ post.date_time_updated_html }}{% endcapture %}{% endif %} diff --git a/.themes/classic/source/_layouts/post.html b/.themes/classic/source/_layouts/post.html index 40911680..b450681b 100644 --- a/.themes/classic/source/_layouts/post.html +++ b/.themes/classic/source/_layouts/post.html @@ -9,7 +9,7 @@ single: true <footer> <p class="meta"> {% include post/author.html %} - {% include post/date.html %}{% if updated %}{{ updated }}{% else %}{{ time }}{% endif %} + {% include post/date.html %}{{ time }}{% if updated %} {{ updated }}{% endif %} {% include post/categories.html %} </p> {% unless page.sharing == false %} diff --git a/.themes/classic/source/atom.xml b/.themes/classic/source/atom.xml index d4a44278..c39831f5 100644 --- a/.themes/classic/source/atom.xml +++ b/.themes/classic/source/atom.xml @@ -1,5 +1,4 @@ --- -layout: nil --- <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> diff --git a/.themes/classic/source/robots.txt b/.themes/classic/source/robots.txt index b18d5dcb..75ddfea2 100644 --- a/.themes/classic/source/robots.txt +++ b/.themes/classic/source/robots.txt @@ -1,7 +1,6 @@ --- -layout: nil --- User-agent: * Disallow: -Sitemap: {{ site.url }}/sitemap.xml
\ No newline at end of file +Sitemap: {{ site.url }}/sitemap.xml @@ -3,8 +3,8 @@ source "https://rubygems.org" group :development do gem 'rake', '~> 10.0' gem 'jekyll', '~> 2.0' - gem 'jekyll-page-hooks', '~> 1.2' - gem 'jekyll-date-format', '~> 1.0' + gem 'octopress-hooks', '~> 2.2' + gem 'octopress-date-format', '~> 2.0' gem 'jekyll-sitemap' gem 'rdiscount', '~> 2.0' gem 'RedCloth', '~> 4.2.9' diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb index 8e2c1141..ae4a0472 100644 --- a/plugins/backtick_code_block.rb +++ b/plugins/backtick_code_block.rb @@ -1,10 +1,9 @@ require './plugins/pygments_code' module BacktickCodeBlock - include HighlightCode AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i LangCaption = /([^\s]+)\s*(.+)?/i - def render_code_block(input) + def self.render_code_block(input) @options = nil @caption = nil @lang = nil @@ -26,7 +25,7 @@ module BacktickCodeBlock str = str.gsub(/^( {4}|\t)/, '') end if @lang.nil? || @lang == 'plain' - code = tableize_code(str.gsub('<','<').gsub('>','>')) + code = HighlightCode::tableize_code(str.gsub('<','<').gsub('>','>')) "<figure class='code'>#{@caption}#{code}</figure>" else if @lang.include? "-raw" @@ -34,7 +33,7 @@ module BacktickCodeBlock raw += str raw += "\n```\n" else - code = highlight(str, @lang) + code = HighlightCode::highlight(str, @lang) "<figure class='code'>#{@caption}#{code}</figure>" end end diff --git a/plugins/code_block.rb b/plugins/code_block.rb index 46620d86..539a3475 100644 --- a/plugins/code_block.rb +++ b/plugins/code_block.rb @@ -47,8 +47,6 @@ require './plugins/raw' module Jekyll class CodeBlock < Liquid::Block - include HighlightCode - include TemplateWrapper CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i Caption = /(\S[\S\s]*)/ def initialize(tag_name, markup, tokens) @@ -79,11 +77,11 @@ module Jekyll source = "<figure class='code'>" source += @caption if @caption if @filetype - source += "#{highlight(code, @filetype)}</figure>" + source += "#{HighlightCode::highlight(code, @filetype)}</figure>" else - source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'<'))}</figure>" + source += "#{HighlightCode::tableize_code(code.lstrip.rstrip.gsub(/</,'<'))}</figure>" end - source = safe_wrap(source) + source = TemplateWrapper::safe_wrap(source) source = context['pygments_prefix'] + source if context['pygments_prefix'] source = source + context['pygments_suffix'] if context['pygments_suffix'] source diff --git a/plugins/include_code.rb b/plugins/include_code.rb index 41f30337..a61d06cf 100644 --- a/plugins/include_code.rb +++ b/plugins/include_code.rb @@ -27,8 +27,6 @@ require 'pathname' module Jekyll class IncludeCodeTag < Liquid::Tag - include HighlightCode - include TemplateWrapper def initialize(tag_name, markup, tokens) @title = nil @file = nil @@ -62,8 +60,8 @@ module Jekyll title = @title ? "#{@title} (#{file.basename})" : file.basename url = "/#{code_dir}/#{@file}" source = "<figure class='code'><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n" - source += "#{highlight(code, @filetype)}</figure>" - safe_wrap(source) + source += "#{HighlightCode::highlight(code, @filetype)}</figure>" + TemplateWrapper::safe_wrap(source) end end end diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index aad5bf9f..bac6768d 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -7,32 +7,38 @@ require './plugins/raw' require 'rubypants' module OctopressFilters - include BacktickCodeBlock - include TemplateWrapper - def pre_filter(input) - input = render_code_block(input) - input.gsub /(<figure.+?>.+?<\/figure>)/m do - safe_wrap($1) + def self.pre_filter(page) + if page.ext.match('html|textile|markdown|md|haml|slim|xml') + input = BacktickCodeBlock::render_code_block(page.content) + page.content = input.gsub /(<figure.+?>.+?<\/figure>)/m do + TemplateWrapper::safe_wrap($1) + end end end - def post_filter(input) - input = unwrap(input) - RubyPants.new(input).to_html + def self.post_filter(page) + if page.ext.match('html|textile|markdown|md|haml|slim|xml') + input = TemplateWrapper::unwrap(page.content) + page.content = RubyPants.new(input).to_html + end end -end -module Jekyll - class ContentFilters < PageHooks - include OctopressFilters + class PageFilters < Octopress::Hooks::Page + def pre_render(page) + OctopressFilters::pre_filter(page) + end + + def post_render(page) + OctopressFilters::post_filter(page) + end + end + + class PostFilters < Octopress::Hooks::Post def pre_render(post) - if post.ext.match('html|textile|markdown|md|haml|slim|xml') - post.content = pre_filter(post.content) - end + OctopressFilters::pre_filter(post) end + def post_render(post) - if post.ext.match('html|textile|markdown|md|haml|slim|xml') - post.content = post_filter(post.content) - end + OctopressFilters::post_filter(post) end end end diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb index 8b851a3b..c0f4de92 100644 --- a/plugins/pygments_code.rb +++ b/plugins/pygments_code.rb @@ -6,7 +6,7 @@ PYGMENTS_CACHE_DIR = File.expand_path('../../.pygments-cache', __FILE__) FileUtils.mkdir_p(PYGMENTS_CACHE_DIR) module HighlightCode - def highlight(str, lang) + def self.highlight(str, lang) lang = 'ruby' if lang == 'ru' lang = 'objc' if lang == 'm' lang = 'perl' if lang == 'pl' @@ -15,7 +15,7 @@ module HighlightCode tableize_code(str, lang) end - def pygments(code, lang) + def self.pygments(code, lang) if defined?(PYGMENTS_CACHE_DIR) path = File.join(PYGMENTS_CACHE_DIR, "#{lang}-#{Digest::MD5.hexdigest(code)}.html") if File.exist?(path) @@ -33,7 +33,7 @@ module HighlightCode end highlighted_code end - def tableize_code (str, lang = '') + def self.tableize_code (str, lang = '') table = '<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers">' code = '' str.lines.each_with_index do |line,index| diff --git a/plugins/raw.rb b/plugins/raw.rb index 4b002625..e97c9459 100644 --- a/plugins/raw.rb +++ b/plugins/raw.rb @@ -3,11 +3,11 @@ # Purpose: This is useful for preventing Markdown and Textile from being too aggressive and incorrectly parsing in-line HTML. module TemplateWrapper # Wrap input with a <div> - def safe_wrap(input) + def self.safe_wrap(input) "<div class='bogus-wrapper'><notextile>#{input}</notextile></div>" end # This must be applied after the - def unwrap(input) + def self.unwrap(input) input.gsub /<div class='bogus-wrapper'><notextile>(.+?)<\/notextile><\/div>/m do $1 end |