From 8698a276f937cb1cd6f67f7f213e2ea438500d7e Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 30 May 2011 00:30:16 -0400 Subject: 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. --- _plugins/blockquote.rb | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 _plugins/blockquote.rb (limited to '_plugins/blockquote.rb') diff --git a/_plugins/blockquote.rb b/_plugins/blockquote.rb new file mode 100644 index 00000000..7a885175 --- /dev/null +++ b/_plugins/blockquote.rb @@ -0,0 +1,109 @@ +# +# Author: Josediaz Gonzalez - https://github.com/josegonzalez +# Source URL: https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/blockquote.rb +# Modified by Brandon Mathis +# +require './_plugins/titlecase.rb' +module Jekyll + + # Outputs a string with a given attribution as a quote + # + # {% blockquote John Paul Jones %} + # Monkeys! + # {% endblockquote %} + # ... + #
+ # Monkeys! + #
+ # John Paul Jones + #
+ # + class Blockquote < Liquid::Block + FullCiteWithTitle = /([\w\s]+)(https?:\/\/)(\S+\s)([\w\s]+)/i + FullCite = /([\w\s]+)(https?:\/\/)(\S+)/i + Author = /([\w\s]+)/ + + def initialize(tag_name, markup, tokens) + @by = nil + @source = nil + @title = nil + if markup =~ FullCiteWithTitle + @by = $1 + @source = $2 + $3 + @title = $4.titlecase + elsif markup =~ FullCite + @by = $1 + @source = $2 + $3 + elsif markup =~ Author + @by = $1 + end + super + end + + def render(context) + output = super + if @by.nil? + '

' + output.join + '

' + elsif !@title.nil? + '

' + output.join + '

' + '

' + @by + '' + '' + @title + '

' + elsif !@source.nil? + '

' + output.join + '

' + '

' + @by + '' + 'source

' + else + '

' + output.join + '

' + '

' + @by + '

' + end + end + end + + # Outputs a string with a given attribution as a pullquote + # + # {% blockquote John Paul Jones %} + # Monkeys! + # {% endblockquote %} + # ... + #
+ # Monkeys! + #
+ # John Paul Jones + #
+ # + class Pullquote < Liquid::Block + FullCiteWithTitle = /([\w\s]+)(http:\/\/|https:\/\/)(\S+)([\w\s]+)/i + FullCite = /([\w\s]+)(http:\/\/|https:\/\/)(\S+)/i + Author = /([\w\s]+)/ + + def initialize(tag_name, markup, tokens) + @by = nil + @source = nil + @title = nil + if markup =~ FullCiteWithTitle + @by = $1 + @source = $2 + $3 + @title = $4 + elsif markup =~ FullCite + @by = $1 + @source = $2 + $3 + elsif markup =~ Author + @by = $1 + end + super + end + + def render(context) + output = super + if @by.nil? + '

' + output.join + '

' + elsif @title + '

' + output.join + '

' + '

' + @by + '' + ' ' + @title + '

' + elsif @source + '

' + output.join + '

' + '

' + @by + '' + ' source

' + elsif @by + '

' + output.join + '

' + '

' + @by + '

' + end + end + end +end + +Liquid::Template.register_tag('blockquote', Jekyll::Blockquote) +Liquid::Template.register_tag('pullquote', Jekyll::Pullquote) + + -- cgit v1.2.1