aboutsummaryrefslogtreecommitdiff
path: root/themes/classic/_plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-06-19 15:14:01 -0400
committerBrandon Mathis <brandon@imathis.com>2011-06-19 15:14:01 -0400
commitf77db80077d739077becc1618b87818ea42f145c (patch)
treee12f94b6badb067597bf76b1dd383a2c370b82c4 /themes/classic/_plugins
parent105ba1434314e06f6cce39e17aedd1f0d66a92d6 (diff)
downloadmy_new_personal_website-f77db80077d739077becc1618b87818ea42f145c.tar.xz
my_new_personal_website-f77db80077d739077becc1618b87818ea42f145c.zip
1. Switched back to Rdiscount
2. Improved Blockquote comment header 3. Added Include File and Pullquote plugins 4. Improved blog typography 5. Simplified "Read more" link
Diffstat (limited to '')
-rw-r--r--themes/classic/_plugins/blockquote.rb24
-rw-r--r--themes/classic/_plugins/custom_filters.rb16
-rw-r--r--themes/classic/_plugins/include_file.rb31
-rw-r--r--themes/classic/_plugins/pullquote.rb42
4 files changed, 95 insertions, 18 deletions
diff --git a/themes/classic/_plugins/blockquote.rb b/themes/classic/_plugins/blockquote.rb
index 8048f476..094e4bc3 100644
--- a/themes/classic/_plugins/blockquote.rb
+++ b/themes/classic/_plugins/blockquote.rb
@@ -2,21 +2,21 @@
# Author: Brandon Mathis
# Based on the work of: Josediaz Gonzalez - https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/blockquote.rb
#
+# Outputs a string with a given attribution as a quote
+#
+# {% blockquote Bobby Willis http://google.com/blah the search for bobby's mom %}
+# Wheeee!
+# {% endblockquote %}
+# ...
+# <blockquote>
+# <p>Wheeee!</p>
+# <footer>
+# <strong>John Paul Jones</strong><cite><a href="http://google.com/blah">The Search For Bobby's Mom</a>
+# </blockquote>
+#
require './_plugins/titlecase.rb'
module Jekyll
- # Outputs a string with a given attribution as a quote
- #
- # {% blockquote Bobby Willis http://google.com/blah the search for bobby's mom %}
- # Wheeee!
- # {% endblockquote %}
- # ...
- # <blockquote>
- # <p>Wheeee!</p>
- # <footer>
- # <strong>John Paul Jones</strong><cite><a href="http://google.com/blah">The Search For Bobby's Mom</a>
- # </blockquote>
- #
class Blockquote < Liquid::Block
FullCiteWithTitle = /([\w\s]+)(https?:\/\/)(\S+\s)([\w\s]+)/i
FullCite = /([\w\s]+)(https?:\/\/)(\S+)/i
diff --git a/themes/classic/_plugins/custom_filters.rb b/themes/classic/_plugins/custom_filters.rb
index 158586af..0d24d720 100644
--- a/themes/classic/_plugins/custom_filters.rb
+++ b/themes/classic/_plugins/custom_filters.rb
@@ -1,11 +1,16 @@
#custom filters for Octopress
module OctopressFilters
- def exerpt(input, url, url_text="Reade more&hellip;", permalink_text=false)
+ def auto_exerpt(input, url, url_text="Read more &hellip;")
if input.index(/<!--\s?more\s?-->/i)
- input.split(/<!--\s?more\s?-->/i)[0] + "<p><a href='#{url}'>#{url_text}</a></p>"
- elsif permalink_text
- input + "<p><a href='#{url}'>#{permalink_text}</a></p>"
+ input.split(/<!--\s?more\s?-->/i)[0] + "<p><a rel='full-article' href='#{url}'>#{url_text}</a></p>"
+ else
+ input
+ end
+ end
+ def exerpt(input)
+ if input.index(/<!--\s*more\s*-->/i)
+ input.split(/<!--\s*more\s*-->/i)[0]
else
input
end
@@ -35,7 +40,7 @@ module OctopressFilters
end
def ordinalize(date)
date = datetime(date)
- "#{date.strftime('%B')} #{ordinal(date.strftime('%e').to_i)}, #{date.strftime('%Y')}"
+ "#{date.strftime('%b')} #{ordinal(date.strftime('%e').to_i)}, #{date.strftime('%Y')}"
end
def ordinal(number)
if (11..13).include?(number.to_i % 100)
@@ -56,4 +61,3 @@ module OctopressFilters
end
end
Liquid::Template.register_filter OctopressFilters
-
diff --git a/themes/classic/_plugins/include_file.rb b/themes/classic/_plugins/include_file.rb
new file mode 100644
index 00000000..3862228b
--- /dev/null
+++ b/themes/classic/_plugins/include_file.rb
@@ -0,0 +1,31 @@
+require 'pathname'
+
+module Jekyll
+
+ class IncludePartialTag < Liquid::Tag
+ def initialize(tag_name, file, tokens)
+ super
+ @file = file.strip
+ end
+
+ def render(context)
+ file_dir = (context.registers[:site].source || 'source')
+ file_path = Pathname.new(file_dir).expand_path
+ file = file_path + @file
+
+ unless file.file?
+ return "File #{file} could not be found"
+ end
+
+ Dir.chdir(file_path) do
+ partial = Liquid::Template.parse(file.read)
+ context.stack do
+ partial.render(context)
+ end
+ end
+ end
+ end
+end
+
+Liquid::Template.register_tag('include_partial', Jekyll::IncludePartialTag)
+
diff --git a/themes/classic/_plugins/pullquote.rb b/themes/classic/_plugins/pullquote.rb
new file mode 100644
index 00000000..2b8544ab
--- /dev/null
+++ b/themes/classic/_plugins/pullquote.rb
@@ -0,0 +1,42 @@
+#
+# Author: Brandon Mathis
+# Based on the sematic pullquote technique by Maykel Loomans at http://miekd.com/articles/pull-quotes-with-html5-and-css/
+#
+# Outputs a span with a data-pullquote attribute set from the marked pullquote. Example:
+#
+# {% pullquote %}
+# When writing longform posts, I find it helpful to include pullquotes, which help those scanning a post discern whether or not a post is helpful.
+# It is important to note, {" pullquotes are merely visual in presentation and should not appear twice in the text. "} That is why it is prefered
+# to use a CSS only technique for styling pullquotes.
+# {% endpullquote %}
+# ...will output...
+# <p>
+# <span data-pullquote="pullquotes are merely visual in presentation and should not appear twice in the text.">
+# When writing longform posts, I find it helpful to include pullquotes, which help those scanning a post discern whether or not a post is helpful.
+# It is important to note, pullquotes are merely visual in presentation and should not appear twice in the text. This is why a CSS only approach # for styling pullquotes is prefered.
+# </span>
+# </p>
+#
+
+module Jekyll
+
+ class PullquoteTag < Liquid::Block
+ PullQuoteMarkup = /\{(.+)\}/i
+
+ def initialize(tag_name, markup, tokens)
+ super
+ end
+
+ def render(context)
+ output = super
+ if output.join =~ /\{"\s*(.+)\s*"\}/
+ @quote = $1
+ "<span class='has-pullquote' data-pullquote='#{@quote}'>#{output.join.gsub(/\{"\s*|\s*"\}/, '')}</span>"
+ else
+ return "Surround your pullquote like this {! text to be quoted !}"
+ end
+ end
+ end
+end
+
+Liquid::Template.register_tag('pullquote', Jekyll::PullquoteTag)