cadmus 0.5.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +35 -14
  3. data/Gemfile +3 -0
  4. data/README.md +89 -52
  5. data/Rakefile +33 -2
  6. data/app/helpers/cadmus/rendering_helper.rb +24 -0
  7. data/app/views/cadmus/layouts/_form.html.erb +11 -0
  8. data/app/views/cadmus/layouts/edit.html.erb +5 -0
  9. data/app/views/cadmus/layouts/index.html.erb +25 -0
  10. data/app/views/cadmus/layouts/new.html.erb +5 -0
  11. data/app/views/cadmus/pages/index.html.erb +2 -2
  12. data/app/views/cadmus/pages/show.html.erb +1 -1
  13. data/app/views/cadmus/partials/_form.html.erb +35 -0
  14. data/app/views/cadmus/partials/edit.html.erb +5 -0
  15. data/app/views/cadmus/partials/index.html.erb +25 -0
  16. data/app/views/cadmus/partials/new.html.erb +5 -0
  17. data/app/views/cadmus/partials/show.html.erb +4 -0
  18. data/bin/rake +16 -0
  19. data/cadmus.gemspec +2 -2
  20. data/lib/cadmus/concerns/controller_with_parent.rb +70 -0
  21. data/lib/cadmus/concerns/liquid_template_field.rb +33 -0
  22. data/lib/cadmus/concerns/model_with_parent.rb +14 -0
  23. data/lib/cadmus/concerns/other_class_accessor.rb +50 -0
  24. data/lib/cadmus/engine.rb +9 -0
  25. data/lib/cadmus/layout.rb +32 -0
  26. data/lib/cadmus/layouts_controller.rb +70 -0
  27. data/lib/cadmus/page.rb +29 -17
  28. data/lib/cadmus/{controller_extensions.rb → pages_controller.rb} +17 -59
  29. data/lib/cadmus/partial.rb +32 -0
  30. data/lib/cadmus/partial_file_system.rb +28 -0
  31. data/lib/cadmus/partials_controller.rb +70 -0
  32. data/lib/cadmus/renderers.rb +24 -22
  33. data/lib/cadmus/tags.rb +35 -0
  34. data/lib/cadmus/version.rb +1 -1
  35. data/lib/cadmus.rb +23 -4
  36. data/test/cadmus_test.rb +7 -0
  37. data/test/dummy/Rakefile +6 -0
  38. data/test/dummy/app/assets/config/manifest.js +4 -0
  39. data/test/dummy/app/assets/images/.keep +0 -0
  40. data/test/dummy/app/assets/javascripts/application.js +13 -0
  41. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  42. data/test/dummy/app/assets/javascripts/channels/.keep +0 -0
  43. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  44. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  45. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  46. data/test/dummy/app/controllers/application_controller.rb +3 -0
  47. data/test/dummy/app/controllers/concerns/.keep +0 -0
  48. data/test/dummy/app/helpers/application_helper.rb +2 -0
  49. data/test/dummy/app/jobs/application_job.rb +2 -0
  50. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  51. data/test/dummy/app/models/application_record.rb +3 -0
  52. data/test/dummy/app/models/concerns/.keep +0 -0
  53. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  54. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  55. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  56. data/test/dummy/bin/bundle +3 -0
  57. data/test/dummy/bin/rails +4 -0
  58. data/test/dummy/bin/rake +4 -0
  59. data/test/dummy/bin/setup +38 -0
  60. data/test/dummy/bin/update +29 -0
  61. data/test/dummy/bin/yarn +10 -0
  62. data/test/dummy/config/application.rb +18 -0
  63. data/test/dummy/config/boot.rb +5 -0
  64. data/test/dummy/config/cable.yml +10 -0
  65. data/test/dummy/config/database.yml +25 -0
  66. data/test/dummy/config/environment.rb +5 -0
  67. data/test/dummy/config/environments/development.rb +54 -0
  68. data/test/dummy/config/environments/production.rb +91 -0
  69. data/test/dummy/config/environments/test.rb +42 -0
  70. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  71. data/test/dummy/config/initializers/assets.rb +14 -0
  72. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  74. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  75. data/test/dummy/config/initializers/inflections.rb +16 -0
  76. data/test/dummy/config/initializers/mime_types.rb +4 -0
  77. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  78. data/test/dummy/config/locales/en.yml +33 -0
  79. data/test/dummy/config/puma.rb +56 -0
  80. data/test/dummy/config/routes.rb +3 -0
  81. data/test/dummy/config/secrets.yml +32 -0
  82. data/test/dummy/config/spring.rb +6 -0
  83. data/test/dummy/config.ru +5 -0
  84. data/test/dummy/db/development.sqlite3 +0 -0
  85. data/test/dummy/db/test.sqlite3 +0 -0
  86. data/test/dummy/lib/assets/.keep +0 -0
  87. data/test/dummy/log/.keep +0 -0
  88. data/test/dummy/log/development.log +5 -0
  89. data/test/dummy/package.json +5 -0
  90. data/test/dummy/public/404.html +67 -0
  91. data/test/dummy/public/422.html +67 -0
  92. data/test/dummy/public/500.html +66 -0
  93. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  94. data/test/dummy/public/apple-touch-icon.png +0 -0
  95. data/test/dummy/public/favicon.ico +0 -0
  96. data/test/test_helper.rb +15 -0
  97. metadata +154 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 25c8b4e53cfd255b409c868f3b8d713ee9ba529f
4
- data.tar.gz: 0d63afd6ffe03f07c80b2e9a6ff6acfd8285c429
2
+ SHA256:
3
+ metadata.gz: 976db2b31a6439bbd4be7c6d8b0cd262bc9a6d69e065770643904703e5a7ff89
4
+ data.tar.gz: fd4e5c8a7dd861bbac67b18aeb72f3b1c6ca5e0956334aa645c0eca019dfec5a
5
5
  SHA512:
6
- metadata.gz: fa374b8cf36fd744d00c382eb62b64f013b53b5ea9a2ce30df22f640b4bcd56e85e3f3d98da8c9b8393d26738c2c6dff32c610ed0f6cbd16b7fafcd741850b1f
7
- data.tar.gz: 6343c1b8a254081c5e2613665534af3cfda9a44837067b02c374916a87dc143a7ed975c1b4ac4c9a1ee7be35d249f13c03928033b93620c0b7d0ccbf32ec80ed
6
+ metadata.gz: d93ed1826c12119f410af33808a44c3f2bbf8e4215b3e8d0fd8c61792550db2feb4163faf8a3d8a4554dc1fc1a99ff3b91433d3effab8e546b4765f9c70ec643
7
+ data.tar.gz: 30b44dc40bc5698f5da0d23967c4a888fce8838e04d434329f0f5f776a2cd84f166aa6abaec6f0a583a645917aa1152ca79ff5ace04d6f0200870a49c21dd7da
data/CHANGELOG.md CHANGED
@@ -1,43 +1,64 @@
1
+ ## cadmus 0.7.1 (12-22-2021)
2
+
3
+ - Rails 7 compatibility fixes
4
+
5
+ ## cadmus 0.7.0 (09-19-2018)
6
+
7
+ - BREAKING CHANGE: Cadmus no longer mixes anything into `ActiveRecord::Base` when required; instead, models must explicitly include the mixins they need
8
+ - Layouts
9
+ - Partials
10
+ - Major internal refactors
11
+
12
+ ## cadmus 0.6.0 (04-08-2017)
13
+
14
+ - Expose a `{% page_url %}` tag, which outputs the URL to a page (for easier inter-page linking)
15
+ - Expose a Liquid register called `parent` from controllers that mix in `Cadmus::ControllerExtensions`, which contains the page parent (if present)
16
+ - Extract a mixin module called `Cadmus::Concerns::LiquidTemplateField`, which makes it easier to add Liquid templates to models
17
+
18
+ ## cadmus 0.5.3 (02-04-2017)
19
+
20
+ - Make it possible to make `liquid_assigns`, `liquid_filters` and `liquid_registers` private or protected methods in controllers and other Renderables.
21
+
1
22
  ## cadmus 0.5.2 (11-10-2016)
2
23
 
3
- * Rails 5 compatibility fixes
24
+ - Rails 5 compatibility fixes
4
25
 
5
26
  ## cadmus 0.5.1 (05-03-2015)
6
27
 
7
- * Support the sanitizer changes in Rails 4.2
28
+ - Support the sanitizer changes in Rails 4.2
8
29
 
9
30
  ## cadmus 0.5.0 (12-06-2013)
10
31
 
11
- * First release that requires Rails 4.0
12
- * Strong parameters compatibility by default
32
+ - First release that requires Rails 4.0
33
+ - Strong parameters compatibility by default
13
34
 
14
35
  ## cadmus 0.4.8 (07-16-2013)
15
36
 
16
- * Add license info to gemspec
37
+ - Add license info to gemspec
17
38
 
18
39
  ## cadmus 0.4.7 (07-15-2013)
19
40
 
20
- * Bugfix: don't try to use the parameters in the new action. This prevents us from raising errors unnecessarily for required params in Rails 4.
41
+ - Bugfix: don't try to use the parameters in the new action. This prevents us from raising errors unnecessarily for required params in Rails 4.
21
42
 
22
43
  ## cadmus 0.4.6 (07-15-2013)
23
44
 
24
- * Changes for Rails 4 compatibility:
25
- ** Allow PUT or PATCH for the update action
26
- ** Implement a page_params protected method in page controllers, which you can override to get strong_parameters support
45
+ - Changes for Rails 4 compatibility:
46
+ ** Allow PUT or PATCH for the update action
47
+ ** Implement a page_params protected method in page controllers, which you can override to get strong_parameters support
27
48
 
28
49
  ## cadmus 0.4.5 (03-04-2013)
29
50
 
30
- * Change all the other uses of ^ and $ in regexes to \A and \z
31
- * Change scope to use a lambda for Rails 4 compatibility
51
+ - Change all the other uses of ^ and $ in regexes to \A and \z
52
+ - Change scope to use a lambda for Rails 4 compatibility
32
53
 
33
54
  ## cadmus 0.4.4 (03-04-2013)
34
55
 
35
- * Change some uses of ^ and $ in regexes to \A and \z
56
+ - Change some uses of ^ and $ in regexes to \A and \z
36
57
 
37
58
  ## cadmus 0.4.3 (06-17-2012)
38
59
 
39
- * Add a cadmus:views generator to make view customization easier
60
+ - Add a cadmus:views generator to make view customization easier
40
61
 
41
62
  ## cadmus 0.4.2 (06-16-2012)
42
63
 
43
- * Make `cadmus_pages` route function work with no arguments
64
+ - Make `cadmus_pages` route function work with no arguments
data/Gemfile CHANGED
@@ -6,3 +6,6 @@ gemspec
6
6
  gem 'yard'
7
7
  gem 'redcarpet', '~> 1.0'
8
8
  gem 'github-markup'
9
+ gem 'rails', '>= 5.1'
10
+ gem 'sprockets-rails'
11
+ gem 'sqlite3'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Cadmus: an embeddable CMS for Rails
2
2
 
3
- Cadmus is an embeddable content management system for Rails 3 applications. It's based on [Liquid](http://liquidmarkup.org)
3
+ Cadmus is an embeddable content management system for Rails applications. It's based on [Liquid](http://liquidmarkup.org)
4
4
  and is designed to be small and unobtrusive.
5
5
 
6
6
  Cadmus doesn't define controllers or models itself, but rather, provides mixins to add CMS-like functionality to controllers
@@ -14,7 +14,7 @@ ORM you want instead of ActiveRecord.
14
14
 
15
15
  One additional feature is the ability for pages to have parents. A parent can be any model object. Page parent objects allow
16
16
  you to create separate "sections" of your site - for example, if you have a project-hosting application that includes multiple
17
- projects, each of which has its own separate space of CMS pages. (Page parents aren't intended for creating sub-pages -
17
+ projects, each of which has its own separate space of CMS pages. (Page parents aren't intended for creating sub-pages -
18
18
  instead, just use forward-slash characters in the page slug to simulate folders, and Cadmus will handle it.)
19
19
 
20
20
  ## Basic Installation
@@ -30,18 +30,19 @@ The next step is to create a Page model. Your app can have multiple Page models
30
30
  create one.
31
31
 
32
32
  rails generate model Page name:text slug:string content:text parent_id:integer parent_type:string
33
-
34
- You'll need to tweak the generated migration and model slightly. In the migration, after the `create_pages` block, add a
33
+
34
+ You'll need to tweak the generated migration and model slightly. In the migration, after the `create_pages` block, add a
35
35
  unique index on the parent and slug columns:
36
36
 
37
37
  ```ruby
38
38
  add_index :pages, [:parent_type, :parent_id, :slug], :unique => true
39
39
  ```
40
-
41
- And in the model, add a `cadmus_page` declaration:
40
+
41
+ And in the model, include `Cadmus::Page` and add a `cadmus_page` declaration:
42
42
 
43
43
  ```ruby
44
44
  class Page < ActiveRecord::Base
45
+ include Cadmus::Page
45
46
  cadmus_page
46
47
  end
47
48
  ```
@@ -51,43 +52,23 @@ You'll need a controller to deal with your pages. Here's a minimal example of o
51
52
  ```ruby
52
53
  class PagesController < ApplicationController
53
54
  include Cadmus::PagesController
54
-
55
- protected
56
- def page_class
57
- Page
58
- end
59
55
  end
60
56
  ```
61
57
 
62
- If you're on Rails 4 (or using the `strong_parameters` gem) you'll probably want to use forbidden attributes protection.
63
- Here's how you do that:
58
+ `Cadmus::PagesController` automatically adds the seven RESTful resource methods to your controller. It requires that you
59
+ define a `page_class` method that returns the class for pages it's dealing with. (This could potentially return different
60
+ classes depending on request parameters, if you need it to - or, you could also set up different controllers for different
61
+ types of page.)
64
62
 
65
- ```ruby
66
- class Page < ActiveRecord::Base
67
- include ActiveModel::ForbiddenAttributesProtection
68
- cadmus_page
69
- end
70
- ```
63
+ You'll also want to set up an initializer (probably in `config/initializers/cadmus.rb`) that will tell Cadmus how to generate URLs for pages. This might look like this:
71
64
 
72
65
  ```ruby
73
- class PagesController < ApplicationController
74
- include Cadmus::PagesController
75
-
76
- protected
77
- def page_params
78
- params.require(:page).permit(:name, :slug, :content)
79
- end
80
-
81
- def page_class
82
- Page
83
- end
66
+ Cadmus::Tags::PageUrl.define_page_path_method do |page_name, parent|
67
+ page_path(page_name, parent_id: parent)
84
68
  end
85
69
  ```
86
70
 
87
- `Cadmus::PagesController` automatically adds the seven RESTful resource methods to your controller. It requires that you
88
- define a `page_class` method that returns the class for pages it's dealing with. (This could potentially return different
89
- classes depending on request parameters, if you need it to - or, you could also set up different controllers for different
90
- types of page.)
71
+ Doing this will enable markup like this in page templates: `<a href="{% page_url my-other-page %}">My other page</a>`. The `{% page_url my-other-page %}` will be replaced with the actual URL for the page called `my-other-page`.
91
72
 
92
73
  Finally, you'll need to create routes for this controller. Cadmus provides a built-in helper for that:
93
74
 
@@ -96,7 +77,7 @@ MyApp::Application.routes.draw do
96
77
  cadmus_pages
97
78
  end
98
79
  ```
99
-
80
+
100
81
  This will create the following routes:
101
82
 
102
83
  * GET /pages => PagesController#index
@@ -109,15 +90,15 @@ This will create the following routes:
109
90
 
110
91
  ## Authorization Control
111
92
 
112
- The pages controller is where you'll need to hook into any authorization or authentication system your app might use.
93
+ The pages controller is where you'll need to hook into any authorization or authentication system your app might use.
113
94
  We use CanCan, so here's an example of how we do that:
114
95
 
115
96
  ```ruby
116
97
  class PagesController < ApplicationController
117
98
  include Cadmus::PagesController
118
-
99
+
119
100
  authorize_resource :page
120
-
101
+
121
102
  protected
122
103
  def page_class
123
104
  Page
@@ -130,7 +111,7 @@ class Ability
130
111
  def initialize(user)
131
112
  can :read, Page
132
113
  return unless user
133
-
114
+
134
115
  # in this example, we've added an owner_id column to our Page model
135
116
  can :manage, Page, :owner_id => user.id
136
117
  end
@@ -154,7 +135,7 @@ DugoutCoach::Application.routes.draw do
154
135
  resources :players
155
136
  resources :schedule
156
137
  end
157
-
138
+
158
139
  cadmus_pages # for global pages on your site
159
140
  end
160
141
  ```
@@ -177,20 +158,20 @@ end
177
158
  ```
178
159
 
179
160
  Now you have a way of separating team-specific pages from global pages on the site. The URLs for these pages might be,
180
- for example, http://dugoutcoach.net/teams/cosmonauts/directions, or
161
+ for example, http://dugoutcoach.net/teams/cosmonauts/directions, or
181
162
  http://dugoutcoach.net/teams/cosmonauts/promotions/free-hat-day (remember, Cadmus slugs can contain slashes). We'll
182
163
  now need a TeamPages controller to handle these:
183
164
 
184
165
  ```ruby
185
166
  class TeamPagesController < ApplicationController
186
167
  include Cadmus::PagesController
187
-
168
+
188
169
  self.page_parent_class = Team # page's parent is a Team
189
170
  self.page_parent_name = "team" # parent ID is in params[:team_id]
190
171
  self.find_parent_by = "slug" # parent ID is the Team's "slug" field rather than "id"
191
-
172
+
192
173
  authorize_resource :page
193
-
174
+
194
175
  protected
195
176
  def page_class
196
177
  Page
@@ -215,7 +196,7 @@ DugoutCoach::Application.routes.draw do
215
196
  resources :schedule
216
197
  cadmus_pages :controller => :team_pages, :shallow => true
217
198
  end
218
-
199
+
219
200
  cadmus_pages
220
201
  end
221
202
  ```
@@ -245,7 +226,7 @@ help them by providing them with a Liquid template variable they can use like so
245
226
 
246
227
  ```html
247
228
  <h1>We're the Cosmonauts!</h1>
248
-
229
+
249
230
  <p>Our uniform color this week is {{ team.uniform_color }}!</p>
250
231
  ```
251
232
 
@@ -254,19 +235,19 @@ To do this, you'll need to expose `team` as a Liquid assign variable:
254
235
  ```ruby
255
236
  class TeamPagesController < ApplicationController
256
237
  include Cadmus::PagesController
257
-
238
+
258
239
  self.page_parent_class = Team # page's parent is a Team
259
240
  self.page_parent_name = "team" # parent ID is in params[:team_id]
260
241
  self.find_parent_by = "slug" # parent ID is the Team's "slug" field rather than "id"
261
-
242
+
262
243
  authorize_resource :page
263
-
244
+
264
245
  protected
265
246
 
266
247
  def page_class
267
248
  Page
268
249
  end
269
-
250
+
270
251
  def liquid_assigns
271
252
  { :team => @page.parent }
272
253
  end
@@ -285,10 +266,66 @@ class Team < ActiveRecord::Base
285
266
  # everything else in your model...
286
267
  end
287
268
  ```
288
-
269
+
289
270
  You could also define a `to_liquid` method that returns a `Liquid::Drop` subclass for Teams, if you need to do things
290
271
  more complicated than just return data values.
291
272
 
273
+ ## Liquid Templates on Non-Page Models
274
+
275
+ Let's say you have another model in your app that you'd like to put a Liquid template on. For example, perhaps the baseball teams would like to send out a welcome email to their fans. You might create a `WelcomeEmail` model with a `content` field.
276
+
277
+ Cadmus provides a convenience mixin to let you make that field a Liquid template. You can use it like so:
278
+
279
+ ```ruby
280
+ class WelcomeEmail < ActiveRecord::Base
281
+ include Cadmus::Concerns::LiquidTemplateField
282
+
283
+ liquid_template_field :content_liquid_template, :content
284
+
285
+ belongs_to :team
286
+ end
287
+ ```
288
+
289
+ Now if you call `my_welcome_email.content_liquid_template`, you'll get a parsed `Liquid::Template` generated from the value of `my_welcome_email.content`. You could further make the WelcomeEmail into a `Cadmus::Renderable` to make it render the template:
290
+
291
+ ```ruby
292
+ class WelcomeEmail < ActiveRecord::Base
293
+ include Cadmus::Concerns::LiquidTemplateField
294
+ include Cadmus::Renderable
295
+
296
+ liquid_template_field :content_liquid_template, :content
297
+
298
+ belongs_to :team
299
+
300
+ def rendered_content
301
+ cadmus_renderer.render(content_liquid_template, :html)
302
+ end
303
+ end
304
+ ```
305
+
306
+ Presto! Now you can call `my_welcome_email.rendered_content`. Since `WelcomeEmail` includes `Cadmus::Renderable`, you can also define `liquid_assigns` to expose variables to the template, for example:
307
+
308
+ ```ruby
309
+ class WelcomeEmail < ActiveRecord::Base
310
+ include Cadmus::Concerns::LiquidTemplateField
311
+ include Cadmus::Renderable
312
+
313
+ liquid_template_field :content_liquid_template, :content
314
+
315
+ belongs_to :team
316
+
317
+ def rendered_content
318
+ cadmus_renderer.render(content_liquid_template, :html)
319
+ end
320
+
321
+ def liquid_assigns
322
+ { 'team' => team }
323
+ end
324
+ end
325
+ ```
326
+
327
+ And now the welcome email templates can include `{{ team.name }}` and any other things derived from the Team model they want.
328
+
292
329
  ## Copyright and Licensing
293
330
 
294
- Copyright &copy; 2011-2012 Gively, Inc. Cadmus is released under the MIT license. For more information, see the LICENSE file.
331
+ Copyright &copy; Gively, Inc. Cadmus is released under the MIT license. For more information, see the LICENSE file.
data/Rakefile CHANGED
@@ -1,2 +1,33 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Cadmus'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
@@ -0,0 +1,24 @@
1
+ module Cadmus::RenderingHelper
2
+ def render_cadmus_page_in_effective_layout(page)
3
+ page_content = cadmus_renderer.render(@page.liquid_template, :html)
4
+ cms_layout = @page.effective_cms_layout
5
+ render_in_cadmus_layout(page_content, cms_layout, 'page' => page)
6
+ end
7
+
8
+ def render_in_cadmus_layout(content, cms_layout, assigns = {})
9
+ if cms_layout
10
+ assigns = assigns.merge({ 'content_for_layout' => content })
11
+ if defined?(:liquid_assigns_for_layout)
12
+ assigns.reverse_merge!(liquid_assigns_for_layout(cms_layout))
13
+ end
14
+
15
+ cadmus_renderer.render(cms_layout.liquid_template, :html, assigns: assigns, registers: { 'parent' => cms_layout.parent })
16
+ else
17
+ content_for :content do
18
+ content
19
+ end
20
+
21
+ render template: 'layouts/application'
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ <div class="form-group">
2
+ <%= f.label :name %>
3
+ <%= f.text_field :name, class: 'form-control' %>
4
+ </div>
5
+
6
+ <div class="form-group">
7
+ <%= f.label :content %>
8
+ <%= f.text_area(:content, :style => "font-family: monospace; min-height: 40vh;", class: 'form-control') %>
9
+ </div>
10
+
11
+ <%= f.submit class: 'btn btn-primary' %>
@@ -0,0 +1,5 @@
1
+ <h1>Editing layout <%= @cms_layout.name %></h1>
2
+
3
+ <%= form_for @cms_layout, url: url_for(action: 'update', id: @cms_layout) do |f| %>
4
+ <%= render partial: 'cadmus/layouts/form', locals: { f: f } %>
5
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <h1>
2
+ <% if @cms_layout_parent && @cms_layout_parent.respond_to?(:name) -%>
3
+ Layouts in <%= @cms_layout_parent.name %>
4
+ <% else -%>
5
+ Layouts
6
+ <% end -%>
7
+ </h1>
8
+
9
+ <ul class="list-group mb-4">
10
+ <% @cms_layouts.each do |cms_layout| %>
11
+ <li class="list-group-item">
12
+ <div class="row w-100">
13
+ <div class="col">
14
+ <%= cms_layout.name %>
15
+ </div>
16
+ <div class="col text-right">
17
+ <%= link_to "Edit", url_for(action: 'edit', id: cms_layout), class: 'btn btn-secondary btn-sm' %>
18
+ <%= link_to "Delete", url_for(action: 'destroy', id: cms_layout), method: 'DELETE', "data-confirm" => "Are you sure you want to delete this layout?", class: 'btn btn-danger btn-sm' %>
19
+ </div>
20
+ </div>
21
+ </li>
22
+ <% end -%>
23
+ </ul>
24
+
25
+ <%= link_to "New layout", url_for(action: 'new'), class: 'btn btn-primary' %>
@@ -0,0 +1,5 @@
1
+ <h1>New layout</h1>
2
+
3
+ <%= form_for @cms_layout, url: url_for(action: 'create') do |f| %>
4
+ <%= render partial: 'cadmus/layouts/form', locals: { f: f } %>
5
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <h1>
2
- <% if @page_parent && @page_parent.respond_to?(:name) -%>
3
- <%= @page_parent.name %>
2
+ <% if @parent_model && @parent_model.respond_to?(:name) -%>
3
+ <%= @parent_model.name %>
4
4
  <% else -%>
5
5
  Pages
6
6
  <% end -%>
@@ -1 +1 @@
1
- <%= cadmus_renderer.render(@page.liquid_template, :html) %>
1
+ <%= render_in_page_layout @page %>
@@ -0,0 +1,35 @@
1
+ <% if f.object.errors.any? -%>
2
+ <div id="error_explanation">
3
+ <h2><%= pluralize(f.object.errors.count, "error") %> prohibited this partial from being saved:</h2>
4
+
5
+ <ul>
6
+ <% f.object.errors.full_messages.each do |message| -%>
7
+ <li><%= message %></li>
8
+ <% end -%>
9
+ </ul>
10
+ </div>
11
+ <% end -%>
12
+
13
+ <div class="form-group">
14
+ <%= f.label f.object.class.name_field %>
15
+ <%= f.text_field f.object.class.name_field, class: 'form-control' %>
16
+ </div>
17
+
18
+ <div class="form-group">
19
+ <%= f.label :content %>
20
+ <%= f.text_area(:content, :style => "font-family: monospace; min-height: 40vh;", class: 'form-control') %>
21
+ </div>
22
+
23
+ <%= f.submit class: 'btn btn-primary' %>
24
+
25
+ <p><b>Rendered html preview</b></p>
26
+ <div id="html-preview" style="border:1px solid; min-height: 10em;">
27
+ </div>
28
+ <br/><br/>
29
+
30
+ <%= javascript_include_tag "cadmus.previewablehtml.js" %>
31
+ <script type="text/javascript">
32
+ $(document).ready(function(){
33
+ $('.cadmus-previewable-html').cadmusPreviewableHtml();
34
+ });
35
+ </script>
@@ -0,0 +1,5 @@
1
+ <h1>Editing partial <%= @cms_partial.public_send(@cms_partial.class.name_field) %></h1>
2
+
3
+ <%= form_for @cms_partial, url: url_for(action: 'update', id: @cms_partial) do |f| %>
4
+ <%= render partial: 'cadmus/partials/form', locals: { f: f } %>
5
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <h1>
2
+ <% if @parent_model && @parent_model.respond_to?(:name) -%>
3
+ Partials in <%= @parent_model.name %>
4
+ <% else -%>
5
+ Partials
6
+ <% end -%>
7
+ </h1>
8
+
9
+ <ul class="list-group mb-4">
10
+ <% @cms_partials.each do |cms_partial| %>
11
+ <li class="list-group-item">
12
+ <div class="row w-100">
13
+ <div class="col">
14
+ <%= cms_partial.public_send(cms_partial.class.name_field) %>
15
+ </div>
16
+ <div class="col text-right">
17
+ <%= link_to "Edit", url_for(action: 'edit', id: cms_partial), class: 'btn btn-secondary btn-sm' %>
18
+ <%= link_to "Delete", url_for(action: 'destroy', id: cms_partial), method: 'DELETE', "data-confirm" => "Are you sure you want to delete this partial?", class: 'btn btn-danger btn-sm' %>
19
+ </div>
20
+ </div>
21
+ </li>
22
+ <% end -%>
23
+ </ul>
24
+
25
+ <%= link_to "New partial", url_for(action: 'new'), class: 'btn btn-primary' %>
@@ -0,0 +1,5 @@
1
+ <h1>New partial</h1>
2
+
3
+ <%= form_for @cms_partial, url: url_for(action: 'create') do |f| %>
4
+ <%= render partial: 'cadmus/partials/form', locals: { f: f } %>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <%= link_to 'Edit', edit_cms_partial_path(@cms_partial) %> |
4
+ <%= link_to 'Back', cms_partials_path %>
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/cadmus.gemspec CHANGED
@@ -9,13 +9,13 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = "http://github.com/gively/cadmus"
10
10
  gem.license = "MIT"
11
11
 
12
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) }
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  gem.name = "cadmus"
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = Cadmus::VERSION
18
18
 
19
- gem.add_dependency("rails", ">= 4.0.0")
19
+ gem.add_dependency("rails", ">= 5.0.0")
20
20
  gem.add_dependency("liquid")
21
21
  end