aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.themes/classic/source/_includes/article.html9
-rw-r--r--_config.yml1
-rw-r--r--plugins/code_block.rb10
-rw-r--r--plugins/include_code.rb11
-rw-r--r--plugins/octopress_filters.rb5
-rw-r--r--plugins/pygments_code.rb4
6 files changed, 28 insertions, 12 deletions
diff --git a/.themes/classic/source/_includes/article.html b/.themes/classic/source/_includes/article.html
index 6b3fb045..b561fbc7 100644
--- a/.themes/classic/source/_includes/article.html
+++ b/.themes/classic/source/_includes/article.html
@@ -12,9 +12,12 @@
{% endunless %}
{% if index %}
<div class="entry-content">{{ content | excerpt }}</div>
- <footer>
- <a rel="full-article" href="{{ root_url }}{{ post.url }}">Read on &rarr;</a>
- </footer>
+ {% capture excerpted %}{{ content | has_excerpt }}{% endcapture %}
+ {% if excerpted == 'true' %}
+ <footer>
+ <a rel="full-article" href="{{ root_url }}{{ post.url }}">{{ site.excerpt_link }}</a>
+ </footer>
+ {% endif %}
{% else %}
<div class="entry-content">{{ content }}</div>
{% endif %}
diff --git a/_config.yml b/_config.yml
index 403f9ba8..00dc8aa4 100644
--- a/_config.yml
+++ b/_config.yml
@@ -32,6 +32,7 @@ pygments: false # default python pygments have been replaced by pygments.rb
paginate: 10 # Posts per page on the blog index
pagination_dir: blog # Directory base for pagination URLs eg. /blog/page/2/
recent_posts: 5 # Posts in the sidebar Recent Posts section
+excerpt_link: "Read on &rarr;" # "Continue reading" link text at the bottom of excerpted articles
# list each of the sidebar modules you want to include, in the order you want them to appear.
# To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'
diff --git a/plugins/code_block.rb b/plugins/code_block.rb
index 55267a36..9c971bf5 100644
--- a/plugins/code_block.rb
+++ b/plugins/code_block.rb
@@ -53,7 +53,12 @@ module Jekyll
def initialize(tag_name, markup, tokens)
@title = nil
@caption = nil
+ @filetype = nil
@highlight = true
+ if markup =~ /\s*lang:(\w+)/i
+ @filetype = $1
+ markup = markup.sub(/lang:\w+/i,'')
+ end
if markup =~ CaptionUrlTitle
@file = $1
@caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>"
@@ -64,7 +69,7 @@ module Jekyll
@file = $1
@caption = "<figcaption><span>#{$1}</span></figcaption>\n"
end
- if @file =~ /\S[\S\s]*\w+\.(\w+)/
+ if @file =~ /\S[\S\s]*\w+\.(\w+)/ && @filetype.nil?
@filetype = $1
end
super
@@ -77,9 +82,6 @@ module Jekyll
source += @caption if @caption
source = context['pygments_prefix'] + source if context['pygments_prefix']
if @filetype
- @filetype = 'objc' if @filetype == 'm'
- @filetype = 'perl' if @filetype == 'pl'
- @filetype = 'yaml' if @filetype == 'yml'
source += " #{highlight(code, @filetype)}</figure></div>"
else
source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'&lt;'))}</figure></div>"
diff --git a/plugins/include_code.rb b/plugins/include_code.rb
index e064fe2c..70d5f138 100644
--- a/plugins/include_code.rb
+++ b/plugins/include_code.rb
@@ -30,6 +30,10 @@ module Jekyll
def initialize(tag_name, markup, tokens)
@title = nil
@file = nil
+ if markup.strip =~ /\s*lang:(\w+)/i
+ @filetype = $1
+ markup = markup.strip.sub(/lang:\w+/i,'')
+ end
if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i
@title = $1 || nil
@file = $3
@@ -52,12 +56,9 @@ module Jekyll
Dir.chdir(code_path) do
code = file.read
- @filetype = file.extname.sub('.','')
- @filetype = 'objc' if @filetype == 'm'
- @filetype = 'perl' if @filetype == 'pl'
- @filetype = 'yaml' if @filetype == 'yml'
+ @filetype = file.extname.sub('.','') if @filetype.nil?
title = @title ? "#{@title} (#{file.basename})" : file.basename
- url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
+ url = "/#{code_dir}/#{@file}"
source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n"
source += " #{highlight(code, @filetype)}</figure></div>"
end
diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb
index 1170f8b6..a63c43ab 100644
--- a/plugins/octopress_filters.rb
+++ b/plugins/octopress_filters.rb
@@ -12,6 +12,11 @@ module OctopressFilters
end
end
+ # Checks for excerpts (helpful for template conditionals)
+ def has_excerpt(input)
+ input =~ /<!--\s*more\s*-->/i ? true : false
+ end
+
# Summary is used on the Archive pages to return the first block of content from a post.
def summary(input)
if input.index(/\n\n/)
diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb
index 1930ec83..67ce8c34 100644
--- a/plugins/pygments_code.rb
+++ b/plugins/pygments_code.rb
@@ -7,6 +7,10 @@ FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
module HighlightCode
def highlight(str, lang)
+ lang = 'ruby' if lang == 'ru'
+ lang = 'objc' if lang == 'm'
+ lang = 'perl' if lang == 'pl'
+ lang = 'yaml' if lang == 'yml'
str = pygments(str, lang).match(/<pre>(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs <div class="highlight">
tableize_code(str, lang)
end