lib/jekyll-bits.rb in jekyll-bits-0.4.1 vs lib/jekyll-bits.rb in jekyll-bits-0.5
- old
+ new
@@ -1,5 +1,7 @@
+# encoding: utf-8
+#
# (The MIT License)
#
# Copyright (c) 2016 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -18,49 +20,6 @@
# 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.
-require 'liquid'
-
-puts 'jekyll-bits is alive'
-
-# Jekyll module
-module Jekyll
- # All our custom filters
- module JbFilters
- def jb_picture_head(page)
- yaml = page['jb_picture']
- return unless yaml
- src = if yaml.is_a?(Array)
- yaml['src']
- else
- yaml
- end
- "<meta property='og:image' content='#{src}'/>"
- end
-
- def jb_picture_body(page)
- yaml = page['jb_picture']
- return unless yaml
- if yaml.is_a?(Array)
- "<figure class='jb_picture'><a \
-href='#{CGI.escapeElement(yaml['href'])}'>\
-<img alt='#{CGI.escapeElement(yaml['alt'])}' \
-src='#{CGI.escapeElement(yaml['src'])}'/></a></figure>"
- else
- "<figure class='jb_picture'><img \
-alt='front picture' src='#{CGI.escapeElement(yaml)}'/></figure>"
- end
- end
- end
-
- # Jekyll block
- class JbPictureBlock < Liquid::Tag
- def render(context)
- Jekyll::JbFilters.jb_picture_body(context.registers[:page])
- end
- end
-end
-
-Liquid::Template.register_filter(Jekyll::JbFilters)
-Liquid::Template.register_tag('jb_picture_body', Jekyll::JbPictureBlock)
+require 'jekyll-bits/picture'