refinerycms-images 1.0.11 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/refinery/admin/images_controller.rb +110 -0
- data/app/helpers/refinery/admin/images_helper.rb +24 -0
- data/app/models/refinery/image.rb +96 -0
- data/app/views/refinery/admin/images/_actions.html.erb +15 -0
- data/app/views/{admin → refinery/admin}/images/_existing_image.html.erb +13 -26
- data/app/views/{admin → refinery/admin}/images/_form.html.erb +11 -15
- data/app/views/{admin → refinery/admin}/images/_grid_view.html.erb +7 -5
- data/app/views/refinery/admin/images/_images.html.erb +2 -0
- data/app/views/{admin → refinery/admin}/images/_list_view.html.erb +0 -0
- data/app/views/{admin → refinery/admin}/images/_list_view_image.html.erb +7 -5
- data/app/views/refinery/admin/images/_records.html.erb +18 -0
- data/app/views/refinery/admin/images/edit.html.erb +1 -0
- data/app/views/refinery/admin/images/index.html.erb +6 -0
- data/app/views/{admin → refinery/admin}/images/insert.html.erb +10 -13
- data/app/views/refinery/admin/images/new.html.erb +1 -0
- data/config/locales/bg.yml +37 -36
- data/config/locales/cs.yml +37 -36
- data/config/locales/da.yml +37 -36
- data/config/locales/de.yml +37 -36
- data/config/locales/el.yml +37 -36
- data/config/locales/en.yml +37 -36
- data/config/locales/es.yml +38 -37
- data/config/locales/fi.yml +37 -36
- data/config/locales/fr.yml +37 -36
- data/config/locales/it.yml +47 -45
- data/config/locales/ja.yml +44 -0
- data/config/locales/ko.yml +44 -0
- data/config/locales/lt.yml +37 -36
- data/config/locales/lv.yml +37 -36
- data/config/locales/nb.yml +37 -37
- data/config/locales/nl.yml +36 -35
- data/config/locales/pl.yml +38 -37
- data/config/locales/pt-BR.yml +38 -37
- data/config/locales/rs.yml +37 -37
- data/config/locales/ru.yml +37 -36
- data/config/locales/sk.yml +37 -36
- data/config/locales/sl.yml +36 -35
- data/config/locales/sv.yml +37 -36
- data/config/locales/vi.yml +37 -36
- data/config/locales/zh-CN.yml +37 -36
- data/config/locales/zh-TW.yml +37 -36
- data/config/routes.rb +4 -7
- data/db/migrate/20100913234707_create_refinerycms_images_schema.rb +10 -18
- data/lib/generators/refinery/images/images_generator.rb +10 -0
- data/lib/generators/refinery/images/templates/config/initializers/refinery/images.rb.erb +41 -0
- data/lib/refinery/images.rb +25 -0
- data/lib/refinery/images/configuration.rb +54 -0
- data/lib/refinery/images/dragonfly.rb +54 -0
- data/lib/refinery/images/engine.rb +38 -0
- data/lib/refinery/images/validators.rb +7 -0
- data/lib/refinery/images/validators/image_size_validator.rb +19 -0
- data/lib/refinerycms-images.rb +1 -76
- data/refinerycms-images.gemspec +14 -91
- data/spec/factories/image.rb +5 -0
- data/{features/uploads → spec/fixtures}/beach.jpeg +0 -0
- data/spec/fixtures/fathead.png +0 -0
- data/spec/fixtures/image-with-dashes.jpg +0 -0
- data/spec/lib/generators/refinery/images/images_generator_spec.rb +29 -0
- data/spec/models/refinery/image_spec.rb +158 -0
- data/spec/requests/refinery/admin/images_spec.rb +103 -0
- metadata +116 -106
- data/app/controllers/admin/images_controller.rb +0 -106
- data/app/helpers/admin/images_helper.rb +0 -27
- data/app/models/image.rb +0 -116
- data/app/views/admin/images/_actions.html.erb +0 -16
- data/app/views/admin/images/_images.html.erb +0 -2
- data/app/views/admin/images/_records.html.erb +0 -18
- data/app/views/admin/images/edit.html.erb +0 -1
- data/app/views/admin/images/index.html.erb +0 -6
- data/app/views/admin/images/new.html.erb +0 -1
- data/config/locales/jp.yml +0 -43
- data/config/locales/lolcat.yml +0 -43
- data/features/manage_images.feature +0 -49
- data/features/step_definitions/image_steps.rb +0 -40
- data/features/support/factories.rb +0 -7
- data/features/support/paths.rb +0 -17
- data/features/uploads/id-rather-be-here.jpg +0 -0
- data/features/uploads/refinery_is_awesome.txt +0 -1
- data/lib/gemspec.rb +0 -38
- data/lib/generators/refinerycms_images_generator.rb +0 -8
- data/spec/models/image_spec.rb +0 -115
- data/spec/uploads/beach.jpeg +0 -0
@@ -1,40 +0,0 @@
|
|
1
|
-
Given /^I have no images$/ do
|
2
|
-
Image.destroy_all
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I attach the image at "([^\"]*)"$/ do |file_path|
|
6
|
-
attach_file('image_image', File.join(File.expand_path('../../uploads/', __FILE__), file_path))
|
7
|
-
end
|
8
|
-
|
9
|
-
Then /^the image "([^\"]*)" should have uploaded successfully$/ do |file_name|
|
10
|
-
Image.find_by_image_name(file_name).nil?.should == false
|
11
|
-
end
|
12
|
-
|
13
|
-
Then /^the image should have size "([^\"]*)"$/ do |size|
|
14
|
-
Image.first.size.should == size.to_i
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^the image should have width "([^\"]*)"$/ do |width|
|
18
|
-
Image.first.width.should == width.to_i
|
19
|
-
end
|
20
|
-
|
21
|
-
Then /^the image should have height "([^\"]*)"$/ do |height|
|
22
|
-
Image.first.height.should == height.to_i
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^the image should have mime_type "([^\"]*)"$/ do |mime_type|
|
26
|
-
Image.first.mime_type.should == mime_type.to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
Then /^I should have ([0-9]+) images?$/ do |number|
|
30
|
-
Image.count.should == number.to_i
|
31
|
-
end
|
32
|
-
|
33
|
-
When /^I upload the image at "([^\"]*)"$/ do |file_path|
|
34
|
-
original_stderr = $stderr.dup
|
35
|
-
$stderr.reopen(Tempfile.new('stderr'))
|
36
|
-
visit new_admin_image_path
|
37
|
-
attach_file('image_image', File.join(File.expand_path('../../uploads/', __FILE__), file_path))
|
38
|
-
click_button 'Save'
|
39
|
-
$stderr.reopen(original_stderr)
|
40
|
-
end
|
data/features/support/paths.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module NavigationHelpers
|
2
|
-
module Refinery
|
3
|
-
module Images
|
4
|
-
def path_to(page_name)
|
5
|
-
case page_name
|
6
|
-
when /the list of images/
|
7
|
-
admin_images_path
|
8
|
-
|
9
|
-
when /the new image form/
|
10
|
-
new_admin_image_path
|
11
|
-
else
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
http://www.refineryhq.com/
|
data/lib/gemspec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Encoding: UTF-8
|
2
|
-
require 'pathname'
|
3
|
-
gempath = Pathname.new(File.expand_path('../../', __FILE__))
|
4
|
-
require gempath.join('..', 'base', 'lib', 'base', 'refinery')
|
5
|
-
|
6
|
-
gemspec = <<EOF
|
7
|
-
# Encoding: UTF-8
|
8
|
-
# DO NOT EDIT THIS FILE DIRECTLY! Instead, use lib/gemspec.rb to generate it.
|
9
|
-
|
10
|
-
Gem::Specification.new do |s|
|
11
|
-
s.name = %q{#{gemname = 'refinerycms-images'}}
|
12
|
-
s.version = %q{#{::Refinery.version}}
|
13
|
-
s.summary = %q{Images engine for Refinery CMS}
|
14
|
-
s.description = %q{Handles all image upload and processing functionality in Refinery CMS.}
|
15
|
-
s.date = %q{#{Time.now.strftime('%Y-%m-%d')}}
|
16
|
-
s.email = %q{info@refinerycms.com}
|
17
|
-
s.homepage = %q{http://refinerycms.com}
|
18
|
-
s.rubyforge_project = %q{refinerycms}
|
19
|
-
s.authors = ['Resolve Digital', 'Philip Arndt', 'David Jones', 'Steven Heidel', 'Uģis Ozols']
|
20
|
-
s.license = %q{MIT}
|
21
|
-
s.require_paths = %w(lib)
|
22
|
-
s.executables = %w(#{Pathname.glob(gempath.join('bin/*')).map{|d| d.relative_path_from(gempath)}.sort.join(" ")})
|
23
|
-
|
24
|
-
s.files = [
|
25
|
-
'#{%w( **/{*,.rspec,.gitignore,.yardopts} ).map { |file| Pathname.glob(gempath.join(file)) }.flatten.reject{|f|
|
26
|
-
!f.exist? or f.to_s =~ /(\.(gem|rbc)|tmp(\/.*)?|spec\/lib\/tmp(\/.*)?)$/ or (f.directory? and f.children.empty?)
|
27
|
-
}.map{|d| d.relative_path_from(gempath)}.uniq.sort.join("',\n '")}'
|
28
|
-
]
|
29
|
-
|
30
|
-
s.add_dependency 'refinerycms-core', '= #{::Refinery::Version}'
|
31
|
-
s.add_dependency 'activerecord', '~> 3.0.10'
|
32
|
-
s.add_dependency 'dragonfly', '~> 0.9.0'
|
33
|
-
s.add_dependency 'rack-cache', '>= 0.5.3'
|
34
|
-
end
|
35
|
-
EOF
|
36
|
-
|
37
|
-
(gemfile = gempath.join("#{gemname}.gemspec")).open('w') {|f| f.puts(gemspec)}
|
38
|
-
puts `cd #{gempath} && gem build #{gemfile}` if ARGV.any?{|a| a == "BUILD=true"}
|
data/spec/models/image_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Image do
|
4
|
-
let(:image) do
|
5
|
-
Image.create!(:id => 1,
|
6
|
-
:image => File.new(File.expand_path('../../uploads/beach.jpeg', __FILE__)))
|
7
|
-
end
|
8
|
-
|
9
|
-
context "with valid attributes" do
|
10
|
-
it "should create successfully" do
|
11
|
-
image.errors.should be_empty
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "image url" do
|
16
|
-
it "should respond to .thumbnail" do
|
17
|
-
image.should respond_to(:thumbnail)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should contain its filename at the end" do
|
21
|
-
image.thumbnail(nil).url.split('/').last.should == image.image_name
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should be different when supplying geometry" do
|
25
|
-
image.thumbnail(nil).url.should_not == image.thumbnail('200x200').url
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should have different urls for each geometry string" do
|
29
|
-
image.thumbnail('200x200').url.should_not == image.thumbnail('200x201').url
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should use right geometry when given a thumbnail name" do
|
33
|
-
name, geometry = Image.user_image_sizes.first
|
34
|
-
image.thumbnail(name).url.should == image.thumbnail(geometry).url
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#title" do
|
39
|
-
it "returns a titleized version of the filename" do
|
40
|
-
image.title.should == "Beach"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe ".per_page" do
|
45
|
-
context "dialog is true" do
|
46
|
-
context "has_size_options is true" do
|
47
|
-
it "returns image count specified by PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS constant" do
|
48
|
-
Image.per_page(true, true).should == Image::PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "has_size_options is false" do
|
53
|
-
it "returns image count specified by PAGES_PER_DIALOG constant" do
|
54
|
-
Image.per_page(true).should == Image::PAGES_PER_DIALOG
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "dialog is false" do
|
60
|
-
it "returns image count specified by PAGES_PER_ADMIN_INDEX constant" do
|
61
|
-
Image.per_page.should == Image::PAGES_PER_ADMIN_INDEX
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe ".user_image_sizes" do
|
67
|
-
it "sets and returns a hash consisting of the keys contained in the RefinerySetting" do
|
68
|
-
Image.user_image_sizes.should == RefinerySetting.get(:user_image_sizes)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# The sample image has dimensions 500x375
|
73
|
-
describe '#thumbnail_dimensions returns correctly with' do
|
74
|
-
it 'nil' do
|
75
|
-
image.thumbnail_dimensions(nil).should == { :width => 500, :height => 375 }
|
76
|
-
end
|
77
|
-
|
78
|
-
it '200x200#ne' do
|
79
|
-
image.thumbnail_dimensions('200x200#ne').should == { :width => 200, :height => 200 }
|
80
|
-
end
|
81
|
-
|
82
|
-
it '100x150#c' do
|
83
|
-
image.thumbnail_dimensions('100x150#c').should == { :width => 100, :height => 150 }
|
84
|
-
end
|
85
|
-
|
86
|
-
it '250x250>' do
|
87
|
-
image.thumbnail_dimensions('250x250>').should == { :width => 250, :height => 188 }
|
88
|
-
end
|
89
|
-
|
90
|
-
it '600x375>' do
|
91
|
-
image.thumbnail_dimensions('600x375>').should == { :width => 500, :height => 375 }
|
92
|
-
end
|
93
|
-
|
94
|
-
it '100x475>' do
|
95
|
-
image.thumbnail_dimensions('100x475>').should == { :width => 100, :height => 75 }
|
96
|
-
end
|
97
|
-
|
98
|
-
it '100x150' do
|
99
|
-
image.thumbnail_dimensions('100x150').should == { :width => 100, :height => 75 }
|
100
|
-
end
|
101
|
-
|
102
|
-
it '200x150' do
|
103
|
-
image.thumbnail_dimensions('200x150').should == { :width => 200, :height => 150 }
|
104
|
-
end
|
105
|
-
|
106
|
-
it '300x150' do
|
107
|
-
image.thumbnail_dimensions('300x150').should == { :width => 200, :height => 150 }
|
108
|
-
end
|
109
|
-
|
110
|
-
it '5x5' do
|
111
|
-
image.thumbnail_dimensions('5x5').should == { :width => 5, :height => 4 }
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
data/spec/uploads/beach.jpeg
DELETED
Binary file
|