diff --git a/_plugins/icon.rb b/_plugins/icon.rb new file mode 100644 index 00000000..dd1d11de --- /dev/null +++ b/_plugins/icon.rb @@ -0,0 +1,71 @@ +## +# The MIT License (MIT) +# +# Copyright (c) 2014 Ryan Morrissey +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# +# Font Awesome Icons Liquid Tag +# Documentation can be found at http://fontawesome.io/ +# +# Example: +# {% icon fa-camera-retro %} +# {% icon fa-camera-retro fa-lg %} +# {% icon fa-spinner fa-spin %} +# {% icon fa-shield fa-rotate-90 %} + +module Jekyll + class FontAwesomeTag < Liquid::Tag + + def render(context) + if tag_contents = determine_arguments(@markup.strip) + icon_class, icon_extra = tag_contents[0], tag_contents[1] + icon_tag(icon_class, icon_extra) + else + raise ArgumentError.new <<-eos +Syntax error in tag 'icon' while parsing the following markup: + + #{@markup} + +Valid syntax: + for icons: {% icon fa-camera-retro %} + for icons with size/spin/rotate: {% icon fa-camera-retro fa-lg %} +eos + end + end + + private + + def determine_arguments(input) + matched = input.match(/\A(\S+) ?(\S+)?\Z/) + [matched[1].to_s.strip, matched[2].to_s.strip] if matched && matched.length >= 3 + end + + def icon_tag(icon_class, icon_extra = nil) + if icon_extra.empty? + "" + else + "" + end + end + end +end + +Liquid::Template.register_tag('icon', Jekyll::FontAwesomeTag) \ No newline at end of file diff --git a/_plugins/image.rb b/_plugins/image.rb new file mode 100644 index 00000000..b111631c --- /dev/null +++ b/_plugins/image.rb @@ -0,0 +1,19 @@ +module Jekyll + module Tags + class ImageTag < Liquid::Block + def initialize(tag_name, src) + super + src.strip! + @src = src + end + + def render(context) + " + + " + end + end + end +end + +Liquid::Template.register_tag('image', Jekyll::Tags::ImageTag) \ No newline at end of file