middleman-galley 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/features/step_definitions/usage_steps.rb +38 -0
- data/features/support/env.rb +1 -0
- data/features/usage.feature +89 -0
- data/lib/middleman/galley.rb +57 -0
- data/lib/middleman/galley/gem_stuff.rb +16 -0
- data/lib/middleman/galley/helper.rb +57 -0
- data/lib/middleman/galley/version.rb +5 -0
- data/middleman-galley.gemspec +28 -0
- data/templates/index.erb +2 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 441fc879469c42cbec011f465257a0ceeac8ad31
|
4
|
+
data.tar.gz: 22f615b2fb1f31eecef23cab7c4a7e7b79e18538
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 072aad4f8c14ff2f2e0e691d0c8af3733685773d57913a699a2fb8eb2c2b9cc5b67aeb18c3f2b971db4a7ab0a6d94e64e337b33996dcd962840d68d995b2c9c8
|
7
|
+
data.tar.gz: e47135cb19c48b5de2efd39ec860d7cd3bfdf6eebba3317690abf3181d323da436218e777728b52fab4e5117a5b66fba9e3c6ee516615e8aeeb67532d1c68ff7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
guard 'cucumber' do
|
2
|
+
watch(%r{^features/.+\.feature$})
|
3
|
+
watch(%r{^lib/.+\.rb$}) { 'features' }
|
4
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
5
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
6
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Alexander K
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Middleman::Galley
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'middleman-galley'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install middleman-galley
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
Given 'I prepare following files:' do |table|
|
4
|
+
files = table.raw
|
5
|
+
files.each { |file|
|
6
|
+
file = file[0]
|
7
|
+
step "an empty file named \"#{file}\""
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
And /^the file "(.*?)" has links:$/ do |file, table|
|
12
|
+
names, links = table.raw.transpose
|
13
|
+
assert_links file, names, links
|
14
|
+
end
|
15
|
+
|
16
|
+
And /^the file "(.*?)" has no links$/ do |file|
|
17
|
+
assert_links file, [], []
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse_html file
|
21
|
+
in_current_dir { Nokogiri.HTML File.read file }
|
22
|
+
end
|
23
|
+
def assert_links file, names, links
|
24
|
+
doc = parse_html file
|
25
|
+
doc.css('a').map { |a| a[:href] }.should == links
|
26
|
+
doc.css('a').map { |a| a.text }.should == names
|
27
|
+
end
|
28
|
+
def assert_images file, images
|
29
|
+
doc = parse_html file
|
30
|
+
doc.css('img').map { |a| a[:src] }.should == images
|
31
|
+
end
|
32
|
+
|
33
|
+
And /^the file "(.*?)" has images:$/ do |file, table|
|
34
|
+
assert_images file, table.raw.map(&:first)
|
35
|
+
end
|
36
|
+
And /^the file "(.*?)" has no images$/ do |file|
|
37
|
+
assert_images file, []
|
38
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Feature: Usage
|
2
|
+
In order to have fun
|
3
|
+
As a human
|
4
|
+
I want my images in the browser
|
5
|
+
|
6
|
+
Scenario: ruby is installed
|
7
|
+
When I successfully run `ruby -v`
|
8
|
+
Then the output should contain "ruby"
|
9
|
+
|
10
|
+
Scenario: middleman is installed
|
11
|
+
When I successfully run `middleman --help`
|
12
|
+
Then the output should contain "middleman"
|
13
|
+
|
14
|
+
Scenario: build gallery
|
15
|
+
Given I successfully run `middleman init my-site`
|
16
|
+
And I cd to "my-site"
|
17
|
+
|
18
|
+
# images for gallery
|
19
|
+
And I prepare following files:
|
20
|
+
| source/gallery/cards/one/01.png |
|
21
|
+
| source/gallery/cards/one/02.png |
|
22
|
+
| source/gallery/cards/two/a1.png |
|
23
|
+
| source/gallery/cards/two/a2.png |
|
24
|
+
| source/gallery/other/01.png |
|
25
|
+
| source/gallery/other/02.png |
|
26
|
+
|
27
|
+
When I append to "Gemfile" with:
|
28
|
+
"""
|
29
|
+
|
30
|
+
gem 'middleman-galley'
|
31
|
+
"""
|
32
|
+
And I successfully run `bundle`
|
33
|
+
|
34
|
+
When I append to "config.rb" with:
|
35
|
+
"""
|
36
|
+
|
37
|
+
# by default uses `gallery` dir inside `source` dir
|
38
|
+
activate :galley
|
39
|
+
|
40
|
+
# made with relative paths in mind anyway
|
41
|
+
# activate :directory_indexes
|
42
|
+
"""
|
43
|
+
# verbose option is optional
|
44
|
+
And I successfully run `middleman build --verbose`
|
45
|
+
|
46
|
+
Then the output should not contain "Unknown Extension"
|
47
|
+
|
48
|
+
# pages
|
49
|
+
And the following files should exist:
|
50
|
+
| build/gallery/index.html |
|
51
|
+
|
52
|
+
| build/gallery/cards/index.html |
|
53
|
+
| build/gallery/cards/one/index.html |
|
54
|
+
| build/gallery/cards/one/01.png |
|
55
|
+
| build/gallery/cards/one/02.png |
|
56
|
+
|
57
|
+
| build/gallery/cards/two/index.html |
|
58
|
+
| build/gallery/cards/two/a1.png |
|
59
|
+
| build/gallery/cards/two/a1.png |
|
60
|
+
|
61
|
+
| build/gallery/other/index.html |
|
62
|
+
| build/gallery/other/01.png |
|
63
|
+
| build/gallery/other/02.png |
|
64
|
+
|
65
|
+
# pages are linked
|
66
|
+
And the file "build/gallery/index.html" has links:
|
67
|
+
| other | other/ |
|
68
|
+
| cards | cards/ |
|
69
|
+
|
70
|
+
And the file "build/gallery/cards/index.html" has links:
|
71
|
+
| one | one/ |
|
72
|
+
| two | two/ |
|
73
|
+
|
74
|
+
And the file "build/gallery/cards/one/index.html" has no links
|
75
|
+
And the file "build/gallery/cards/two/index.html" has no links
|
76
|
+
And the file "build/gallery/other/index.html" has no links
|
77
|
+
|
78
|
+
# pages have images
|
79
|
+
And the file "build/gallery/cards/one/index.html" has images:
|
80
|
+
| 01.png |
|
81
|
+
| 02.png |
|
82
|
+
And the file "build/gallery/cards/two/index.html" has images:
|
83
|
+
| a1.png |
|
84
|
+
| a2.png |
|
85
|
+
And the file "build/gallery/other/index.html" has images:
|
86
|
+
| 01.png |
|
87
|
+
| 02.png |
|
88
|
+
And the file "build/gallery/index.html" has no images
|
89
|
+
And the file "build/gallery/cards/index.html" has no images
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'middleman/galley/version'
|
2
|
+
require 'middleman/galley/gem_stuff'
|
3
|
+
require 'middleman/galley/helper'
|
4
|
+
require 'middleman' # kinda required...
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
|
8
|
+
module Middleman
|
9
|
+
module Galley
|
10
|
+
|
11
|
+
class Ext < Extension
|
12
|
+
extend GemStuff
|
13
|
+
|
14
|
+
self.option :at, 'gallery',
|
15
|
+
'gallery directory'
|
16
|
+
|
17
|
+
# todo: templates/index.*?'
|
18
|
+
self.option :lang, 'erb',
|
19
|
+
'erb / slim / any?'
|
20
|
+
|
21
|
+
template = here('templates/index.erb')
|
22
|
+
|
23
|
+
self.option :template, template,
|
24
|
+
'template for missing pages'
|
25
|
+
|
26
|
+
def initialize app, options_hash={}, &block
|
27
|
+
super
|
28
|
+
|
29
|
+
missing.each { |dir|
|
30
|
+
base = Pathname(options.template).basename.to_s
|
31
|
+
dest = dir + base
|
32
|
+
FileUtils.cp options.template, dest.to_s
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
helpers do
|
37
|
+
def galley
|
38
|
+
::Middleman::Galley::Helper.new self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def missing
|
44
|
+
src = Pathname('source')
|
45
|
+
dir = src + options.at
|
46
|
+
dirs = [dir] + Pathname.glob(dir + '**/**')
|
47
|
+
.select(&:directory?)
|
48
|
+
missing = dirs.reject { |x|
|
49
|
+
x.children.any? { |x|
|
50
|
+
x.to_s =~ /\/index(\.[^\/]+)?$/ }
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Extensions.register :galley, Galley::Ext
|
57
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Middleman::Galley::GemStuff
|
4
|
+
def this_path
|
5
|
+
@this_path ||=
|
6
|
+
begin
|
7
|
+
this = 'middleman-galley'
|
8
|
+
this = Gem::Specification.find_by_name this
|
9
|
+
Pathname this.gem_dir
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def here relative_path
|
14
|
+
(this_path + relative_path).to_s
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#require 'delegate' #< SimpleDelegator
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module Galley
|
5
|
+
class Helper
|
6
|
+
def initialize context
|
7
|
+
@a = context
|
8
|
+
end
|
9
|
+
attr_reader :a
|
10
|
+
|
11
|
+
# to extract as a partial?...
|
12
|
+
def nested
|
13
|
+
a.current_page.children.select { |x| nested? x }
|
14
|
+
.map { |x| link x }
|
15
|
+
.join
|
16
|
+
end
|
17
|
+
|
18
|
+
# to extract as a partial?...
|
19
|
+
def images
|
20
|
+
a.current_page.children.select { |x| image? x }
|
21
|
+
.sort_by { |x| x.url }
|
22
|
+
.map { |x| image x }
|
23
|
+
.join
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
IMG = /\.(png|jpg|jpeg|gif|svg|bmp)$/
|
28
|
+
|
29
|
+
def image? res
|
30
|
+
res.source_file =~ IMG
|
31
|
+
end
|
32
|
+
def nested? res
|
33
|
+
res.path =~ /\/index\.html$/
|
34
|
+
end
|
35
|
+
|
36
|
+
def image res
|
37
|
+
#return nil unless image? res #+optional compact ?
|
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)
|
44
|
+
end
|
45
|
+
|
46
|
+
def link res
|
47
|
+
name = Pathname(res.url).basename.to_s
|
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, ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'middleman/galley/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "middleman-galley"
|
8
|
+
spec.version = Middleman::Galley::VERSION
|
9
|
+
spec.authors = ["Alexander K"]
|
10
|
+
spec.email = ["xpyro@ya.ru"]
|
11
|
+
spec.description = %q{convenient and simplistic image gallery for middleman }
|
12
|
+
spec.summary = %q{image gallery for middleman}
|
13
|
+
spec.homepage = "https://github.com/sowcow/middleman-galley/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_development_dependency 'aruba'
|
25
|
+
spec.add_development_dependency 'nokogiri'
|
26
|
+
spec.add_development_dependency 'guard-cucumber'
|
27
|
+
spec.add_runtime_dependency 'middleman'
|
28
|
+
end
|
data/templates/index.erb
ADDED
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-galley
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander K
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: middleman
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: 'convenient and simplistic image gallery for middleman '
|
98
|
+
email:
|
99
|
+
- xpyro@ya.ru
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- Guardfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- features/step_definitions/usage_steps.rb
|
111
|
+
- features/support/env.rb
|
112
|
+
- features/usage.feature
|
113
|
+
- lib/middleman/galley.rb
|
114
|
+
- lib/middleman/galley/gem_stuff.rb
|
115
|
+
- lib/middleman/galley/helper.rb
|
116
|
+
- lib/middleman/galley/version.rb
|
117
|
+
- middleman-galley.gemspec
|
118
|
+
- templates/index.erb
|
119
|
+
homepage: https://github.com/sowcow/middleman-galley/
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.1.8
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: image gallery for middleman
|
143
|
+
test_files:
|
144
|
+
- features/step_definitions/usage_steps.rb
|
145
|
+
- features/support/env.rb
|
146
|
+
- features/usage.feature
|