Skip to content

Commit dd68142

Browse files
committed
Image galleries
1 parent 23ad473 commit dd68142

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+171
-7
lines changed

_plugins/directory_tag.rb

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Title: Dynamic directories for Jekyll
2+
# Author: Tommy Sullivan http://superawesometommy.com, Robert Park http://exolucere.ca
3+
# Description: The directory tag lets you iterate over files at a particular path. If files conform to the standard Jekyll format, YYYY-MM-DD-file-title, then those attributes will be populated on the yielded file object. The `forloop` object maintains [its usual context](http://wiki.shopify.com/UsingLiquid#For_loops).
4+
#
5+
# Syntax:
6+
#
7+
# {% directory path: path/from/source [reverse] [exclude] %}
8+
# {{ file.url }}
9+
# {{ file.name }}
10+
# {{ file.date }}
11+
# {{ file.slug }}
12+
# {{ file.title }}
13+
# {% enddirectory %}
14+
#
15+
# Options:
16+
#
17+
# - `reverse` - Defaults to 'false', ordering files the same way `ls` does: 0-9A-Za-z.
18+
# - `exclude` - Defaults to '.html$', a Regexp of files to skip.
19+
#
20+
# File Attributes:
21+
#
22+
# - `url` - The absolute path to the published file
23+
# - `name` - The basename
24+
# - `date` - The date extracted from the filename, otherwise the file's creation time
25+
# - `slug` - The basename with date and extension removed
26+
# - `title` - The titlecase'd slug
27+
#
28+
29+
module Jekyll
30+
31+
class DirectoryTag < Liquid::Block
32+
include Convertible
33+
34+
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
35+
36+
attr_accessor :content, :data
37+
38+
def initialize(tag_name, markup, tokens)
39+
attributes = {}
40+
41+
# Parse parameters
42+
markup.scan(Liquid::TagAttributes) do |key, value|
43+
attributes[key] = value
44+
end
45+
46+
@path = attributes['path'] || '.'
47+
@exclude = Regexp.new(attributes['exclude'] || '.html$', Regexp::EXTENDED | Regexp::IGNORECASE)
48+
@rev = attributes['reverse'].nil?
49+
50+
super
51+
end
52+
53+
def render(context)
54+
context.registers[:directory] ||= Hash.new(0)
55+
56+
source_dir = context.registers[:site].source
57+
directory_files = File.join(source_dir, @path, "*")
58+
59+
files = Dir.glob(directory_files).reject{|f| f =~ @exclude }
60+
files.sort! {|x,y| @rev ? x <=> y : y <=> x }
61+
62+
length = files.length
63+
result = []
64+
65+
context.stack do
66+
files.each_with_index do |filename, index|
67+
basename = File.basename(filename)
68+
69+
filepath = [@path, basename] - ['.']
70+
path = filepath.join '/'
71+
url = '/' + filepath.join('/')
72+
73+
m, cats, date, slug, ext = *basename.match(MATCHER)
74+
75+
if m
76+
date = Time.parse(date)
77+
ext = ext
78+
slug = slug
79+
else
80+
date = File.ctime(filename)
81+
ext = basename[/\.[a-z]+$/, 0]
82+
slug = basename.sub(ext, '')
83+
end
84+
85+
context['file'] = {
86+
'date' => date,
87+
'name' => basename,
88+
'slug' => slug,
89+
'url' => url
90+
}
91+
92+
context['forloop'] = {
93+
'name' => 'directory',
94+
'length' => length,
95+
'index' => index + 1,
96+
'index0' => index,
97+
'rindex' => length - index,
98+
'rindex0' => length - index - 1,
99+
'first' => (index == 0),
100+
'last' => (index == length - 1)
101+
}
102+
103+
result << render_all(@nodelist, context)
104+
end
105+
end
106+
result
107+
end
108+
109+
end
110+
111+
end
112+
113+
Liquid::Template.register_tag('directory', Jekyll::DirectoryTag)
114+

_posts/2014-06-03-companion-2.0.0.md

+1-1

_posts/2014-06-11-radio-poll.md

+2-2

_posts/2014-06-11-companion-2.0.2.md renamed to _posts/2014-06-12-companion-2.0.2.md

+1-2

assets/images/icons-taranis/ASw28.bmp

1.12 KB
Binary file not shown.

assets/images/icons-taranis/Alpha.bmp

1.12 KB
Binary file not shown.

assets/images/icons-taranis/Alula.bmp

1.12 KB
Binary file not shown.
1.12 KB
Binary file not shown.
1.12 KB
Binary file not shown.
4.13 KB
Binary file not shown.

assets/images/icons-taranis/Axn.bmp

1.12 KB
Binary file not shown.

assets/images/icons-taranis/B-25.bmp

1.12 KB
Binary file not shown.

assets/images/icons-taranis/B-26.bmp

1.12 KB
Binary file not shown.

assets/images/icons-taranis/B25.bmp

1.12 KB
Binary file not shown.

assets/images/icons-taranis/Beast.bmp

1.12 KB
Binary file not shown.
1.12 KB
Binary file not shown.

assets/images/screens-9x/00050.png

353 Bytes

assets/images/screens-9x/00051.png

3.61 KB

assets/images/screens-9x/00052.png

3.39 KB

assets/images/screens-9x/00053.png

425 Bytes
2.28 KB
4.26 KB
1.33 KB
8.07 KB
5.29 KB
3.02 KB
3.36 KB
2.38 KB
2 KB
3.14 KB
2.12 KB
2.42 KB
12.8 KB
7.86 KB
7.23 KB
10.7 KB
21.6 KB
7.91 KB
6.12 KB
12.5 KB

downloads.md

+10-2

icons-taranis.md

+14

screens-9x.md

+15

screens-taranis.md

+14

0 commit comments

Comments
 (0)