noodall-components-gallery 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +21 -0
  3. data/Gemfile.lock +186 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +3 -0
  6. data/Rakefile +39 -0
  7. data/app/models/gallery.rb +13 -0
  8. data/app/views/admin/components/_gallery.html.erb +49 -0
  9. data/app/views/components/_gallery.html.erb +23 -0
  10. data/cucumber.yml +8 -0
  11. data/features/gallery_component.feature +19 -0
  12. data/features/step_definitions/asset_steps.rb +66 -0
  13. data/features/step_definitions/cms_node_steps.rb +126 -0
  14. data/features/step_definitions/component_steps.rb +138 -0
  15. data/features/step_definitions/web_steps.rb +219 -0
  16. data/features/support/env.rb +50 -0
  17. data/features/support/paths.rb +58 -0
  18. data/lib/noodall-components-gallery.rb +1 -0
  19. data/lib/noodall/components/gallery/engine.rb +11 -0
  20. data/lib/noodall/components/gallery/version.rb +7 -0
  21. data/noodall-components-gallery.gemspec +22 -0
  22. data/spec/dummy/Rakefile +7 -0
  23. data/spec/dummy/app/controllers/application_controller.rb +22 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +3 -0
  25. data/spec/dummy/app/models/page_a.rb +8 -0
  26. data/spec/dummy/app/models/user.rb +12 -0
  27. data/spec/dummy/app/views/admin/nodes/_page_a.html.erb +47 -0
  28. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  29. data/spec/dummy/app/views/nodes/page_a.html.erb +14 -0
  30. data/spec/dummy/config.ru +4 -0
  31. data/spec/dummy/config/application.rb +46 -0
  32. data/spec/dummy/config/boot.rb +10 -0
  33. data/spec/dummy/config/database.yml +12 -0
  34. data/spec/dummy/config/environment.rb +5 -0
  35. data/spec/dummy/config/environments/development.rb +26 -0
  36. data/spec/dummy/config/environments/production.rb +49 -0
  37. data/spec/dummy/config/environments/test.rb +35 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/dragonfly.rb +1 -0
  40. data/spec/dummy/config/initializers/inflections.rb +10 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  42. data/spec/dummy/config/initializers/mongo_mapper.rb +13 -0
  43. data/spec/dummy/config/initializers/noodall.rb +5 -0
  44. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  45. data/spec/dummy/config/initializers/session_store.rb +8 -0
  46. data/spec/dummy/config/locales/en.yml +5 -0
  47. data/spec/dummy/config/routes.rb +3 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +26 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/public/javascripts/application.js +2 -0
  53. data/spec/dummy/public/javascripts/controls.js +965 -0
  54. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  55. data/spec/dummy/public/javascripts/effects.js +1123 -0
  56. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  57. data/spec/dummy/public/javascripts/rails.js +175 -0
  58. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  59. data/spec/dummy/script/rails +6 -0
  60. data/spec/factories/asset.rb +6 -0
  61. data/spec/factories/node.rb +6 -0
  62. data/spec/files/beef.png +0 -0
  63. data/spec/integration/navigation_spec.rb +9 -0
  64. data/spec/noodall_component_gallery_spec.rb +7 -0
  65. data/spec/spec_helper.rb +30 -0
  66. metadata +149 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ pkg/*
2
+ *.gem
3
+ log/*.log
4
+ .bundle
5
+ spec/dummy/db/*.sqlite3
6
+ spec/dummy/log/*.log
7
+ spec/dummy/tmp/
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ gem "rails", "3.0.1"
6
+ gem 'noodall-ui', :path => "~/Gems/noodall-ui"
7
+ gem "capybara", ">= 0.3.9"
8
+ gem "rspec-rails", ">= 2.0.0.beta"
9
+ gem 'database_cleaner'
10
+ gem 'cucumber-rails'
11
+ gem 'launchy' # So you can do Then show me the page
12
+ gem 'rmagick', :require => 'RMagick'
13
+ gem 'dragonfly', '~> 0.7.6'
14
+ gem 'factory_girl', '~> 1.3.2'
15
+ gem "faker", "~> 0.3.1"
16
+
17
+
18
+ if RUBY_VERSION < '1.9'
19
+ gem "ruby-debug", ">= 0.10.3"
20
+ end
21
+
data/Gemfile.lock ADDED
@@ -0,0 +1,186 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ noodall-components-gallery (0.0.1)
5
+
6
+ PATH
7
+ remote: /Users/steve/Gems/noodall-ui
8
+ specs:
9
+ noodall-ui (0.0.2)
10
+ dynamic_form
11
+ noodall-core
12
+ thoughtbot-sortable_table (= 0.0.6)
13
+ will_paginate (~> 3.0.pre2)
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ abstract (1.0.0)
19
+ actionmailer (3.0.1)
20
+ actionpack (= 3.0.1)
21
+ mail (~> 2.2.5)
22
+ actionpack (3.0.1)
23
+ activemodel (= 3.0.1)
24
+ activesupport (= 3.0.1)
25
+ builder (~> 2.1.2)
26
+ erubis (~> 2.6.6)
27
+ i18n (~> 0.4.1)
28
+ rack (~> 1.2.1)
29
+ rack-mount (~> 0.6.12)
30
+ rack-test (~> 0.5.4)
31
+ tzinfo (~> 0.3.23)
32
+ activemodel (3.0.1)
33
+ activesupport (= 3.0.1)
34
+ builder (~> 2.1.2)
35
+ i18n (~> 0.4.1)
36
+ activerecord (3.0.1)
37
+ activemodel (= 3.0.1)
38
+ activesupport (= 3.0.1)
39
+ arel (~> 1.0.0)
40
+ tzinfo (~> 0.3.23)
41
+ activeresource (3.0.1)
42
+ activemodel (= 3.0.1)
43
+ activesupport (= 3.0.1)
44
+ activesupport (3.0.1)
45
+ arel (1.0.1)
46
+ activesupport (~> 3.0.0)
47
+ bson (1.1.1)
48
+ builder (2.1.2)
49
+ canable (0.1.1)
50
+ capybara (0.3.9)
51
+ culerity (>= 0.2.4)
52
+ mime-types (>= 1.16)
53
+ nokogiri (>= 1.3.3)
54
+ rack (>= 1.0.0)
55
+ rack-test (>= 0.5.4)
56
+ selenium-webdriver (>= 0.0.3)
57
+ childprocess (0.1.3)
58
+ ffi (~> 0.6.3)
59
+ columnize (0.3.1)
60
+ configuration (1.1.0)
61
+ cucumber (0.9.0)
62
+ builder (~> 2.1.2)
63
+ diff-lcs (~> 1.1.2)
64
+ gherkin (~> 2.2.2)
65
+ json (~> 1.4.6)
66
+ term-ansicolor (~> 1.0.5)
67
+ cucumber-rails (0.3.2)
68
+ cucumber (>= 0.8.0)
69
+ culerity (0.2.12)
70
+ database_cleaner (0.6.0)
71
+ diff-lcs (1.1.2)
72
+ dragonfly (0.7.6)
73
+ rack
74
+ dynamic_form (1.1.3)
75
+ erubis (2.6.6)
76
+ abstract (>= 1.0.0)
77
+ factory_girl (1.3.2)
78
+ faker (0.3.1)
79
+ ffi (0.6.3)
80
+ rake (>= 0.8.7)
81
+ gherkin (2.2.4)
82
+ json (~> 1.4.6)
83
+ term-ansicolor (~> 1.0.5)
84
+ trollop (~> 1.16.2)
85
+ i18n (0.4.1)
86
+ jnunemaker-validatable (1.8.4)
87
+ activesupport (>= 2.3.4)
88
+ json (1.4.6)
89
+ json_pure (1.4.6)
90
+ launchy (0.3.7)
91
+ configuration (>= 0.0.5)
92
+ rake (>= 0.8.1)
93
+ linecache (0.43)
94
+ mail (2.2.7)
95
+ activesupport (>= 2.3.6)
96
+ mime-types
97
+ treetop (>= 1.4.5)
98
+ mime-types (1.16)
99
+ mongo (1.1.1)
100
+ bson (>= 1.1.1)
101
+ mongo_mapper (0.8.4)
102
+ activesupport (>= 2.3.4)
103
+ jnunemaker-validatable (~> 1.8.4)
104
+ plucky (~> 0.3.5)
105
+ nokogiri (1.4.3.1)
106
+ noodall-core (0.1.0)
107
+ canable (= 0.1.1)
108
+ mongo_mapper (= 0.8.4)
109
+ ramdiv-mongo_mapper_acts_as_tree (= 0.1.1)
110
+ ruby-stemmer
111
+ plucky (0.3.6)
112
+ mongo (~> 1.1)
113
+ polyglot (0.3.1)
114
+ rack (1.2.1)
115
+ rack-mount (0.6.13)
116
+ rack (>= 1.0.0)
117
+ rack-test (0.5.6)
118
+ rack (>= 1.0)
119
+ rails (3.0.1)
120
+ actionmailer (= 3.0.1)
121
+ actionpack (= 3.0.1)
122
+ activerecord (= 3.0.1)
123
+ activeresource (= 3.0.1)
124
+ activesupport (= 3.0.1)
125
+ bundler (~> 1.0.0)
126
+ railties (= 3.0.1)
127
+ railties (3.0.1)
128
+ actionpack (= 3.0.1)
129
+ activesupport (= 3.0.1)
130
+ rake (>= 0.8.4)
131
+ thor (~> 0.14.0)
132
+ rake (0.8.7)
133
+ ramdiv-mongo_mapper_acts_as_tree (0.1.1)
134
+ mongo_mapper (>= 0.6.8)
135
+ rmagick (2.13.1)
136
+ rspec (2.0.0.beta.22)
137
+ rspec-core (= 2.0.0.beta.22)
138
+ rspec-expectations (= 2.0.0.beta.22)
139
+ rspec-mocks (= 2.0.0.beta.22)
140
+ rspec-core (2.0.0.beta.22)
141
+ rspec-expectations (2.0.0.beta.22)
142
+ diff-lcs (>= 1.1.2)
143
+ rspec-mocks (2.0.0.beta.22)
144
+ rspec-core (= 2.0.0.beta.22)
145
+ rspec-expectations (= 2.0.0.beta.22)
146
+ rspec-rails (2.0.0.beta.22)
147
+ rspec (= 2.0.0.beta.22)
148
+ ruby-debug (0.10.3)
149
+ columnize (>= 0.1)
150
+ ruby-debug-base (~> 0.10.3.0)
151
+ ruby-debug-base (0.10.3)
152
+ linecache (>= 0.3)
153
+ ruby-stemmer (0.8.2)
154
+ rubyzip (0.9.4)
155
+ selenium-webdriver (0.0.29)
156
+ childprocess (>= 0.0.7)
157
+ ffi (~> 0.6.3)
158
+ json_pure
159
+ rubyzip
160
+ term-ansicolor (1.0.5)
161
+ thor (0.14.3)
162
+ thoughtbot-sortable_table (0.0.6)
163
+ treetop (1.4.8)
164
+ polyglot (>= 0.3.1)
165
+ trollop (1.16.2)
166
+ tzinfo (0.3.23)
167
+ will_paginate (3.0.pre2)
168
+
169
+ PLATFORMS
170
+ ruby
171
+
172
+ DEPENDENCIES
173
+ bundler (>= 1.0.0)
174
+ capybara (>= 0.3.9)
175
+ cucumber-rails
176
+ database_cleaner
177
+ dragonfly (~> 0.7.6)
178
+ factory_girl (~> 1.3.2)
179
+ faker (~> 0.3.1)
180
+ launchy
181
+ noodall-components-gallery!
182
+ noodall-ui!
183
+ rails (= 3.0.1)
184
+ rmagick
185
+ rspec-rails (>= 2.0.0.beta)
186
+ ruby-debug (>= 0.10.3)
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2010 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Noodall-component-gallery
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ require 'rspec/core'
10
+ require 'rspec/core/rake_task'
11
+
12
+ Rspec::Core::RakeTask.new(:spec)
13
+
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
18
+ t.fork = true # You may get faster startup if you set this to false
19
+ t.profile = 'default'
20
+ end
21
+
22
+ Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
23
+ t.fork = true # You may get faster startup if you set this to false
24
+ t.profile = 'wip'
25
+ end
26
+
27
+ Cucumber::Rake::Task.new(:rerun, 'Record failing features and run only them if any exist') do |t|
28
+ t.fork = true # You may get faster startup if you set this to false
29
+ t.profile = 'rerun'
30
+ end
31
+
32
+ desc 'Run all features'
33
+ task :all => [:ok, :wip]
34
+ end
35
+ desc 'Alias for cucumber:ok'
36
+ task :cucumber => 'cucumber:ok'
37
+
38
+ task :default => :cucumber
39
+
@@ -0,0 +1,13 @@
1
+ class Gallery < Noodall::Component
2
+ key :title, String, :default => "Gallery"
3
+ key :description, String
4
+ key :asset_ids, Array, :typecast => 'ObjectId'
5
+
6
+
7
+ def assets
8
+ assets = Asset.all(:id => asset_ids)
9
+ asset_ids.map do |id|
10
+ assets.find{|a| a._id == id}
11
+ end.compact
12
+ end
13
+ end
@@ -0,0 +1,49 @@
1
+ <%= fields_for :node do |f| %>
2
+ <%= f.fields_for slot_name, component do |c| %>
3
+ <div class="multi-file-component">
4
+ <%= c.hidden_field :_type %>
5
+ <fieldset class="multi-file-details">
6
+ <legend>Gallery Details</legend>
7
+ <p>
8
+ <%= c.label :title %><br />
9
+ <span class="input-wrap"><%= c.text_field :title %></span>
10
+ </p>
11
+
12
+ <p>
13
+ <%= c.label :description %><br />
14
+ <span class="input-wrap"><%= c.text_area :description, :rows => 4 %></span>
15
+ </p>
16
+ </fieldset>
17
+ <fieldset class="multi-file-files images">
18
+ <legend>Images</legend>
19
+ <p><span class="add-multi-asset">Add File</span><span class="types">Images</span></p>
20
+ <ol>
21
+ <% component.assets.each_with_index do |asset,i| %>
22
+ <li class="multi-file file-selectable">
23
+ <span class="file-detail"><%= image_tag( asset.url('70x70#', :jpg) ) %></span>
24
+ <span class="delete" title="Remove this file">Delete</span>
25
+ <span class="edit" title="Edit this file">Edit</span>
26
+ <div class="file-form">
27
+ <p>
28
+ <span class="select-file">Select File</span>
29
+ (<span class="types">Images</span>)
30
+ <%= hidden_field_tag "node[#{slot_name}][asset_ids][]", asset.id, :id => "node_#{slot_name}_asset_id_#{i}", :class => "asset_id" %>
31
+ </p>
32
+ </div>
33
+ </li>
34
+ <% end %>
35
+ <li class="multi-file file-selectable">
36
+ <span class="delete" title="Remove this file">Delete</span>
37
+ <span class="edit" title="Edit this file">Edit</span>
38
+ <div class="file-form">
39
+ <p>
40
+ <span class="select-file">Select File</span>
41
+ (<span class="types">Images</span>)
42
+ <%= hidden_field_tag "node[#{slot_name}][asset_ids][]", '', :id => nil, :class => "asset_id" %>
43
+ </p>
44
+ </div>
45
+ </li>
46
+ </ol>
47
+ </fieldset></div>
48
+ <% end
49
+ end %>
@@ -0,0 +1,23 @@
1
+ <div id="<%= slot_code %>" class="component gallery <%= component.style %> <%= expand ? 'double' : 'single' %> <%= additional_classes %>">
2
+ <h2><%=h component.title %></h2>
3
+
4
+ <div class="carousel-wrap">
5
+ <div class="carousel">
6
+ <ul class="gallery <%= component.style %>">
7
+ <% for image in component.assets %>
8
+ <li>
9
+ <%= link_to(
10
+ image_tag(image.url('100x100#', :jpg), :alt => image.description),
11
+ image.url('800x600', :jpg),
12
+ :title => image.title,
13
+ :target => '_blank',
14
+ :rel => 'gallery') %>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+ </div>
19
+ </div>
20
+
21
+ <p><%= component.description %></p>
22
+
23
+ </div>
data/cucumber.yml ADDED
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,19 @@
1
+ @wip
2
+ Feature: Gallery Component
3
+ To provide the ability to show many images on the website, website editors will be able
4
+ to create a gallery of images within a template
5
+
6
+ @javascript
7
+ Scenario: Add Gallery Component
8
+ Given I am editing content
9
+ When I click a "Wide" component slot
10
+ And select the "Gallery" component
11
+ And fill in the following within the component:
12
+ | Title | Big Promotion |
13
+ | Description | A really big thing is happening! |
14
+ Then I add some images to from the asset library
15
+ And I press "Save" within the component
16
+ And I press "Publish"
17
+ And I visit the content page
18
+ Then I should see the gallery thumbnails
19
+
@@ -0,0 +1,66 @@
1
+ Given /^I am using the asset library$/ do
2
+ visit noodall_admin_assets_path
3
+ end
4
+
5
+ When /^I upload a file$/ do
6
+ click_link "Upload"
7
+ fill_in "Title", :with => "A loverly asset"
8
+ attach_file("File", "#{Rails.root}/spec/files/beef.png")
9
+ end
10
+
11
+ When /^enter tags$/ do
12
+ fill_in "Tags", :with => "you, me, things, stuff"
13
+ fill_in "Description", :with => "Some nice info"
14
+ click_button "Create"
15
+ end
16
+
17
+ Then /^it should appear in the asset library$/ do
18
+ page.should_not have_content('Errors')
19
+ page.should have_content('A loverly asset')
20
+ end
21
+
22
+ Given /^files have been uploaded to the asset library$/ do
23
+ 20.times { Factory(:asset) }
24
+ 20.times { Factory(:document_asset) }
25
+ 20.times { Factory(:video_asset) }
26
+
27
+ 20.times { Factory(:asset, :title => "Tagged Asset", :tags => ['RAC','lorem','dolar']) }
28
+
29
+ end
30
+
31
+ Then /^I should be able to browse assets by content type$/ do
32
+ within(:css, "ul.choices") { click_link "Images" }
33
+ page.should_not have_content('Document asset')
34
+ page.should_not have_content('Video asset')
35
+ within(:css, "ul.choices") { click_link "Documents" }
36
+ page.should_not have_content('Image asset')
37
+ page.should_not have_content('Video asset')
38
+ within(:css, "ul.choices") { click_link "Videos" }
39
+ page.should_not have_content('Document asset')
40
+ page.should_not have_content('Image asset')
41
+
42
+ end
43
+
44
+ Then /^I should be able to browse assets by tags$/ do
45
+ within(:css, "ul.choices") { click_link "Images" }
46
+ within(:css, "div#tags") { click_link "RAC" }
47
+ page.should_not have_content('Image asset')
48
+ end
49
+
50
+ When /^I click the editor "([^"]*)" button$/ do |button_name|
51
+ within('.mceToolbar') do
52
+ click_link button_name
53
+ end
54
+ end
55
+
56
+ When /^I click "([^"]*)" on an Asset$/ do |button_name|
57
+ within('#browser-list ul li:first') do
58
+ click_link button_name
59
+ end
60
+ end
61
+
62
+ Then /^the "([^"]*)" asset should appear in the content editor$/ do |asset_type|
63
+ within_frame('node_body_ifr') do
64
+ page.should have_css("#tinymce img[src^='/media/']")
65
+ end
66
+ end