From 52435c2e0aae9a5a186ebc5149362c2ee5004ece Mon Sep 17 00:00:00 2001 From: Danny Berger Date: Mon, 31 Mar 2014 01:53:09 -0600 Subject: [PATCH] reusable gallery includes; primitive, dynamic loopdir path support --- _includes/gallery_list.html | 5 +++ _includes/gallery_map.html | 46 +++++++++++++++++++++ _plugins/loopdir.rb | 12 +++++- gallery/2014-london-iceland-trip/index.html | 4 +- gallery/2014-london-iceland-trip/map.html | 6 +++ 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 _includes/gallery_list.html create mode 100644 _includes/gallery_map.html create mode 100644 gallery/2014-london-iceland-trip/map.html diff --git a/_includes/gallery_list.html b/_includes/gallery_list.html new file mode 100644 index 0000000..5a694ef --- /dev/null +++ b/_includes/gallery_list.html @@ -0,0 +1,5 @@ + diff --git a/_includes/gallery_map.html b/_includes/gallery_map.html new file mode 100644 index 0000000..b120944 --- /dev/null +++ b/_includes/gallery_map.html @@ -0,0 +1,46 @@ +
+ + diff --git a/_plugins/loopdir.rb b/_plugins/loopdir.rb index 9211150..efaa9fb 100644 --- a/_plugins/loopdir.rb +++ b/_plugins/loopdir.rb @@ -16,7 +16,12 @@ module Jekyll @attributes['sort'] = 'path'; markup.scan(Liquid::TagAttributes) do | key, value | - @attributes[key] = value + if 'path' == key + # path can be dynamic to support includes + @attributes['path'] = Liquid::Variable.new(value) + else + @attributes[key] = value.gsub /"(.*)"/, '\1' + end end if @attributes['path'].nil? @@ -36,8 +41,10 @@ module Jekyll context.registers[:loopdir] ||= Hash.new(0) items = [] + + path = @attributes['path'].render(context) - Dir.glob(File.join(@attributes['path'], @attributes['match'])).each do |pathname| + Dir.glob(File.join(path, @attributes['match'])).each do |pathname| if @attributes['parse'] item = {} @@ -59,6 +66,7 @@ module Jekyll end item['name'] = File.basename(pathname, @attributes['match'].sub('*', '')) + item['fullname'] = path + '/' + item['name'] item['path'] = pathname items.push item diff --git a/gallery/2014-london-iceland-trip/index.html b/gallery/2014-london-iceland-trip/index.html index 1515762..41e1acd 100644 --- a/gallery/2014-london-iceland-trip/index.html +++ b/gallery/2014-london-iceland-trip/index.html @@ -7,6 +7,4 @@ title : London & Iceland Trip My trip to London and Iceland…

- +{% include gallery_list.html gallery='2014-london-iceland-trip' %} diff --git a/gallery/2014-london-iceland-trip/map.html b/gallery/2014-london-iceland-trip/map.html new file mode 100644 index 0000000..a76b007 --- /dev/null +++ b/gallery/2014-london-iceland-trip/map.html @@ -0,0 +1,6 @@ +--- +layout: post +title: London & Iceland Trip +--- + +{% include gallery_map.html gallery='2014-london-iceland-trip' latitude=59.1116508 longitude=-10.4266682 zoom=4 %}