aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-23 00:23:50 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-23 00:26:00 -0400
commita2bc6f97627d78d42230061125252f074ce4f4cd (patch)
tree9b1fad420abb561f01c45712082d4c4b897f9f96 /plugins
parent8e489ac2daf35f81d4567f959219decd6836b024 (diff)
downloadmy_new_personal_website-a2bc6f97627d78d42230061125252f074ce4f4cd.tar.xz
my_new_personal_website-a2bc6f97627d78d42230061125252f074ce4f4cd.zip
1. Added image tag plugin
2. Removed figure tag plugin 3. Renamed custom_filters to octopress_filters 4. Added styles to support new image tag plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/figure_tag.rb69
-rw-r--r--plugins/image_tag.rb41
-rw-r--r--plugins/octopress_filters.rb (renamed from plugins/custom_filters.rb)0
3 files changed, 41 insertions, 69 deletions
diff --git a/plugins/figure_tag.rb b/plugins/figure_tag.rb
deleted file mode 100644
index 550e677f..00000000
--- a/plugins/figure_tag.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# Title: Simple Image Figure tag for Jekyll
-# Author: Brandon Mathis http://brandonmathis.com
-# Description: Easily output images in <figure> with an optional <figcaption> and class names.
-#
-# Syntax {% figure [class name(s)] url [caption text] %}
-#
-# Example:
-# {% figure left half http://site.com/images/ninja.png Ninja Attack! %}
-#
-# Output:
-# <figure class='left half'><img src="http://site.com/images/ninja.png"><figcaption>Ninja Attack!</figcaption></figure>
-#
-# Example 2 (image with caption)
-# {% figure /images/ninja.png Ninja Attack! %}
-#
-# Output:
-# <figure><img src="/images/ninja.png"><figcaption>Ninja Attack!</figcaption></figure>
-#
-# Example 3 (just an image with classes)
-# {% figure right /images/ninja.png %}
-#
-# Output:
-# <figure><img class="right" src="/images/ninja.png"></figure>
-#
-
-module Jekyll
-
- class FigureImageTag < Liquid::Tag
- ClassImgCaption = /(\S[\S\s]*)\s+(https?:\/\/|\/)(\S+)\s+(.+)/i
- ClassImg = /(\S[\S\s]*)\s+(https?:\/\/|\/)(\S+)/i
- ImgCaption = /^\s*(https?:\/\/|\/)(\S+)\s+(.+)/i
- Img = /^\s*(https?:\/\/|\/)(\S+\s)/i
-
- @img = nil
- @caption = nil
- @class = ''
-
- def initialize(tag_name, markup, tokens)
- if markup =~ ClassImgCaption
- @class = $1
- @img = $2 + $3
- @caption = $4
- elsif markup =~ ClassImg
- @class = $1
- @img = $2 + $3
- elsif markup =~ ImgCaption
- @img = $1 + $2
- @caption = $3
- elsif markup =~ Img
- @img = $1 + $2
- end
- super
- end
-
- def render(context)
- output = super
- if @img
- figure = "<figure class='#{@class}'>"
- figure += "<img src='#{@img}'>"
- figure += "<figcaption>#{@caption}</figcaption>" if @caption
- figure += "</figure>"
- else
- "Error processing input, expected syntax: {% figure [class name(s)] /url/to/image [caption] %}"
- end
- end
- end
-end
-
-Liquid::Template.register_tag('figure', Jekyll::FigureImageTag)
diff --git a/plugins/image_tag.rb b/plugins/image_tag.rb
new file mode 100644
index 00000000..d7c85925
--- /dev/null
+++ b/plugins/image_tag.rb
@@ -0,0 +1,41 @@
+# Title: Simple Image tag for Jekyll
+# Author: Brandon Mathis http://brandonmathis.com
+# Description: Easily output images with optional class names and title/alt attributes
+#
+# Syntax {% image [class name(s)] url [title text] %}
+#
+# Example:
+# {% imaeg left half http://site.com/images/ninja.png Ninja Attack! %}
+#
+# Output:
+# <image class='left' src="http://site.com/images/ninja.png" title="Ninja Attack!" alt="Ninja Attack!">
+#
+
+module Jekyll
+
+ class ImageTag < Liquid::Tag
+ @img = nil
+ @title = nil
+ @class = ''
+
+ def initialize(tag_name, markup, tokens)
+ if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+.+)?/i
+ @class = $1
+ @img = $2 + $3
+ @title = $4
+ end
+ super
+ end
+
+ def render(context)
+ output = super
+ if @img
+ figure = "<img class='#{@class}' src='#{@img}' alt='#{@title}' title='#{@title}'>"
+ else
+ "Error processing input, expected syntax: {% img [class name(s)] /url/to/image [title text] %}"
+ end
+ end
+ end
+end
+
+Liquid::Template.register_tag('img', Jekyll::ImageTag)
diff --git a/plugins/custom_filters.rb b/plugins/octopress_filters.rb
index 5b49363b..5b49363b 100644
--- a/plugins/custom_filters.rb
+++ b/plugins/octopress_filters.rb