aboutsummaryrefslogtreecommitdiff
path: root/_plugins/blockquote.rb
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-05-30 00:30:16 -0400
committerBrandon Mathis <brandon@imathis.com>2011-05-30 00:30:16 -0400
commit8698a276f937cb1cd6f67f7f213e2ea438500d7e (patch)
tree3963ed8f9750cd565087ce54fe8de38d9f5c606d /_plugins/blockquote.rb
parentc7d5365f81552cae16bbb91696ca3e67b4a0a2e9 (diff)
downloadmy_new_personal_website-8698a276f937cb1cd6f67f7f213e2ea438500d7e.tar.xz
my_new_personal_website-8698a276f937cb1cd6f67f7f213e2ea438500d7e.zip
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.
Diffstat (limited to '_plugins/blockquote.rb')
-rw-r--r--_plugins/blockquote.rb109
1 files changed, 109 insertions, 0 deletions
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 %}
+ # ...
+ # <blockquote>
+ # Monkeys!
+ # <br />
+ # John Paul Jones
+ # </blockquote>
+ #
+ 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?
+ '<blockquote><p>' + output.join + '</p></blockquote>'
+ elsif !@title.nil?
+ '<blockquote><p>' + output.join + '</p></blockquote>' + '<p><cite><strong>' + @by + '</strong>' + '<a class="source" href="' + @source + '">' + @title + '</a></cite></p>'
+ elsif !@source.nil?
+ '<blockquote><p>' + output.join + '</p></blockquote>' + '<p><cite><strong>' + @by + '</strong>' + '<a class="source" href="' + @source + '">source</a></cite></p>'
+ else
+ '<blockquote><p>' + output.join + '</p></blockquote>' + '<p><cite><strong>' + @by + '</strong></cite></p>'
+ end
+ end
+ end
+
+ # Outputs a string with a given attribution as a pullquote
+ #
+ # {% blockquote John Paul Jones %}
+ # Monkeys!
+ # {% endblockquote %}
+ # ...
+ # <blockquote class="pullquote">
+ # Monkeys!
+ # <br />
+ # John Paul Jones
+ # </blockquote>
+ #
+ 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?
+ '<blockquote class="pullquote"><p>' + output.join + '</p></blockquote>'
+ elsif @title
+ '<blockquote class="pullquote"><p>' + output.join + '</p></blockquote>' + '<p><cite><strong>' + @by + '</strong>' + ' <a class="source" href="' + @source + '">' + @title + '</a></cite></p>'
+ elsif @source
+ '<blockquote class="pullquote"><p>' + output.join + '</p></blockquote>' + '<p><cite><strong>' + @by + '</strong>' + ' <a class="source" href="' + @source + '">source</a></cite></p>'
+ elsif @by
+ '<blockquote class="pullquote"><p>' + output.join + '</p></blockquote>' + '<p><cite><strong>' + @by + '</strong></cite></p>'
+ end
+ end
+ end
+end
+
+Liquid::Template.register_tag('blockquote', Jekyll::Blockquote)
+Liquid::Template.register_tag('pullquote', Jekyll::Pullquote)
+
+