lib/ext.rb in no-style-please2-plugins-0.4.1 vs lib/ext.rb in no-style-please2-plugins-0.4.2

- old
+ new

@@ -45,10 +45,41 @@ end return "![](#{link})" end end + class ImgLink < Liquid::Tag + + + def initialize(tag_name, text, tokens) + arr = text.strip.split(' ',2) + if arr.count == 2 + @img_name = arr[1] + @title = arr[0] + else + @img_name = arr[0] + @title = "img_link" + end + end + + def render(context) + path = context['page']['path'] + + + dirPath0 = path[0...(path.length - 3)] + pathComponent = dirPath0.split("/") + dirPath = pathComponent[-1] + + base = $g_config['baseurl'] + link = "/pics/#{dirPath}/#{@img_name}" + if base && base.length + link = "#{base}/pics/#{dirPath}/#{@img_name}" + end + return "[#{@title}](#{link})" + end + end + $g_title_link ||= {} LOADINGFLG = :LOADINGFLG class PostLink < Liquid::Tag @@ -76,11 +107,10 @@ end end end end - class IncludeCode < Liquid::Tag @filecontent = "" def initialize(tag_name, text, tokens) @@ -115,9 +145,12 @@ Liquid::Template.register_tag('asset_img', Jekyll::AssetImg) Liquid::Template.register_tag('include_code', Jekyll::IncludeCode) Liquid::Template.register_tag('post_link', Jekyll::PostLink) + Liquid::Template.register_tag('img_link', Jekyll::ImgLink) + + module Reading class Generator < Jekyll::Generator \ No newline at end of file