jekyll-galleries 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ChangeLog +7 -0
- data/README.rdoc +61 -0
- data/Rakefile +0 -0
- data/lib/jekyll/galleries.rb +90 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6978dd5f6d6d477aba217497f611471184d9647c
|
4
|
+
data.tar.gz: 548abaae61e0141bf5584f5465e6a1d956134431
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: deb0e5551b4a08812ba41011ab1a0f05c87745ec6c482b12e48991777147213f09f7761ec1dd8c4311b9584f9b1ef25d93e655956ce4c43d2ad5165fc1f7fb70
|
7
|
+
data.tar.gz: ef1c7537800e331f9a306cec5dcaf1da560c543616d35c735ed3e7aad22600b350768984805e9dfea2df6b11b2537934cd8b8afec160313b1116647758e1457f
|
data/ChangeLog
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= jekyll-galleries
|
2
|
+
|
3
|
+
By allenlsy <mailto:cafe@allenlsy>
|
4
|
+
|
5
|
+
Jekyll-galleries is a Jekyll plugin used for generating photo galleries from image folders.
|
6
|
+
|
7
|
+
<tt>_config.yml</tt>:
|
8
|
+
|
9
|
+
gallery_dir: galleries
|
10
|
+
gallery_layout: gallery
|
11
|
+
|
12
|
+
Sample layout for gallery index, which you can make a <tt>galleries.html</tt> in Jekyll root directory:
|
13
|
+
|
14
|
+
{% for gallery in site.data['galleries'] %}
|
15
|
+
<p>
|
16
|
+
<a href="{{ gallery.url }}">{{ gallery.name }}</a>
|
17
|
+
<span>{{ gallery.date }}</span>
|
18
|
+
</p>
|
19
|
+
{% endfor %}
|
20
|
+
|
21
|
+
Sample layout for one gallery page, which normally you will put it as <tt>_layouts/gallery.html</tt>:
|
22
|
+
|
23
|
+
---
|
24
|
+
layout: base
|
25
|
+
---
|
26
|
+
{% for photo_url in page.photos %}
|
27
|
+
<p>
|
28
|
+
<img src="{{ photo_url }}" />
|
29
|
+
</p>
|
30
|
+
{% endfor %}
|
31
|
+
|
32
|
+
== Links
|
33
|
+
|
34
|
+
<b></b>
|
35
|
+
Source code:: <http://github.com/allenlsy/jekyll-galleries>
|
36
|
+
RubyGem:: <http://rubygems.org/gems/jekyll-galleries>
|
37
|
+
|
38
|
+
== License
|
39
|
+
|
40
|
+
=== The MIT License
|
41
|
+
|
42
|
+
Copyright (c) 2010-2012 University of Cologne,
|
43
|
+
Albertus-Magnus-Platz, 50923 Cologne, Germany
|
44
|
+
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
46
|
+
of this software and associated documentation files (the "Software"), to deal
|
47
|
+
in the Software without restriction, including without limitation the rights
|
48
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
49
|
+
copies of the Software, and to permit persons to whom the Software is
|
50
|
+
furnished to do so, subject to the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be included in
|
53
|
+
all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
56
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
57
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
58
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
59
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
60
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
61
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class GalleryGenerator < Generator
|
3
|
+
attr_accessor :site, :gallery_dir, :gallery_layout
|
4
|
+
class << self; attr_accessor :site; end
|
5
|
+
|
6
|
+
def generate(site)
|
7
|
+
self.class.site = self.site = site
|
8
|
+
self.gallery_dir = site.config['gallery_dir'] || 'galleries'
|
9
|
+
self.gallery_layout = site.config['gallery_layout'] || 'gallery'
|
10
|
+
|
11
|
+
# array of GalleryPage objects
|
12
|
+
site.data['galleries'] = []
|
13
|
+
gallery_dirs = Dir["#{site.source}/#{gallery_dir}/*/"].select { |e| File.directory? e }
|
14
|
+
gallery_dirs.reverse! # sort by date desc
|
15
|
+
gallery_dirs.each do |dir|
|
16
|
+
generate_gallery_page(dir)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def generate_gallery_page(gallery_dir)
|
22
|
+
data = { 'layout' => gallery_layout }
|
23
|
+
|
24
|
+
page = GalleryPage.new(site, site.source, self.gallery_dir, gallery_dir, data)
|
25
|
+
site.pages << page
|
26
|
+
|
27
|
+
site.data['galleries'] << page
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class GalleryPage < Page
|
33
|
+
# Valid post name regex.
|
34
|
+
MATCHER = /^(\d+-\d+-\d+)-(.*)$/
|
35
|
+
|
36
|
+
attr_accessor :site, :url, :name, :slug
|
37
|
+
|
38
|
+
def initialize(site, base, gen_dir, dir, data={})
|
39
|
+
self.content = data.delete('content') || ''
|
40
|
+
self.data = data
|
41
|
+
|
42
|
+
super(site, base, gen_dir, File.basename(dir) )
|
43
|
+
|
44
|
+
# url, photos
|
45
|
+
self.url = "/#{gen_dir}/#{self.data['slug']}.html"
|
46
|
+
self.data['url'] = URI.escape self.url
|
47
|
+
self.data['photo_urls'] = Dir["#{base}/#{gen_dir}/#{self.name}/*"].map { |e| URI.escape("/#{gen_dir}/#{self.name}/#{File.basename e}") }
|
48
|
+
end
|
49
|
+
|
50
|
+
def read_yaml(*)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Extract information from the post filename.
|
54
|
+
#
|
55
|
+
# name - The String filename of the post file.
|
56
|
+
#
|
57
|
+
# Returns nothing.
|
58
|
+
def process(name)
|
59
|
+
m, date, name = *name.match(MATCHER)
|
60
|
+
|
61
|
+
# self.data['date'] = Time.parse(date)
|
62
|
+
self.data['date'] = date
|
63
|
+
self.data['name'] = name
|
64
|
+
self.data['slug'] = name
|
65
|
+
rescue ArgumentError
|
66
|
+
raise FatalException.new("Gallery #{name} does not have a valid date.")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class YamlToLiquid < Liquid::Tag
|
71
|
+
def initialize(tag_name, arg, tokens)
|
72
|
+
super
|
73
|
+
|
74
|
+
if arg.length == 0
|
75
|
+
raise 'Please enter a yaml file path'
|
76
|
+
else
|
77
|
+
@yml_path = arg
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def render(context)
|
82
|
+
|
83
|
+
yml = YAML::load(File.read(@yml_path))
|
84
|
+
context.registers[:page]['yml'] = yml
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Liquid::Template.register_tag('yaml_to_liquid', Jekyll::YamlToLiquid)
|
90
|
+
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-galleries
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- allenlsy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Jekyll plugin to automatically generate photo gallery (album) from image
|
14
|
+
folder.
|
15
|
+
email: cafe@allenlsy.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/jekyll/galleries.rb
|
21
|
+
- ChangeLog
|
22
|
+
- README.rdoc
|
23
|
+
- Rakefile
|
24
|
+
homepage: http://github.com/allenlsy/jekyll-galleries
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options:
|
30
|
+
- --charset
|
31
|
+
- UTF-8
|
32
|
+
- --line-numbers
|
33
|
+
- --all
|
34
|
+
- --title
|
35
|
+
- jekyll-galleries Application documentation (v0.7.0)
|
36
|
+
- --main
|
37
|
+
- ChangeLog
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 2.1.11
|
53
|
+
signing_key:
|
54
|
+
specification_version: 4
|
55
|
+
summary: Jekyll plugin to automatically generate photo gallery (album) from image
|
56
|
+
folder.
|
57
|
+
test_files: []
|
58
|
+
has_rdoc:
|