From 913fa105c4a6793e6522ca45b85d8f06c803c6b9 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sat, 11 Jun 2011 15:58:53 -0400 Subject: 1. Moved _plugins into themes/classic/_plugins I think it's probably better to ship plugins with themes to make it easier to update them. 2. Improved 'install' rake task and made nicer output --- themes/classic/_plugins/blockquote.rb | 109 ++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 themes/classic/_plugins/blockquote.rb (limited to 'themes/classic/_plugins/blockquote.rb') diff --git a/themes/classic/_plugins/blockquote.rb b/themes/classic/_plugins/blockquote.rb new file mode 100644 index 00000000..7a885175 --- /dev/null +++ b/themes/classic/_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