diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/backtick_code_block.rb | 2 | ||||
-rw-r--r-- | plugins/blockquote.rb | 17 | ||||
-rw-r--r-- | plugins/category_generator.rb | 28 | ||||
-rw-r--r-- | plugins/code_block.rb | 10 | ||||
-rw-r--r-- | plugins/date.rb | 2 | ||||
-rw-r--r-- | plugins/gist_tag.rb | 4 | ||||
-rw-r--r-- | plugins/jsfiddle.rb | 2 | ||||
-rw-r--r-- | plugins/octopress_filters.rb | 8 | ||||
-rw-r--r-- | plugins/preview_unpublished.rb | 2 | ||||
-rw-r--r-- | plugins/pullquote.rb | 6 | ||||
-rw-r--r-- | plugins/sitemap_generator.rb | 6 | ||||
-rw-r--r-- | plugins/video_tag.rb | 25 |
12 files changed, 69 insertions, 43 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 7fb8c261..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,23 +31,21 @@ 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 def render(context) - quote = paragraphize(super.map(&:strip).join) + quote = paragraphize(super) author = "<strong>#{@by.strip}</strong>" if @by if @source url = @source.match(/https?:\/\/(.+)/)[1].split('/') @@ -75,7 +74,7 @@ module Jekyll end def paragraphize(input) - "<p>#{input.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')}</p>" + "<p>#{input.lstrip.rstrip.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')}</p>" end end end diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb index bb5fd329..d4840a8d 100644 --- a/plugins/category_generator.rb +++ b/plugins/category_generator.rb @@ -111,7 +111,17 @@ module Jekyll # 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 +151,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 +163,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.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{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 e175d445..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" @@ -79,7 +75,7 @@ module Jekyll def render(context) output = super - code = super.join + code = super source = "<figure class='code'>" source += @caption if @caption if @filetype 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 ee87fcf7..43e7eb0a 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) 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 a5bb235c..091f75aa 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -24,10 +24,14 @@ module Jekyll class ContentFilters < PostFilter include OctopressFilters def pre_render(post) - post.content = pre_filter(post.content) + if post.ext.match('html|textile|markdown|md|haml|slim|xml') + post.content = pre_filter(post.content) + end end def post_render(post) - post.content = post_filter(post.content) + if post.ext.match('html|textile|markdown|md|haml|slim|xml') + post.content = post_filter(post.content) + end end 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/pullquote.rb b/plugins/pullquote.rb index 2b59bad6..3c65e66e 100644 --- a/plugins/pullquote.rb +++ b/plugins/pullquote.rb @@ -32,11 +32,9 @@ module Jekyll def render(context) output = super - if output.join =~ /\{"\s*(.+)\s*"\}/ - #@quote = $1 + if output =~ /\{"\s*(.+?)\s*"\}/m @quote = RubyPants.new($1).to_html - #@quote = CGI.escape($1) - "<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.join.gsub(/\{"\s*|\s*"\}/, '')}</span>" + "<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.gsub(/\{"\s*|\s*"\}/, '')}</span>" else return "Surround your pullquote like this {\" text to be quoted \"}" 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 |