spree_content_chunks 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +219 -0
- data/LICENSE +26 -0
- data/README.md +51 -0
- data/Rakefile +31 -0
- data/Versionfile +5 -0
- data/app/assets/javascripts/admin/spree_content_chunks.js +1 -0
- data/app/assets/javascripts/store/spree_content_chunks.js +1 -0
- data/app/assets/stylesheets/admin/spree_content_chunks.css +3 -0
- data/app/assets/stylesheets/store/spree_content_chunks.css +3 -0
- data/app/controllers/admin/content_chunks_controller.rb +2 -0
- data/app/models/content_chunk.rb +11 -0
- data/app/overrides/content_chunks.rb +5 -0
- data/app/views/admin/content_chunks/_form.html.erb +34 -0
- data/app/views/admin/content_chunks/edit.html.erb +11 -0
- data/app/views/admin/content_chunks/index.html.erb +32 -0
- data/app/views/admin/content_chunks/new.html.erb +11 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20111230112420_create_content_chunks.rb +16 -0
- data/lib/generators/spree_content_chunks/install/install_generator.rb +29 -0
- data/lib/spree_content_chunks.rb +2 -0
- data/lib/spree_content_chunks/engine.rb +24 -0
- data/script/rails +7 -0
- data/spec/models/content_chunk_spec.rb +16 -0
- data/spec/spec_helper.rb +31 -0
- data/spree_content_chunks.gemspec +22 -0
- metadata +140 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'sqlite3'
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem 'rspec-rails', '= 2.6.1'
|
7
|
+
gem 'shoulda-matchers'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :cucumber do
|
11
|
+
gem 'cucumber-rails', '1.0.0'
|
12
|
+
gem 'database_cleaner', '= 0.6.7'
|
13
|
+
gem 'nokogiri'
|
14
|
+
gem 'capybara', '1.0.1'
|
15
|
+
end
|
16
|
+
|
17
|
+
if RUBY_VERSION < "1.9"
|
18
|
+
gem "ruby-debug"
|
19
|
+
else
|
20
|
+
gem "ruby-debug19"
|
21
|
+
end
|
22
|
+
|
23
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
spree_content_chunks (0.1)
|
5
|
+
spree_core (>= 0.70.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.1.3)
|
11
|
+
actionpack (= 3.1.3)
|
12
|
+
mail (~> 2.3.0)
|
13
|
+
actionpack (3.1.3)
|
14
|
+
activemodel (= 3.1.3)
|
15
|
+
activesupport (= 3.1.3)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
rack (~> 1.3.5)
|
20
|
+
rack-cache (~> 1.1)
|
21
|
+
rack-mount (~> 0.8.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.0.3)
|
24
|
+
activemerchant (1.17.0)
|
25
|
+
activesupport (>= 2.3.11)
|
26
|
+
braintree (>= 2.0.0)
|
27
|
+
builder (>= 2.0.0)
|
28
|
+
json (>= 1.5.1)
|
29
|
+
activemodel (3.1.3)
|
30
|
+
activesupport (= 3.1.3)
|
31
|
+
builder (~> 3.0.0)
|
32
|
+
i18n (~> 0.6)
|
33
|
+
activerecord (3.1.3)
|
34
|
+
activemodel (= 3.1.3)
|
35
|
+
activesupport (= 3.1.3)
|
36
|
+
arel (~> 2.2.1)
|
37
|
+
tzinfo (~> 0.3.29)
|
38
|
+
activeresource (3.1.3)
|
39
|
+
activemodel (= 3.1.3)
|
40
|
+
activesupport (= 3.1.3)
|
41
|
+
activesupport (3.1.3)
|
42
|
+
multi_json (~> 1.0)
|
43
|
+
acts_as_list (0.1.4)
|
44
|
+
arel (2.2.1)
|
45
|
+
braintree (2.13.1)
|
46
|
+
builder (>= 2.0.0)
|
47
|
+
builder (3.0.0)
|
48
|
+
capybara (1.0.1)
|
49
|
+
mime-types (>= 1.16)
|
50
|
+
nokogiri (>= 1.3.3)
|
51
|
+
rack (>= 1.0.0)
|
52
|
+
rack-test (>= 0.5.4)
|
53
|
+
selenium-webdriver (~> 2.0)
|
54
|
+
xpath (~> 0.1.4)
|
55
|
+
childprocess (0.2.4)
|
56
|
+
ffi (~> 1.0.6)
|
57
|
+
cocaine (0.2.1)
|
58
|
+
columnize (0.3.6)
|
59
|
+
cucumber (1.0.6)
|
60
|
+
builder (>= 2.1.2)
|
61
|
+
diff-lcs (>= 1.1.2)
|
62
|
+
gherkin (~> 2.4.18)
|
63
|
+
json (>= 1.4.6)
|
64
|
+
term-ansicolor (>= 1.0.6)
|
65
|
+
cucumber-rails (1.0.0)
|
66
|
+
capybara (>= 1.0.0)
|
67
|
+
cucumber (~> 1.0.0)
|
68
|
+
nokogiri (>= 1.4.4)
|
69
|
+
rack-test (>= 0.5.7)
|
70
|
+
database_cleaner (0.6.7)
|
71
|
+
deface (0.7.2)
|
72
|
+
nokogiri (~> 1.5.0)
|
73
|
+
rails (>= 3.0.9)
|
74
|
+
diff-lcs (1.1.3)
|
75
|
+
erubis (2.7.0)
|
76
|
+
faker (1.0.0)
|
77
|
+
i18n (~> 0.4)
|
78
|
+
ffi (1.0.11)
|
79
|
+
gherkin (2.4.21)
|
80
|
+
json (>= 1.4.6)
|
81
|
+
highline (1.6.2)
|
82
|
+
hike (1.2.1)
|
83
|
+
i18n (0.6.0)
|
84
|
+
jquery-rails (1.0.19)
|
85
|
+
railties (~> 3.0)
|
86
|
+
thor (~> 0.14)
|
87
|
+
json (1.6.4)
|
88
|
+
kaminari (0.13.0)
|
89
|
+
actionpack (>= 3.0.0)
|
90
|
+
activesupport (>= 3.0.0)
|
91
|
+
railties (>= 3.0.0)
|
92
|
+
linecache (0.46)
|
93
|
+
rbx-require-relative (> 0.0.4)
|
94
|
+
mail (2.3.0)
|
95
|
+
i18n (>= 0.4.0)
|
96
|
+
mime-types (~> 1.16)
|
97
|
+
treetop (~> 1.4.8)
|
98
|
+
meta_search (1.1.1)
|
99
|
+
actionpack (~> 3.1.0)
|
100
|
+
activerecord (~> 3.1.0)
|
101
|
+
activesupport (~> 3.1.0)
|
102
|
+
polyamorous (~> 0.5.0)
|
103
|
+
mime-types (1.17.2)
|
104
|
+
multi_json (1.0.4)
|
105
|
+
nested_set (1.6.8)
|
106
|
+
activerecord (>= 3.0.0)
|
107
|
+
railties (>= 3.0.0)
|
108
|
+
nokogiri (1.5.0)
|
109
|
+
paperclip (2.4.1)
|
110
|
+
activerecord (>= 2.3.0)
|
111
|
+
activesupport (>= 2.3.2)
|
112
|
+
cocaine (>= 0.0.2)
|
113
|
+
mime-types
|
114
|
+
polyamorous (0.5.0)
|
115
|
+
activerecord (~> 3.0)
|
116
|
+
polyglot (0.3.3)
|
117
|
+
rack (1.3.6)
|
118
|
+
rack-cache (1.1)
|
119
|
+
rack (>= 0.4)
|
120
|
+
rack-mount (0.8.3)
|
121
|
+
rack (>= 1.0.0)
|
122
|
+
rack-ssl (1.3.2)
|
123
|
+
rack
|
124
|
+
rack-test (0.6.1)
|
125
|
+
rack (>= 1.0)
|
126
|
+
rails (3.1.3)
|
127
|
+
actionmailer (= 3.1.3)
|
128
|
+
actionpack (= 3.1.3)
|
129
|
+
activerecord (= 3.1.3)
|
130
|
+
activeresource (= 3.1.3)
|
131
|
+
activesupport (= 3.1.3)
|
132
|
+
bundler (~> 1.0)
|
133
|
+
railties (= 3.1.3)
|
134
|
+
railties (3.1.3)
|
135
|
+
actionpack (= 3.1.3)
|
136
|
+
activesupport (= 3.1.3)
|
137
|
+
rack-ssl (~> 1.3.2)
|
138
|
+
rake (>= 0.8.7)
|
139
|
+
rdoc (~> 3.4)
|
140
|
+
thor (~> 0.14.6)
|
141
|
+
rake (0.9.2.2)
|
142
|
+
rbx-require-relative (0.0.5)
|
143
|
+
rd_find_by_param (0.1.1)
|
144
|
+
activerecord (~> 3.0)
|
145
|
+
activesupport (~> 3.0)
|
146
|
+
rd_resource_controller (1.0.1)
|
147
|
+
rdoc (3.12)
|
148
|
+
json (~> 1.4)
|
149
|
+
rspec (2.6.0)
|
150
|
+
rspec-core (~> 2.6.0)
|
151
|
+
rspec-expectations (~> 2.6.0)
|
152
|
+
rspec-mocks (~> 2.6.0)
|
153
|
+
rspec-core (2.6.4)
|
154
|
+
rspec-expectations (2.6.0)
|
155
|
+
diff-lcs (~> 1.1.2)
|
156
|
+
rspec-mocks (2.6.0)
|
157
|
+
rspec-rails (2.6.1)
|
158
|
+
actionpack (~> 3.0)
|
159
|
+
activesupport (~> 3.0)
|
160
|
+
railties (~> 3.0)
|
161
|
+
rspec (~> 2.6.0)
|
162
|
+
ruby-debug (0.10.4)
|
163
|
+
columnize (>= 0.1)
|
164
|
+
ruby-debug-base (~> 0.10.4.0)
|
165
|
+
ruby-debug-base (0.10.4)
|
166
|
+
linecache (>= 0.3)
|
167
|
+
rubyzip (0.9.5)
|
168
|
+
selenium-webdriver (2.15.0)
|
169
|
+
childprocess (>= 0.2.1)
|
170
|
+
ffi (~> 1.0.9)
|
171
|
+
multi_json (~> 1.0.4)
|
172
|
+
rubyzip
|
173
|
+
shoulda-matchers (1.0.0)
|
174
|
+
spree_core (0.70.3)
|
175
|
+
activemerchant (= 1.17.0)
|
176
|
+
acts_as_list (= 0.1.4)
|
177
|
+
deface (>= 0.7.0)
|
178
|
+
faker (= 1.0.0)
|
179
|
+
highline (= 1.6.2)
|
180
|
+
jquery-rails (>= 1.0.14)
|
181
|
+
kaminari (>= 0.12.4)
|
182
|
+
meta_search (= 1.1.1)
|
183
|
+
nested_set (= 1.6.8)
|
184
|
+
paperclip (= 2.4.1)
|
185
|
+
rails (>= 3.1.1, <= 3.1.3)
|
186
|
+
rd_find_by_param (= 0.1.1)
|
187
|
+
rd_resource_controller
|
188
|
+
state_machine (= 1.0.1)
|
189
|
+
stringex (= 1.0.3)
|
190
|
+
sprockets (2.0.3)
|
191
|
+
hike (~> 1.2)
|
192
|
+
rack (~> 1.0)
|
193
|
+
tilt (!= 1.3.0, ~> 1.1)
|
194
|
+
sqlite3 (1.3.5)
|
195
|
+
state_machine (1.0.1)
|
196
|
+
stringex (1.0.3)
|
197
|
+
term-ansicolor (1.0.7)
|
198
|
+
thor (0.14.6)
|
199
|
+
tilt (1.3.3)
|
200
|
+
treetop (1.4.10)
|
201
|
+
polyglot
|
202
|
+
polyglot (>= 0.3.1)
|
203
|
+
tzinfo (0.3.31)
|
204
|
+
xpath (0.1.4)
|
205
|
+
nokogiri (~> 1.3)
|
206
|
+
|
207
|
+
PLATFORMS
|
208
|
+
ruby
|
209
|
+
|
210
|
+
DEPENDENCIES
|
211
|
+
capybara (= 1.0.1)
|
212
|
+
cucumber-rails (= 1.0.0)
|
213
|
+
database_cleaner (= 0.6.7)
|
214
|
+
nokogiri
|
215
|
+
rspec-rails (= 2.6.1)
|
216
|
+
ruby-debug
|
217
|
+
shoulda-matchers
|
218
|
+
spree_content_chunks!
|
219
|
+
sqlite3
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2011 One Design Company
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
SpreeContentChunks
|
2
|
+
==================
|
3
|
+
|
4
|
+
A Spree extension for managing tiny bits of content.
|
5
|
+
By default, the content bits have a title, body, and optional image.
|
6
|
+
|
7
|
+
|
8
|
+
Installation
|
9
|
+
============
|
10
|
+
|
11
|
+
Include the following in your Gemfile (after the line that includes Spree):
|
12
|
+
|
13
|
+
gem spree_content_chunks, :git => git://github.com/onedesign/spree_content_chunks.git
|
14
|
+
|
15
|
+
Then run:
|
16
|
+
|
17
|
+
bundle install
|
18
|
+
rake railties:install:migrations FROM=spree_content_chunks
|
19
|
+
rake db:migrate
|
20
|
+
|
21
|
+
|
22
|
+
Usage
|
23
|
+
=====
|
24
|
+
|
25
|
+
A section will be added to Spree's configuration page, and can be accessed at
|
26
|
+
[site_root]/admin/content_chunks.
|
27
|
+
|
28
|
+
Use the 'kind' field to distinguish different types of content; e.g. 'Hero' or
|
29
|
+
'Call to Action'.
|
30
|
+
|
31
|
+
To use the content chunks in your store (say, to display a series of hero images):
|
32
|
+
|
33
|
+
<div id="hero_images">
|
34
|
+
<% ContentChunk.where(:kind => 'Hero').each do |chunk| %>
|
35
|
+
<div class="hero" style="background-image:url(<%= chunk.image.url %>)">
|
36
|
+
<h3><%= chunk.title %></h3>
|
37
|
+
<div><%= chunk.body %></div>
|
38
|
+
</div>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
|
42
|
+
Testing
|
43
|
+
-------
|
44
|
+
|
45
|
+
Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test
|
46
|
+
app for the specs to run against.
|
47
|
+
|
48
|
+
$ bundle exec rake test_app
|
49
|
+
$ bundle exec rspec spec
|
50
|
+
|
51
|
+
Copyright (c) 2011 One Design Company, released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/packagetask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
require 'spree_core/testing_support/common_rake'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new
|
10
|
+
Cucumber::Rake::Task.new
|
11
|
+
|
12
|
+
task :default => [:spec, :cucumber ]
|
13
|
+
|
14
|
+
spec = eval(File.read('spree_content_chunks.gemspec'))
|
15
|
+
|
16
|
+
Gem::PackageTask.new(spec) do |p|
|
17
|
+
p.gem_spec = spec
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Release to gemcutter"
|
21
|
+
task :release => :package do
|
22
|
+
require 'rake/gemcutter'
|
23
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
24
|
+
Rake::Task['gem:push'].invoke
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Generates a dummy app for testing"
|
28
|
+
task :test_app do
|
29
|
+
ENV['LIB_NAME'] = 'spree_content_chunks'
|
30
|
+
Rake::Task['common:test_app'].invoke
|
31
|
+
end
|
data/Versionfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ContentChunk < ActiveRecord::Base
|
2
|
+
has_attached_file :image,
|
3
|
+
:url => "/spree/content_chunks/:id/main/:style/:basename.:extension",
|
4
|
+
:path => ":rails_root/public/spree/content_chunks/:id/main/:style/:basename.:extension"
|
5
|
+
|
6
|
+
attr_accessor :delete_image
|
7
|
+
before_validation { image.clear if '1' == delete_image }
|
8
|
+
|
9
|
+
validates :title, :presence => true
|
10
|
+
validates :kind, :presence => true
|
11
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Deface::Override.new(:virtual_path => "admin/configurations/index",
|
2
|
+
:name => "content_chunks_configuration_line",
|
3
|
+
:insert_bottom => "[data-hook='admin_configurations_menu']",
|
4
|
+
:text => "<%= configurations_menu_item('Content Chunks', admin_content_chunks_path, 'Manage bits of content (like Hero Images and Calls to Action)') %>",
|
5
|
+
:disabled => false)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<table data-hook="admin_content_chunk_form">
|
2
|
+
<tr data-hook="title">
|
3
|
+
<td><label>Title</label></td>
|
4
|
+
<td><%= f.text_field :title %></td>
|
5
|
+
</tr>
|
6
|
+
<tr data-hook="body">
|
7
|
+
<td><label>Body</label></td>
|
8
|
+
<td><%= f.text_area :body %></td>
|
9
|
+
</tr>
|
10
|
+
<tr data-hook="link">
|
11
|
+
<td><label>Link</label></td>
|
12
|
+
<td><%= f.text_field :link %></td>
|
13
|
+
</tr>
|
14
|
+
<tr data-hook="image">
|
15
|
+
<td><label>Image</label></td>
|
16
|
+
<td><%= f.file_field :image %></td>
|
17
|
+
<% if !@content_chunk.new_record? && @content_chunk.image? %>
|
18
|
+
<td>
|
19
|
+
<%= image_tag(@content_chunk.image.url) %><br>
|
20
|
+
<%= f.check_box :delete_image %> <label for="content_chunk_delete_image">Delete this image</label>
|
21
|
+
</td>
|
22
|
+
<% end %>
|
23
|
+
</tr>
|
24
|
+
<tr data-hook="image_position">
|
25
|
+
<td><label>Image Position</label></td>
|
26
|
+
<td>
|
27
|
+
<%= f.text_field :image_position %><br>
|
28
|
+
</td>
|
29
|
+
</tr>
|
30
|
+
<tr data-hook="kind">
|
31
|
+
<td><label>Kind</label></td>
|
32
|
+
<td><%= f.text_field :kind %></td>
|
33
|
+
</tr>
|
34
|
+
</table>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render :partial => 'admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<h1>Editing Content Chunk</h1>
|
4
|
+
<%= render "shared/error_messages", :target => @content_chunk %>
|
5
|
+
<%= form_for(@content_chunk, :url => object_url, :html => { :method => :put, :multipart => true }) do |f| %>
|
6
|
+
<%= render :partial => "form", :locals => { :f => f } %>
|
7
|
+
<p class="form-buttons" data-hook="form-buttons">
|
8
|
+
<%= button t('update') %>
|
9
|
+
<%= t("or") %> <%= link_to t("actions.cancel"), admin_content_chunks_url %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%= render :partial => 'admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<div class='toolbar' data-hook="toolbar">
|
4
|
+
<ul class='actions'>
|
5
|
+
<li>
|
6
|
+
<%= button_link_to "New Content Chunk", new_object_url, :icon => 'add', :id => 'admin_new_content_chunk_link' %>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
<br class='clear' />
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<h1>Content Chunks</h1>
|
13
|
+
|
14
|
+
<table class="index" id="content_chunks_listing">
|
15
|
+
<thead data-hook="admin_content_chunks_index_headers">
|
16
|
+
<th>Title</th>
|
17
|
+
<th>Kind</th>
|
18
|
+
<th><%= t("action") %></th>
|
19
|
+
</thead>
|
20
|
+
<tbody>
|
21
|
+
<% @content_chunks.each do |content_chunk|%>
|
22
|
+
<tr id="<%= dom_id content_chunk %>" data-hook="admin_content_chunks_index_rows">
|
23
|
+
<td><%= content_chunk.title %></td>
|
24
|
+
<td><%= content_chunk.kind %></td>
|
25
|
+
<td>
|
26
|
+
<%= link_to_edit content_chunk, :class => 'edit' %>
|
27
|
+
<%= link_to_delete content_chunk %>
|
28
|
+
</td>
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
31
|
+
</tbody>
|
32
|
+
</table>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render :partial => 'admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<h1>New Content Chunk</h1>
|
4
|
+
<%= render "shared/error_messages", :target => @content_chunk %>
|
5
|
+
<%= form_for(@content_chunk, :url => collection_url, :html => { :multipart => true }) do |f| %>
|
6
|
+
<%= render :partial => "form", :locals => { :f => f } %>
|
7
|
+
<p class="form-buttons" data-hook="buttons">
|
8
|
+
<%= button t('continue') %>
|
9
|
+
<%= t("or") %> <%= link_to t("actions.cancel"), admin_content_chunks_url %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateContentChunks < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :content_chunks do |t|
|
4
|
+
t.string :title
|
5
|
+
t.text :body
|
6
|
+
t.string :link
|
7
|
+
t.string :kind
|
8
|
+
t.string :image_file_name
|
9
|
+
t.string :image_content_type
|
10
|
+
t.integer :image_file_size
|
11
|
+
t.datetime :image_updated_at
|
12
|
+
t.string :image_position
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SpreeContentChunk
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_javascripts
|
6
|
+
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_content_chunks\n"
|
7
|
+
append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_content_chunks\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_stylesheets
|
11
|
+
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_content_chunks\n", :before => /\*\//, :verbose => true
|
12
|
+
inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_content_chunks\n", :before => /\*\//, :verbose => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_migrations
|
16
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_content_chunks'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_migrations
|
20
|
+
res = ask "Would you like to run the migrations now? [Y/n]"
|
21
|
+
if res == "" || res.downcase == "y"
|
22
|
+
run 'bundle exec rake db:migrate'
|
23
|
+
else
|
24
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SpreeContentChunk
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name 'spree_content_chunks'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
|
18
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.to_prepare &method(:activate).to_proc
|
23
|
+
end
|
24
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
|
5
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
6
|
+
load File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
7
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ContentChunk do
|
4
|
+
it { should validate_presence_of(:title) }
|
5
|
+
|
6
|
+
it { should validate_presence_of(:kind) }
|
7
|
+
|
8
|
+
it { should allow_value(nil).for(:image_position) }
|
9
|
+
it { should allow_value('').for(:image_position) }
|
10
|
+
it { should allow_value('Left').for(:image_position) }
|
11
|
+
it { should allow_value('Right').for(:image_position) }
|
12
|
+
it { should allow_value('Bottom').for(:image_position) }
|
13
|
+
|
14
|
+
it { should respond_to :delete_image }
|
15
|
+
it { should respond_to :delete_image= }
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
|
5
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
6
|
+
|
7
|
+
|
8
|
+
require 'rspec/rails'
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
# == Mock Framework
|
16
|
+
#
|
17
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
18
|
+
#
|
19
|
+
# config.mock_with :mocha
|
20
|
+
# config.mock_with :flexmock
|
21
|
+
# config.mock_with :rr
|
22
|
+
config.mock_with :rspec
|
23
|
+
|
24
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
25
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
26
|
+
|
27
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
28
|
+
# examples within a transaction, remove the following line or assign false
|
29
|
+
# instead of true.
|
30
|
+
config.use_transactional_fixtures = true
|
31
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_content_chunks'
|
5
|
+
s.version = '0.1'
|
6
|
+
s.summary = 'Spree extension for managing small chunks of content (e.g. calls to action, hero images)'
|
7
|
+
s.required_ruby_version = '>= 1.8.7'
|
8
|
+
|
9
|
+
s.authors = ['AJ Schuster']
|
10
|
+
s.email = ['aj@onedesigncompany.com']
|
11
|
+
s.homepage = 'http://github.com/onedesign/spree_content_chunks'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.require_path = 'lib'
|
16
|
+
s.requirements << 'none'
|
17
|
+
|
18
|
+
s.add_dependency 'spree_core', '>= 0.70.3'
|
19
|
+
s.add_development_dependency 'rspec-rails'
|
20
|
+
s.add_development_dependency 'shoulda-matchers'
|
21
|
+
end
|
22
|
+
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_content_chunks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- AJ Schuster
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-12-30 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spree_core
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 257
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 70
|
32
|
+
- 3
|
33
|
+
version: 0.70.3
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: shoulda-matchers
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
description:
|
65
|
+
email:
|
66
|
+
- aj@onedesigncompany.com
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files: []
|
72
|
+
|
73
|
+
files:
|
74
|
+
- .gitignore
|
75
|
+
- .rspec
|
76
|
+
- Gemfile
|
77
|
+
- Gemfile.lock
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- Versionfile
|
82
|
+
- app/assets/javascripts/admin/spree_content_chunks.js
|
83
|
+
- app/assets/javascripts/store/spree_content_chunks.js
|
84
|
+
- app/assets/stylesheets/admin/spree_content_chunks.css
|
85
|
+
- app/assets/stylesheets/store/spree_content_chunks.css
|
86
|
+
- app/controllers/admin/content_chunks_controller.rb
|
87
|
+
- app/models/content_chunk.rb
|
88
|
+
- app/overrides/content_chunks.rb
|
89
|
+
- app/views/admin/content_chunks/_form.html.erb
|
90
|
+
- app/views/admin/content_chunks/edit.html.erb
|
91
|
+
- app/views/admin/content_chunks/index.html.erb
|
92
|
+
- app/views/admin/content_chunks/new.html.erb
|
93
|
+
- config/routes.rb
|
94
|
+
- db/migrate/20111230112420_create_content_chunks.rb
|
95
|
+
- lib/generators/spree_content_chunks/install/install_generator.rb
|
96
|
+
- lib/spree_content_chunks.rb
|
97
|
+
- lib/spree_content_chunks/engine.rb
|
98
|
+
- script/rails
|
99
|
+
- spec/models/content_chunk_spec.rb
|
100
|
+
- spec/spec_helper.rb
|
101
|
+
- spree_content_chunks.gemspec
|
102
|
+
has_rdoc: true
|
103
|
+
homepage: http://github.com/onedesign/spree_content_chunks
|
104
|
+
licenses: []
|
105
|
+
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 57
|
117
|
+
segments:
|
118
|
+
- 1
|
119
|
+
- 8
|
120
|
+
- 7
|
121
|
+
version: 1.8.7
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
requirements:
|
132
|
+
- none
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.4.2
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Spree extension for managing small chunks of content (e.g. calls to action, hero images)
|
138
|
+
test_files:
|
139
|
+
- spec/models/content_chunk_spec.rb
|
140
|
+
- spec/spec_helper.rb
|