cardboard_cms 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -0
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +47 -42
  5. data/README.md +12 -2
  6. data/app/assets/javascripts/cardboard/admin.js +1 -1
  7. data/app/controllers/pages_controller.rb +3 -35
  8. data/app/controllers/url_controller.rb +33 -0
  9. data/app/decorators/controllers/application_controller_decorator.rb +3 -1
  10. data/app/helpers/cardboard/public_helper.rb +1 -1
  11. data/app/helpers/cardboard/resource_helper.rb +6 -0
  12. data/app/models/cardboard/field.rb +2 -1
  13. data/app/models/cardboard/field/rich_text.rb +5 -5
  14. data/app/models/cardboard/page.rb +30 -72
  15. data/app/models/cardboard/setting.rb +0 -2
  16. data/app/models/cardboard/template.rb +5 -0
  17. data/app/models/cardboard/url.rb +91 -0
  18. data/app/views/cardboard/pages/_sidebar.html.slim +1 -1
  19. data/app/views/layouts/cardboard/_main_topbar.html.slim +1 -1
  20. data/cardboard.gemspec +4 -2
  21. data/config/routes.rb +3 -14
  22. data/db/migrate/1_create_cardboard.rb +13 -4
  23. data/lib/cardboard/concerns/url_concern.rb +29 -0
  24. data/lib/cardboard/constraints/page_constraint.rb +7 -0
  25. data/lib/cardboard/dynamic_router.rb +34 -0
  26. data/lib/cardboard/engine.rb +3 -1
  27. data/lib/cardboard/helpers/content_for_in_controllers.rb +23 -0
  28. data/lib/cardboard/helpers/seed.rb +17 -10
  29. data/lib/cardboard/version.rb +1 -1
  30. data/lib/generators/cardboard/resource/resource_generator.rb +2 -2
  31. data/lib/generators/cardboard/resource/templates/slim/edit.html.slim +1 -1
  32. data/lib/generators/cardboard/resource/templates/slim/new.html.slim +1 -1
  33. data/test/dummy/app/controllers/blog_controller.rb +2 -0
  34. data/test/dummy/app/views/blog/index.html.slim +1 -0
  35. data/test/dummy/app/views/layouts/application.html.slim +1 -0
  36. data/test/dummy/app/views/pages/about_us.html.slim +1 -0
  37. data/test/dummy/app/views/pages/history.html.slim +3 -0
  38. data/test/dummy/app/views/{templates → pages}/home.html.slim +0 -0
  39. data/test/dummy/config/cardboard.yml +6 -2
  40. data/test/dummy/db/migrate/20140312180204_create_cardboard.rb +72 -0
  41. data/test/dummy/db/schema.rb +19 -6
  42. data/test/models/url_test.rb +11 -0
  43. metadata +32 -28
  44. data/.ruby-gemset +0 -1
  45. data/.ruby-version +0 -1
  46. data/app/views/cardboard/pages/_error.html.slim +0 -7
  47. data/app/views/cardboard/pages/_seo.html.slim +0 -6
  48. data/app/views/cardboard/pages/show.html.slim +0 -9
  49. data/test/dummy/app/views/templates/about-us.html.slim +0 -1
  50. data/test/dummy/test/fixtures/admins.yml +0 -7
  51. data/test/dummy/test/functional/admins_controller_test.rb +0 -49
  52. data/test/dummy/test/unit/admin_test.rb +0 -7
  53. data/test/dummy/test/unit/helpers/admins_helper_test.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0c9ba046a708dba52e5848d89dd284ee9bcec1e
4
- data.tar.gz: 5171f5d82832e70ff0ed47c8200a2539837561bd
3
+ metadata.gz: b6ac8ca5c27e3d52c4f2eaa544763dab9d1d0fa8
4
+ data.tar.gz: 0df3371e7810c9c5aafccc8a6baf0255c7186aa4
5
5
  SHA512:
6
- metadata.gz: 7e37d4374060af4c6cddc1ac86988f8bd6822b57213ae7cdbf46e7911ad2fe445fc0842f57c6a1e4f316ba42aaaacaba226fbdc2c2c646a32508151304a44e07
7
- data.tar.gz: f368b5dbcc53f777e18498b3c792336bb259b1447c98b4229290a018355cbd693211cacb68c9cbea421b8c1cedf1124550cba3bfd4b6db801fc9927c9c4e67ec
6
+ metadata.gz: 43fda20aa8dacdfa2b0b5999324d625683c9ca08540b37b2998b8fa9b5cf4881623b022a1b26e49ad6e90246eb62fda99e722ad466c026b57a11e124acd65037
7
+ data.tar.gz: 1b7f04cd4de2c51666f44cf3d7ac5937ffe31ef25147ccbdc96d25b3b8bbda296d4db58c5aeccf7a52855f168f7174a983afcee15f7710debe9fd636d4a786af
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.1
6
+ - rbx-2
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source "http://rubygems.org"
2
- ruby '2.0.0'
3
2
 
4
3
  # Declare your gem's dependencies in cardboard.gemspec.
5
4
  # Bundler will treat runtime dependencies like base dependencies, and
@@ -25,12 +24,13 @@ gem 'quiet_assets'
25
24
  gem 'better_errors'
26
25
  gem 'binding_of_caller'
27
26
  gem 'pry-rails'
28
- gem 'pry-debugger'
27
+ gem 'pry-byebug'
29
28
  gem 'uglifier'
30
29
 
31
30
  group :test do
32
31
  gem 'turn'
33
32
  gem 'simplecov'
33
+ gem 'rake'
34
34
  end
35
35
 
36
36
 
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cardboard_cms (0.2.2)
4
+ cardboard_cms (0.3.1)
5
5
  bootstrap-datepicker-rails
6
6
  bootstrap-sass (~> 2.2)
7
- bootstrap-wysihtml5-rails
7
+ bootstrap-wysihtml5-rails (~> 0.3.1.24)
8
8
  chronic
9
9
  cocoon (>= 1.2.0)
10
10
  coffee-rails
@@ -14,7 +14,7 @@ PATH
14
14
  gon
15
15
  inherited_resources (>= 1.4.1)
16
16
  jquery-rails
17
- jquery-ui-rails
17
+ jquery-ui-rails (~> 5.0.0)
18
18
  kaminari
19
19
  kaminari-bootstrap (~> 0.1.3)
20
20
  rack-cache
@@ -65,13 +65,16 @@ GEM
65
65
  erubis (>= 2.6.6)
66
66
  binding_of_caller (0.7.2)
67
67
  debug_inspector (>= 0.0.1)
68
- bootstrap-datepicker-rails (1.3.0.1)
68
+ bootstrap-datepicker-rails (1.3.0.2)
69
69
  railties (>= 3.0)
70
70
  bootstrap-sass (2.3.2.2)
71
71
  sass (~> 3.2)
72
- bootstrap-wysihtml5-rails (0.3.1.23)
72
+ bootstrap-wysihtml5-rails (0.3.1.24)
73
73
  railties (>= 3.0)
74
74
  builder (3.1.4)
75
+ byebug (2.7.0)
76
+ columnize (~> 0.3)
77
+ debugger-linecache (~> 1.2)
75
78
  capybara (2.1.0)
76
79
  mime-types (>= 1.16)
77
80
  nokogiri (>= 1.3.3)
@@ -79,25 +82,20 @@ GEM
79
82
  rack-test (>= 0.5.4)
80
83
  xpath (~> 2.0)
81
84
  chronic (0.10.2)
82
- cocoon (1.2.5)
85
+ cocoon (1.2.6)
83
86
  coderay (1.0.9)
84
87
  coffee-rails (4.0.1)
85
88
  coffee-script (>= 2.2.0)
86
89
  railties (>= 4.0.0, < 5.0)
87
- coffee-script (2.2.0)
90
+ coffee-script (2.3.0)
88
91
  coffee-script-source
89
92
  execjs
90
- coffee-script-source (1.7.0)
91
- columnize (0.3.6)
93
+ coffee-script-source (1.7.1)
94
+ columnize (0.8.9)
92
95
  daemons (1.1.9)
93
96
  database_cleaner (1.0.1)
94
97
  debug_inspector (0.0.2)
95
- debugger (1.6.1)
96
- columnize (>= 0.3.1)
97
- debugger-linecache (~> 1.2.0)
98
- debugger-ruby_core_source (~> 1.2.3)
99
98
  debugger-linecache (1.2.0)
100
- debugger-ruby_core_source (1.2.3)
101
99
  decorators (1.0.3)
102
100
  railties (>= 3.0.19, != 3.2.9, != 3.2.8, != 3.2.7, != 3.2.6, != 3.2.5, != 3.2.4, != 3.2.3, != 3.2.2, != 3.2.10, != 3.2.1, != 3.2.0, != 3.1.9, != 3.1.8, != 3.1.7, != 3.1.6, != 3.1.5, != 3.1.4, != 3.1.3, != 3.1.2, != 3.1.1, != 3.1.0)
103
101
  devise (3.0.2)
@@ -105,7 +103,7 @@ GEM
105
103
  orm_adapter (~> 0.1)
106
104
  railties (>= 3.2.6, < 5)
107
105
  warden (~> 1.2.3)
108
- dragonfly (1.0.3)
106
+ dragonfly (1.0.5)
109
107
  multi_json (~> 1.0)
110
108
  rack
111
109
  erubis (2.7.0)
@@ -124,9 +122,11 @@ GEM
124
122
  railties (>= 3.1.1)
125
123
  sass-rails (>= 3.1.1)
126
124
  formatador (0.2.4)
127
- gon (5.0.1)
125
+ gon (5.1.1)
128
126
  actionpack (>= 2.3.0)
129
127
  json
128
+ multi_json
129
+ request_store (>= 1.0.5)
130
130
  guard (1.8.2)
131
131
  formatador (>= 0.2.4)
132
132
  listen (>= 1.0.0)
@@ -141,16 +141,16 @@ GEM
141
141
  activesupport (>= 3.2, < 5)
142
142
  hike (1.2.3)
143
143
  i18n (0.6.4)
144
- inherited_resources (1.4.1)
144
+ inherited_resources (1.5.0)
145
145
  has_scope (~> 0.6.0.rc)
146
- responders (~> 1.0.0.rc)
146
+ responders (~> 1.0)
147
147
  jquery-rails (3.0.4)
148
148
  railties (>= 3.0, < 5.0)
149
149
  thor (>= 0.14, < 2.0)
150
- jquery-ui-rails (4.1.1)
151
- railties (>= 3.1.0)
150
+ jquery-ui-rails (5.0.0)
151
+ railties (>= 3.2.16)
152
152
  json (1.8.0)
153
- kaminari (0.15.1)
153
+ kaminari (0.16.1)
154
154
  actionpack (>= 3.0.0)
155
155
  activesupport (>= 3.0.0)
156
156
  kaminari-bootstrap (0.1.3)
@@ -190,16 +190,16 @@ GEM
190
190
  nokogiri (1.6.0)
191
191
  mini_portile (~> 0.5.0)
192
192
  orm_adapter (0.4.0)
193
- polyamorous (0.6.4)
193
+ polyamorous (1.0.0)
194
194
  activerecord (>= 3.0)
195
195
  polyglot (0.3.3)
196
196
  pry (0.9.12.2)
197
197
  coderay (~> 1.0.5)
198
198
  method_source (~> 0.8)
199
199
  slop (~> 3.4)
200
- pry-debugger (0.2.2)
201
- debugger (~> 1.3)
202
- pry (~> 0.9.10)
200
+ pry-byebug (1.3.2)
201
+ byebug (~> 2.7)
202
+ pry (~> 0.9.12)
203
203
  pry-rails (0.3.2)
204
204
  pry (>= 0.9.10)
205
205
  quiet_assets (1.0.2)
@@ -223,12 +223,14 @@ GEM
223
223
  rake (>= 0.8.7)
224
224
  thor (>= 0.18.1, < 2.0)
225
225
  rake (10.1.0)
226
- ranked-model (0.3)
226
+ ranked-model (0.4.0)
227
227
  activerecord (>= 3.1.12)
228
- ransack (1.1.0)
228
+ ransack (1.2.3)
229
229
  actionpack (>= 3.0)
230
230
  activerecord (>= 3.0)
231
- polyamorous (~> 0.6.0)
231
+ activesupport (>= 3.0)
232
+ i18n
233
+ polyamorous (~> 1.0.0)
232
234
  rb-fsevent (0.9.3)
233
235
  rb-inotify (0.9.0)
234
236
  ffi (>= 0.5.0)
@@ -236,26 +238,28 @@ GEM
236
238
  ffi (>= 0.5.0)
237
239
  rdoc (3.12.2)
238
240
  json (~> 1.4)
239
- responders (1.0.0)
241
+ request_store (1.0.7)
242
+ responders (1.1.0)
240
243
  railties (>= 3.2, < 5)
241
- sass (3.2.14)
242
- sass-rails (4.0.1)
244
+ sass (3.2.19)
245
+ sass-rails (4.0.3)
243
246
  railties (>= 4.0.0, < 5.0)
244
- sass (>= 3.1.10)
245
- sprockets-rails (~> 2.0.0)
247
+ sass (~> 3.2.0)
248
+ sprockets (~> 2.8, <= 2.11.0)
249
+ sprockets-rails (~> 2.0)
246
250
  sdoc (0.3.20)
247
251
  json (>= 1.1.3)
248
252
  rdoc (~> 3.10)
249
- select2-rails (3.5.2)
253
+ select2-rails (3.5.9)
250
254
  thor (~> 0.14)
251
- simple_form (3.0.1)
252
- actionpack (>= 4.0.0, < 4.1)
253
- activemodel (>= 4.0.0, < 4.1)
255
+ simple_form (3.0.2)
256
+ actionpack (~> 4.0)
257
+ activemodel (~> 4.0)
254
258
  simplecov (0.7.1)
255
259
  multi_json (~> 1.0)
256
260
  simplecov-html (~> 0.7.1)
257
261
  simplecov-html (0.7.1)
258
- slim (2.0.2)
262
+ slim (2.0.3)
259
263
  temple (~> 0.6.6)
260
264
  tilt (>= 1.3.3, < 2.1)
261
265
  slop (3.4.6)
@@ -269,8 +273,8 @@ GEM
269
273
  activesupport (>= 3.0)
270
274
  sprockets (~> 2.8)
271
275
  sqlite3 (1.3.7)
272
- stringex (2.2.0)
273
- temple (0.6.7)
276
+ stringex (2.5.2)
277
+ temple (0.6.8)
274
278
  thin (1.5.1)
275
279
  daemons (>= 1.0.9)
276
280
  eventmachine (>= 0.12.6)
@@ -282,7 +286,7 @@ GEM
282
286
  treetop (1.4.14)
283
287
  polyglot
284
288
  polyglot (>= 0.3.1)
285
- turbolinks (2.2.1)
289
+ turbolinks (2.2.2)
286
290
  coffee-rails
287
291
  turn (0.9.6)
288
292
  ansi
@@ -311,9 +315,10 @@ DEPENDENCIES
311
315
  letter_opener
312
316
  minitest-rails
313
317
  minitest-rails-capybara
314
- pry-debugger
318
+ pry-byebug
315
319
  pry-rails
316
320
  quiet_assets
321
+ rake
317
322
  rb-fsevent
318
323
  sdoc
319
324
  simplecov
data/README.md CHANGED
@@ -16,6 +16,10 @@ Cardboard is a simple CMS Engine for your Rails 4 applications.
16
16
 
17
17
  ![alt text](https://github.com/smashingboxes/cardboard/wiki/images/2a.jpg "screenshot1")
18
18
 
19
+
20
+ ## Updating from 0.2 -> 0.3
21
+ Some changes were made to the database. Before updating make sure to have a look at the [new migration](https://github.com/smashingboxes/cardboard/blob/master/db/migrate/1_create_cardboard.rb)
22
+
19
23
  ## Requirements
20
24
  * An authentication solution. For example, [here is what you need to do](https://github.com/plataformatec/devise#getting-started) to get `Devise` installed.
21
25
  * `imagemagick` (on mac do `brew install imagemagick`)
@@ -45,7 +49,7 @@ rake cardboard:seed
45
49
 
46
50
  ## Usage
47
51
  ### Get a page
48
- Add a file in your `app/views/templates` with filename matching the identifier of the page. Inside this file you can access the page with:
52
+ Add a file in your `app/views/pages` (or `app/views/templates`) with filename matching the identifier of the page. Inside this file you can access the page with:
49
53
  ```ruby
50
54
  current_page
51
55
  ```
@@ -104,7 +108,7 @@ pages:
104
108
  type: image
105
109
  required: true
106
110
  default: CrashTest.jpg
107
- pages:
111
+ templates:
108
112
  two_column:
109
113
  parts:
110
114
  main:
@@ -124,7 +128,10 @@ Key | Type | Default | Definition
124
128
  title | string | identifier | name of the page as shown in the nav bar
125
129
  position | integer | auto-increment | position of the page on the nav bar (the lowest position is the home page!)
126
130
  parent_id | string | nil | identifier of the parent page (used for nested pages)
131
+ controller_action | string | pages#identifier | go to a specific controller example "blog#index". In that case, the page identifier is passed in the params
127
132
 
133
+ #### Templates
134
+ Templates are declared exactly like pages. They allow for the creation of pages directly from the admin interface. One key difference between templates and pages is the location of the view files which will be under `app/views/templates`.
128
135
 
129
136
  #### Parts
130
137
  Each part sub-section starts with the name of it's unique identifier. This name is used to reference the part in the code an thus should not change throughout the life of the project.
@@ -173,6 +180,7 @@ Gem | Description
173
180
 
174
181
 
175
182
  ### Menu options
183
+ You can customize the menu for this resource by adding to the controller class:
176
184
  ```ruby
177
185
  menu label: "Test", priority: 1
178
186
  ```
@@ -182,6 +190,7 @@ You can also choose to remove a resource from the menu
182
190
  ```
183
191
 
184
192
  ### Sorting
193
+ You can customize the sorting for this resource by adding to the controller class:
185
194
  ```ruby
186
195
  default_order "name DESC" # default: 'updated_at desc'
187
196
  ```
@@ -281,6 +290,7 @@ In your controllers you may want to redirect to a specific page. You can do so w
281
290
  ```ruby
282
291
  page_path("identifier_for_this_page")
283
292
  page_url("identifier_for_this_page")
293
+ cardboard.edit_page_path(@page) #link to let your admins edit the page they see
284
294
  ```
285
295
 
286
296
 
@@ -3,7 +3,7 @@
3
3
  //
4
4
  //= require jquery
5
5
  //= require jquery_ujs
6
- //= require jquery.ui.sortable
6
+ //= require jquery-ui/sortable
7
7
  //= require cardboard/jquery.livesearch
8
8
  //= require turbolinks
9
9
  //= require bootstrap-button
@@ -1,35 +1,3 @@
1
- class PagesController < ApplicationController
2
- def show
3
- if current_page.nil?
4
- flash[:error] = "No root page! Make sure to add a page first"
5
- redirect_to cardboard.dashboard_path
6
- else
7
- if current_page.using_slug_backup?
8
- redirect_to current_page.url, status: :moved_permanently
9
- else
10
- # call controller hook
11
- self.send(current_page.identifier) if self.respond_to? current_page.identifier
12
-
13
- render "cardboard/pages/show", layout: @layout || "layouts/application"
14
- end
15
- end
16
- end
17
-
18
- private
19
-
20
- # def edit_link
21
- # cardboard.edit_page_path(@page)
22
- # end
23
- # helper_method :edit_link
24
-
25
- def current_page
26
- return @page unless @page.nil?
27
- @page = if params[:id].nil?
28
- Cardboard::Page.root
29
- else
30
- Cardboard::Page.find_by_url(params[:id])
31
- end
32
- @page || raise(ActionController::RoutingError.new("Page not found"))
33
- end
34
-
35
- end
1
+ class PagesController < UrlController
2
+ #Main app can overwrite to customize the actions per page
3
+ end
@@ -0,0 +1,33 @@
1
+ class UrlController < ApplicationController
2
+ around_filter :apply_some_cardboard_magic
3
+ include Cardboard::ContentForInControllers
4
+
5
+ private
6
+
7
+ def apply_some_cardboard_magic
8
+ if current_page.using_slug_backup?
9
+ redirect_to current_page.url, status: :moved_permanently
10
+ else
11
+ render_seo
12
+ yield
13
+ end
14
+ end
15
+
16
+ def render_seo
17
+ title = (current_page.meta_tags.delete("title") || current_page.meta_tags.delete(:title))
18
+ seo = ""
19
+ seo += "<title>#{Cardboard::Setting.company_name}#{" | " + title unless title.blank?}</title>"
20
+ seo += current_page.meta_tags.map{|key, value| "<meta name='#{key}' content='#{value}' />"}.join
21
+ content_for :seo, seo.html_safe
22
+ end
23
+
24
+ def current_page
25
+ return @cardboard_page unless @cardboard_page.nil?
26
+
27
+ @cardboard_page = if request.path == "/"
28
+ Cardboard::Page.root
29
+ else
30
+ Cardboard::Url.urlable_for(request.path)
31
+ end
32
+ end
33
+ end
@@ -3,7 +3,9 @@ ApplicationController.class_eval do
3
3
  # helper Cardboard::PublicHelper
4
4
 
5
5
  def current_page
6
- nil #this will be overwritten only for cardboard pages
6
+ #nil default for non cardboard pages
7
+ #overwritten otherwise by url controller
8
+ nil
7
9
  end
8
10
  helper_method :current_page
9
11
  end
@@ -3,7 +3,7 @@ module Cardboard
3
3
 
4
4
  def dragonfly_image_tag(image, options = {})
5
5
  return nil unless image
6
- size = options.delete(:size) || '125x125'
6
+ size = options.delete(:size) || '125x125>'
7
7
  image_tag image.thumb(size).url, options
8
8
  end
9
9
 
@@ -7,6 +7,12 @@ module Cardboard
7
7
  super(val, options)
8
8
  end
9
9
 
10
+ def dragonfly_image_tag(image, options = {})
11
+ return nil unless image
12
+ size = options.delete(:size) || '125x125>'
13
+ image_tag image.thumb(size).url, options
14
+ end
15
+
10
16
  # ActionView::Helpers::FormBuilder.class_eval do
11
17
  # def date_field(conf,opts = {})
12
18
  # options = opts.dup
@@ -60,7 +60,8 @@ module Cardboard
60
60
  end
61
61
 
62
62
  def required?
63
- required = self.object_with_field.template[self.identifier.to_sym][:required]
63
+ return false if (field_name = self.identifier.to_sym) == :company_name
64
+ required = self.object_with_field.template[field_name][:required]
64
65
  required = true if required.nil?
65
66
  required
66
67
  end