diff options
Diffstat (limited to '')
-rw-r--r-- | plugins/backtick_code_block.rb | 2 | ||||
-rw-r--r-- | plugins/blockquote.rb | 13 | ||||
-rw-r--r-- | plugins/category_generator.rb | 32 | ||||
-rw-r--r-- | plugins/code_block.rb | 8 | ||||
-rw-r--r-- | plugins/date.rb | 2 | ||||
-rw-r--r-- | plugins/gist_tag.rb | 7 | ||||
-rw-r--r-- | plugins/jsfiddle.rb | 2 | ||||
-rw-r--r-- | plugins/octopress_filters.rb | 4 | ||||
-rw-r--r-- | plugins/preview_unpublished.rb | 2 | ||||
-rw-r--r-- | plugins/sitemap_generator.rb | 6 | ||||
-rw-r--r-- | plugins/video_tag.rb | 25 |
11 files changed, 66 insertions, 37 deletions
diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb index 40e7900b..8e2c1141 100644 --- a/plugins/backtick_code_block.rb +++ b/plugins/backtick_code_block.rb @@ -2,7 +2,7 @@ require './plugins/pygments_code' module BacktickCodeBlock include HighlightCode - AllOptions = /([^\s]+)\s+(.+?)(https?:\/\/\S+)\s*(.+)?/i + AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i LangCaption = /([^\s]+)\s*(.+)?/i def render_code_block(input) @options = nil diff --git a/plugins/blockquote.rb b/plugins/blockquote.rb index 62e7d143..ebdc0e89 100644 --- a/plugins/blockquote.rb +++ b/plugins/blockquote.rb @@ -21,6 +21,7 @@ module Jekyll class Blockquote < Liquid::Block FullCiteWithTitle = /(\S.*)\s+(https?:\/\/)(\S+)\s+(.+)/i FullCite = /(\S.*)\s+(https?:\/\/)(\S+)/i + AuthorTitle = /([^,]+),([^,]+)/ Author = /(.+)/ def initialize(tag_name, markup, tokens) @@ -30,17 +31,15 @@ module Jekyll if markup =~ FullCiteWithTitle @by = $1 @source = $2 + $3 - @title = $4.titlecase + @title = $4.titlecase.strip elsif markup =~ FullCite @by = $1 @source = $2 + $3 + elsif markup =~ AuthorTitle + @by = $1 + @title = $2.titlecase.strip elsif markup =~ Author - if $1 =~ /([^,]+),([^,]+)/ - @by = $1 - @title = $2.titlecase - else - @by = $1 - end + @by = $1 end super end diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb index bb5fd329..a49c4296 100644 --- a/plugins/category_generator.rb +++ b/plugins/category_generator.rb @@ -19,6 +19,8 @@ # - category_title_prefix: The string used before the category name in the page title (default is # 'Category: '). +require 'stringex' + module Jekyll # The CategoryIndex class creates a single category page for the specified category. @@ -106,12 +108,22 @@ module Jekyll if self.layouts.key? 'category_index' dir = self.config['category_dir'] || 'categories' self.categories.keys.each do |category| - self.write_category_index(File.join(dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase), category) + self.write_category_index(File.join(dir, category.to_url), category) end # Throw an exception if the layout couldn't be found. else - throw "No 'category_index' layout found." + raise <<-ERR + + +=============================================== + Error for category_generator.rb plugin +----------------------------------------------- + No 'category_index.hmtl' in source/_layouts/ + Perhaps you haven't installed a theme yet. +=============================================== + +ERR end end @@ -141,10 +153,7 @@ module Jekyll # Returns string # def category_links(categories) - dir = @context.registers[:site].config['category_dir'] - categories = categories.sort!.map do |item| - "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>" - end + categories = categories.sort!.map { |c| category_link c } case categories.length when 0 @@ -156,6 +165,17 @@ module Jekyll end end + # Outputs a single category as an <a> link. + # + # +category+ is a category string to format as an <a> link + # + # Returns string + # + def category_link(category) + dir = @context.registers[:site].config['category_dir'] + "<a class='category' href='/#{dir}/#{category.to_url}/'>#{category}</a>" + end + # Outputs the post.date as formatted html, with hooks for CSS styling. # # +date+ is the date object to format as HTML. diff --git a/plugins/code_block.rb b/plugins/code_block.rb index 44e34945..660f73d7 100644 --- a/plugins/code_block.rb +++ b/plugins/code_block.rb @@ -49,8 +49,7 @@ module Jekyll class CodeBlock < Liquid::Block include HighlightCode include TemplateWrapper - CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)\s+(.+)/i - CaptionUrl = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)/i + CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i Caption = /(\S[\S\s]*)/ def initialize(tag_name, markup, tokens) @title = nil @@ -63,10 +62,7 @@ module Jekyll end if markup =~ CaptionUrlTitle @file = $1 - @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>" - elsif markup =~ CaptionUrl - @file = $1 - @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>link</a></figcaption>" + @caption = "<figcaption><span>#{$1}</span><a href='#{$2}'>#{$3 || 'link'}</a></figcaption>" elsif markup =~ Caption @file = $1 @caption = "<figcaption><span>#{$1}</span></figcaption>\n" diff --git a/plugins/date.rb b/plugins/date.rb index b864f3e9..49fb79a3 100644 --- a/plugins/date.rb +++ b/plugins/date.rb @@ -95,4 +95,4 @@ module Jekyll self.data['updated_formatted'] = format_date(self.data['updated'], date_format) if self.data.has_key?('updated') end end -end
\ No newline at end of file +end diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb index 74dd3b37..2549ea7a 100644 --- a/plugins/gist_tag.rb +++ b/plugins/gist_tag.rb @@ -40,7 +40,9 @@ module Jekyll end def script_url_for(gist_id, filename) - "https://gist.github.com/#{gist_id}.js?file=#{filename}" + url = "https://gist.github.com/#{gist_id}.js" + url = "#{url}?file=#{filename}" unless filename.nil? or filename.empty? + url end def get_gist_url_for(gist, file) @@ -82,6 +84,9 @@ module Jekyll https.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new raw_uri.request_uri data = https.request request + if data.code.to_i != 200 + raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}" + end data = data.body cache gist, file, data unless @cache_disabled data diff --git a/plugins/jsfiddle.rb b/plugins/jsfiddle.rb index 3ae173eb..a80becb3 100644 --- a/plugins/jsfiddle.rb +++ b/plugins/jsfiddle.rb @@ -37,4 +37,4 @@ module Jekyll end end -Liquid::Template.register_tag('jsfiddle', Jekyll::JsFiddle)
\ No newline at end of file +Liquid::Template.register_tag('jsfiddle', Jekyll::JsFiddle) diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index 2ba93e9e..091f75aa 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -24,12 +24,12 @@ module Jekyll class ContentFilters < PostFilter include OctopressFilters def pre_render(post) - if post.ext.match('html|textile|markdown|haml|slim|xml') + if post.ext.match('html|textile|markdown|md|haml|slim|xml') post.content = pre_filter(post.content) end end def post_render(post) - if post.ext.match('html|textile|markdown|haml|slim|xml') + if post.ext.match('html|textile|markdown|md|haml|slim|xml') post.content = post_filter(post.content) end end diff --git a/plugins/preview_unpublished.rb b/plugins/preview_unpublished.rb index 321ffd6f..28cbdfe7 100644 --- a/plugins/preview_unpublished.rb +++ b/plugins/preview_unpublished.rb @@ -45,4 +45,4 @@ module Jekyll self.posts = self.posts[-limit_posts, limit_posts] if limit_posts end end -end
\ No newline at end of file +end diff --git a/plugins/sitemap_generator.rb b/plugins/sitemap_generator.rb index b63e9423..a08590bf 100644 --- a/plugins/sitemap_generator.rb +++ b/plugins/sitemap_generator.rb @@ -1,6 +1,6 @@ # Sitemap.xml Generator is a Jekyll plugin that generates a sitemap.xml file by # traversing all of the available posts and pages. -# +# # How To Use: # 1) Copy source file into your _plugins folder within your Jekyll project. # 2) Change modify the url variable in _config.yml to reflect your domain name. @@ -28,12 +28,12 @@ # system modified date of the page or post, system modified date of # included layout, system modified date of included layout within that # layout, ... -# +# # Author: Michael Levin # Site: http://www.kinnetica.com # Distributed Under A Creative Commons License # - http://creativecommons.org/licenses/by/3.0/ -# +# # Modified for Octopress by John W. Long # require 'rexml/document' diff --git a/plugins/video_tag.rb b/plugins/video_tag.rb index 6b93be82..c6e67b77 100644 --- a/plugins/video_tag.rb +++ b/plugins/video_tag.rb @@ -22,22 +22,31 @@ module Jekyll @width = '' def initialize(tag_name, markup, tokens) - if markup =~ /((https?:\/\/|\/)(\S+))(\s+(\d+)\s(\d+))?(\s+(https?:\/\/|\/)(\S+))?/i - @video = $1 - @width = $5 - @height = $6 - @poster = $7 + if markup =~ /(https?:\S+)(\s+(https?:\S+))?(\s+(https?:\S+))?(\s+(\d+)\s(\d+))?(\s+(https?:\S+))?/i + @video = [$1, $3, $5].compact + @width = $7 + @height = $8 + @poster = $10 end super end def render(context) output = super - if @video + type = { + 'mp4' => "type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'", + 'ogv' => "type='video/ogg; codecs=theora, vorbis'", + 'webm' => "type='video/webm; codecs=vp8, vorbis'" + } + if @video.size > 0 video = "<video width='#{@width}' height='#{@height}' preload='none' controls poster='#{@poster}'>" - video += "<source src='#{@video}' type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'/></video>" + @video.each do |v| + t = v.match(/([^\.]+)$/)[1] + video += "<source src='#{v}' #{type[t]}>" + end + video += "</video>" else - "Error processing input, expected syntax: {% video url/to/video [width height] [url/to/poster] %}" + "Error processing input, expected syntax: {% video url/to/video [url/to/video] [url/to/video] [width height] [url/to/poster] %}" end end end |