middleman-galley 0.0.1 → 0.0.2
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 +4 -4
- data/.travis.yml +8 -0
- data/Gemfile +2 -0
- data/README.md +8 -1
- data/features/step_definitions/usage_steps.rb +10 -0
- data/features/support/env.rb +3 -0
- data/features/usage.feature +12 -5
- data/lib/middleman/galley/gallery_template.rb +78 -0
- data/lib/middleman/galley/helper.rb +11 -21
- data/lib/middleman/galley/version.rb +1 -1
- data/lib/middleman/galley.rb +23 -0
- data/middleman-galley.gemspec +4 -2
- data/templates/index.erb +5 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10752cd763741094cdbd6a501e81d2ce44e7fb6f
|
4
|
+
data.tar.gz: 728e6ab302b4b9d457298ab3d65a9b2763ff3fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aefcb04fb033bac2a95047eaf4d0877ef04a6e1f839cd368c2bbb65a4e0f322c7cca653fc43aec397532040d8b989a689d36e2c2332f9c7dbb0effab1734641b
|
7
|
+
data.tar.gz: 85208cee122766098e57c876a2b71b21ffe80d74b9b01854c600b1ae61f34fa25502630562d4f2a5a04484066909bac3ea33a45b0c8c02fed84923754b050223
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Middleman::Galley
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/middleman-galley)
|
4
|
+
[](https://travis-ci.org/sowcow/middleman-galley)
|
5
|
+
[](https://gemnasium.com/sowcow/middleman-galley)
|
6
|
+
[](https://codeclimate.com/github/sowcow/middleman-galley)
|
7
|
+
[](https://coveralls.io/r/sowcow/middleman-galley?branch=master)
|
8
|
+
|
3
9
|
TODO: Write a gem description
|
4
10
|
|
5
11
|
## Installation
|
@@ -18,7 +24,8 @@ Or install it yourself as:
|
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
1. https://github.com/sowcow/middleman-galley/blob/master/features/usage.feature
|
28
|
+
2. https://github.com/sowcow/middleman-galley/issues/new
|
22
29
|
|
23
30
|
## Contributing
|
24
31
|
|
@@ -36,3 +36,13 @@ end
|
|
36
36
|
And /^the file "(.*?)" has no images$/ do |file|
|
37
37
|
assert_images file, []
|
38
38
|
end
|
39
|
+
|
40
|
+
And /^document "(.*?)" has (\d+) "(.*?)"$/ do \
|
41
|
+
|file, count, selector|
|
42
|
+
count = count.to_i
|
43
|
+
select(file, selector).count.should == count
|
44
|
+
end
|
45
|
+
|
46
|
+
def select file, selector
|
47
|
+
parse_html(file).css selector
|
48
|
+
end
|
data/features/support/env.rb
CHANGED
data/features/usage.feature
CHANGED
@@ -15,7 +15,7 @@ Feature: Usage
|
|
15
15
|
Given I successfully run `middleman init my-site`
|
16
16
|
And I cd to "my-site"
|
17
17
|
|
18
|
-
# images for gallery
|
18
|
+
# images for the gallery
|
19
19
|
And I prepare following files:
|
20
20
|
| source/gallery/cards/one/01.png |
|
21
21
|
| source/gallery/cards/one/02.png |
|
@@ -37,8 +37,8 @@ Feature: Usage
|
|
37
37
|
# by default uses `gallery` dir inside `source` dir
|
38
38
|
activate :galley
|
39
39
|
|
40
|
-
#
|
41
|
-
|
40
|
+
# todo: test non relative paths?
|
41
|
+
set :relative_links, true
|
42
42
|
"""
|
43
43
|
# verbose option is optional
|
44
44
|
And I successfully run `middleman build --verbose`
|
@@ -62,10 +62,10 @@ Feature: Usage
|
|
62
62
|
| build/gallery/other/01.png |
|
63
63
|
| build/gallery/other/02.png |
|
64
64
|
|
65
|
-
# pages are linked
|
65
|
+
# pages are linked (links sorted by name?) distinct feature?
|
66
66
|
And the file "build/gallery/index.html" has links:
|
67
|
-
| other | other/ |
|
68
67
|
| cards | cards/ |
|
68
|
+
| other | other/ |
|
69
69
|
|
70
70
|
And the file "build/gallery/cards/index.html" has links:
|
71
71
|
| one | one/ |
|
@@ -87,3 +87,10 @@ Feature: Usage
|
|
87
87
|
| 02.png |
|
88
88
|
And the file "build/gallery/index.html" has no images
|
89
89
|
And the file "build/gallery/cards/index.html" has no images
|
90
|
+
|
91
|
+
# with fotorama template by default:
|
92
|
+
And document "build/gallery/index.html" has 0 ".fotorama > img"
|
93
|
+
And document "build/gallery/cards/index.html" has 0 ".fotorama > img"
|
94
|
+
And document "build/gallery/cards/one/index.html" has 2 ".fotorama > img"
|
95
|
+
And document "build/gallery/cards/two/index.html" has 2 ".fotorama > img"
|
96
|
+
And document "build/gallery/other/index.html" has 2 ".fotorama > img"
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Middleman
|
2
|
+
module Galley
|
3
|
+
class GalleryTemplate
|
4
|
+
@@known = {}
|
5
|
+
def self.[] name
|
6
|
+
name = name.to_sym
|
7
|
+
@@known[name]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.register name
|
11
|
+
name = name.to_sym
|
12
|
+
@@known[name] = self
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.build context
|
16
|
+
new(context).build
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize context
|
20
|
+
@context = context
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def a
|
25
|
+
@context
|
26
|
+
end
|
27
|
+
|
28
|
+
def children
|
29
|
+
@context.current_page.children
|
30
|
+
end
|
31
|
+
|
32
|
+
def image_tags
|
33
|
+
children.sort_by(&:url).map { |x| image x }.compact
|
34
|
+
end
|
35
|
+
|
36
|
+
def image res
|
37
|
+
return nil unless image? res
|
38
|
+
url = if a.relative_links
|
39
|
+
relative res.url
|
40
|
+
else
|
41
|
+
res.url
|
42
|
+
end
|
43
|
+
a.tag :img, src: url
|
44
|
+
end
|
45
|
+
|
46
|
+
IMG = /\.(png|jpg|jpeg|gif|svg|bmp)$/
|
47
|
+
def image? res
|
48
|
+
res.source_file =~ IMG
|
49
|
+
end
|
50
|
+
|
51
|
+
def relative url
|
52
|
+
url.sub a.current_page.url, ''
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# todo extract:
|
57
|
+
|
58
|
+
class Fotorama < GalleryTemplate
|
59
|
+
register :fotorama
|
60
|
+
|
61
|
+
def build
|
62
|
+
a.content_tag(:script, src:
|
63
|
+
"http://code.jquery.com/jquery-1.10.2.min.js"){''}
|
64
|
+
a.content_tag(:script, src:
|
65
|
+
"http://fotorama.s3.amazonaws.com/4.4.6/fotorama.js"){''}
|
66
|
+
style = a.content_tag(:script) do <<tag
|
67
|
+
$("head").append("<link rel='stylesheet' href='http://fotorama.s3.amazonaws.com/4.4.6/fotorama.css' />");
|
68
|
+
tag
|
69
|
+
end
|
70
|
+
images = a.content_tag(:div, class: 'fotorama') do
|
71
|
+
image_tags.join
|
72
|
+
end
|
73
|
+
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'middleman/galley/gallery_template'
|
2
2
|
|
3
3
|
module Middleman
|
4
4
|
module Galley
|
@@ -11,16 +11,18 @@ module Middleman
|
|
11
11
|
# to extract as a partial?...
|
12
12
|
def nested
|
13
13
|
a.current_page.children.select { |x| nested? x }
|
14
|
+
.sort_by { |x| name x }
|
14
15
|
.map { |x| link x }
|
15
16
|
.join
|
16
17
|
end
|
17
18
|
|
18
19
|
# to extract as a partial?...
|
19
|
-
def images
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def images gallery_template = :default
|
21
|
+
if gallery_template == :default
|
22
|
+
gallery_template = a.galley!
|
23
|
+
.options.default_template
|
24
|
+
end
|
25
|
+
GalleryTemplate[gallery_template].build a
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
@@ -33,24 +35,12 @@ module Middleman
|
|
33
35
|
res.path =~ /\/index\.html$/
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
|
38
|
-
#raise [a.current_page.url, res.url].inspect
|
39
|
-
#raise [a.current_page.url, res.url,
|
40
|
-
# relative(res.url),
|
41
|
-
# a.image_tag(relative res.url) ].inspect
|
42
|
-
#a.image_tag relative(res.url)
|
43
|
-
'<img src="%s" />' % relative(res.url)
|
38
|
+
def name res
|
39
|
+
Pathname(res.url).basename.to_s
|
44
40
|
end
|
45
41
|
|
46
42
|
def link res
|
47
|
-
name
|
48
|
-
a.link_to name, relative(res.url)
|
49
|
-
end
|
50
|
-
|
51
|
-
# middleman dont want to do that...
|
52
|
-
def relative url
|
53
|
-
url.sub a.current_page.url, ''
|
43
|
+
a.link_to name(res), res
|
54
44
|
end
|
55
45
|
end
|
56
46
|
end
|
data/lib/middleman/galley.rb
CHANGED
@@ -8,9 +8,20 @@ require 'fileutils'
|
|
8
8
|
module Middleman
|
9
9
|
module Galley
|
10
10
|
|
11
|
+
module Method
|
12
|
+
def galley!
|
13
|
+
extensions[:galley].values.find { |x|
|
14
|
+
x.has? current_page
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
class Ext < Extension
|
12
20
|
extend GemStuff
|
13
21
|
|
22
|
+
self.option :default_template, 'fotorama',
|
23
|
+
'default gallery template'
|
24
|
+
|
14
25
|
self.option :at, 'gallery',
|
15
26
|
'gallery directory'
|
16
27
|
|
@@ -23,7 +34,13 @@ module Middleman
|
|
23
34
|
self.option :template, template,
|
24
35
|
'template for missing pages'
|
25
36
|
|
37
|
+
def self.supports_multiple_instances?
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
26
41
|
def initialize app, options_hash={}, &block
|
42
|
+
app.send :include, Galley::Method
|
43
|
+
|
27
44
|
super
|
28
45
|
|
29
46
|
missing.each { |dir|
|
@@ -33,6 +50,12 @@ module Middleman
|
|
33
50
|
}
|
34
51
|
end
|
35
52
|
|
53
|
+
def has? page
|
54
|
+
at = options.at
|
55
|
+
at = at[0] == ?/ ? at : "/#{at}"
|
56
|
+
page.url.index(at) == 0
|
57
|
+
end
|
58
|
+
|
36
59
|
helpers do
|
37
60
|
def galley
|
38
61
|
::Middleman::Galley::Helper.new self
|
data/middleman-galley.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency 'aruba'
|
25
25
|
spec.add_development_dependency 'nokogiri'
|
26
|
-
spec.add_development_dependency '
|
27
|
-
|
26
|
+
spec.add_development_dependency 'coveralls'
|
27
|
+
# moved to Gemfile:
|
28
|
+
#spec.add_development_dependency 'guard-cucumber', group: :guard
|
29
|
+
spec.add_runtime_dependency 'middleman', '~> 3.1'
|
28
30
|
end
|
data/templates/index.erb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-galley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander K
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: coveralls
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: middleman
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.1'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.1'
|
97
97
|
description: 'convenient and simplistic image gallery for middleman '
|
98
98
|
email:
|
99
99
|
- xpyro@ya.ru
|
@@ -102,6 +102,7 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
|
+
- .travis.yml
|
105
106
|
- Gemfile
|
106
107
|
- Guardfile
|
107
108
|
- LICENSE.txt
|
@@ -111,6 +112,7 @@ files:
|
|
111
112
|
- features/support/env.rb
|
112
113
|
- features/usage.feature
|
113
114
|
- lib/middleman/galley.rb
|
115
|
+
- lib/middleman/galley/gallery_template.rb
|
114
116
|
- lib/middleman/galley/gem_stuff.rb
|
115
117
|
- lib/middleman/galley/helper.rb
|
116
118
|
- lib/middleman/galley/version.rb
|