ecm_cms 0.0.13.pre → 1.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,7 @@ class Ecm::Cms::PageController < ApplicationController
8
8
  # avoid error 500 on missing template
9
9
  rescue_from ActionView::MissingTemplate do
10
10
  respond_to do |format|
11
- # format.html { render(:file => "#{Rails.root}/public/404.html", :layout => false, :status => 404) }
12
- format.html { render(:file => "#{Rails.root}/public/404", :formats => [:html], :status => 404, :layout => false) }
11
+ format.html { render(:file => "#{Rails.root}/public/404", :formats => [:html], :layout => false, :status => 404) }
13
12
  format.xml { head :not_found }
14
13
  format.any { head :not_found }
15
14
  end
@@ -0,0 +1,21 @@
1
+ module Ecm::Cms
2
+ class ContentBox < ActiveRecord::Base
3
+ self.table_name = 'ecm_cms_content_boxes'
4
+
5
+ # associations
6
+ has_many :ecm_cms_page_content_blocks, :class_name => 'Page::ContentBlock',
7
+ :foreign_key => 'ecm_cms_content_box_id'
8
+
9
+ # attributes
10
+ attr_accessible :name
11
+
12
+ # validations
13
+ validates :name, :presence => true,
14
+ :uniqueness => true
15
+
16
+ def ecm_cms_page_content_blocks_count
17
+ ecm_cms_page_content_blocks.count
18
+ end
19
+ end
20
+ end
21
+
@@ -22,3 +22,4 @@ class Ecm::Cms::Navigation < ActiveRecord::Base
22
22
  "#{self.name} (#{self.locale})"
23
23
  end
24
24
  end
25
+
@@ -0,0 +1,24 @@
1
+ module Ecm::Cms
2
+ class Page::ContentBlock < ActiveRecord::Base
3
+ # associations
4
+ belongs_to :ecm_cms_content_box, :class_name => 'ContentBox',
5
+ :foreign_key => 'ecm_cms_content_box_id'
6
+ belongs_to :ecm_cms_page, :class_name => 'Ecm::Cms::Page',
7
+ :foreign_key => 'ecm_cms_page_id'
8
+
9
+ # attributes
10
+ attr_accessible :body,
11
+ :ecm_cms_content_box_id
12
+
13
+ # validations
14
+ validates :body, :presence => true
15
+ validates :ecm_cms_content_box, :presence => true
16
+ validates :ecm_cms_page, :presence => true
17
+ # validates :ecm_cms_page, :existence => true
18
+
19
+ def content_box_name
20
+ ecm_cms_content_box.name
21
+ end
22
+ end
23
+ end
24
+
@@ -1,40 +1,48 @@
1
- class Ecm::Cms::Page < ActiveRecord::Base
2
- self.table_name = 'ecm_cms_pages'
3
-
4
- # add shared behaviour for database backed templates
5
- include Ecm::Cms::DatabaseTemplate
6
-
7
- # associations
8
- has_many :ecm_cms_navigation_items,
9
- :class_name => 'Ecm::Cms::NavigationItem',
10
- :dependent => :nullify,
11
- :foreign_key => 'ecm_cms_page_id'
12
-
13
- # attributes
14
- attr_accessible :basename,
15
- :body,
16
- :ecm_cms_folder_id,
17
- :ecm_cms_navigation_item_ids,
18
- :format,
19
- :handler,
20
- :layout,
21
- :locale,
22
- :meta_description,
23
- :pathname,
24
- :title
25
-
26
- # callbacks
27
- after_save :touch_navigation_items # , :if => Proc.new { |page| page.locale_changed? || page.pathname_changed? || page.basename_changed? }
28
-
29
- # validations
30
- validates :title, :presence => true
31
-
32
- def home_page?
33
- return self.pathname == '/' && self.basename == 'home'
34
- end
35
-
36
- def touch_navigation_items
37
- self.ecm_cms_navigation_items.map(&:update_url_form_page!)
1
+ module Ecm::Cms
2
+ class Page < ActiveRecord::Base
3
+ self.table_name = 'ecm_cms_pages'
4
+
5
+ # add shared behaviour for database backed templates
6
+ include DatabaseTemplate
7
+
8
+ # associations
9
+ has_many :ecm_cms_navigation_items,
10
+ :class_name => 'NavigationItem',
11
+ :dependent => :nullify,
12
+ :foreign_key => 'ecm_cms_page_id'
13
+ has_many :ecm_cms_page_content_blocks,
14
+ :class_name => 'Ecm::Cms::Page::ContentBlock',
15
+ :dependent => :destroy,
16
+ :foreign_key => 'ecm_cms_page_id',
17
+ :inverse_of => :ecm_cms_page
18
+
19
+ # attributes
20
+ attr_accessible :basename,
21
+ :body,
22
+ :ecm_cms_folder_id,
23
+ :ecm_cms_navigation_item_ids,
24
+ :ecm_cms_page_content_blocks_attributes,
25
+ :format,
26
+ :handler,
27
+ :layout,
28
+ :locale,
29
+ :meta_description,
30
+ :pathname,
31
+ :title
32
+ accepts_nested_attributes_for :ecm_cms_page_content_blocks, :allow_destroy => true
33
+
34
+ # callbacks
35
+ after_save :touch_navigation_items # , :if => Proc.new { |page| page.locale_changed? || page.pathname_changed? || page.basename_changed? }
36
+
37
+ # validations
38
+ validates :title, :presence => true
39
+
40
+ def home_page?
41
+ return self.pathname == '/' && self.basename == 'home'
42
+ end
43
+
44
+ def touch_navigation_items
45
+ self.ecm_cms_navigation_items.map(&:update_url_form_page!)
46
+ end
38
47
  end
39
48
  end
40
-
@@ -0,0 +1,16 @@
1
+ ---
2
+ de:
3
+ activerecord:
4
+ models:
5
+ ecm/cms/content_box:
6
+ one: Content Box
7
+ other: Content Boxen
8
+ attributes:
9
+ ecm/cms/content_box:
10
+ name: Name
11
+ body: Inhalt
12
+ created_at: Erstellt am
13
+ ecm_cms_page_content_blocks: Content Blöcke
14
+ ecm_cms_page_content_blocks_count: Content Blöcke
15
+ updated_at: Aktualisiert am
16
+
@@ -0,0 +1,16 @@
1
+ ---
2
+ en:
3
+ activerecord:
4
+ models:
5
+ ecm/cms/content_box:
6
+ one: content box
7
+ other: content boxes
8
+ attributes:
9
+ ecm/cms/content_box:
10
+ name: name
11
+ body: body
12
+ created_at: created at
13
+ ecm_cms_page_content_blocks: content blocks
14
+ ecm_cms_page_content_blocks_count: content blocks
15
+ updated_at: updated at
16
+
@@ -0,0 +1,15 @@
1
+ ---
2
+ de:
3
+ activerecord:
4
+ models:
5
+ ecm/cms/page/content_block:
6
+ one: Content Block
7
+ other: Content Blöcke
8
+ attributes:
9
+ ecm/cms/page/content_block:
10
+ body: Inhalt
11
+ created_at: Erstellt am
12
+ ecm_cms_page: Seite
13
+ ecm_cms_content_box: Content Box
14
+ updated_at: Aktualisiert am
15
+
@@ -0,0 +1,15 @@
1
+ ---
2
+ en:
3
+ activerecord:
4
+ models:
5
+ ecm/cms/page/content_block:
6
+ one: content block
7
+ other: content blocks
8
+ attributes:
9
+ ecm/cms/page/content_block:
10
+ body: body
11
+ created_at: created at
12
+ ecm_cms_page: page
13
+ ecm_cms_content_box: content box
14
+ updated_at: udpated at
15
+
@@ -0,0 +1,9 @@
1
+ class CreateEcmCmsContentBoxes < ActiveRecord::Migration
2
+ def change
3
+ create_table :ecm_cms_content_boxes do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class CreateEcmCmsPageContentBlocks < ActiveRecord::Migration
2
+ def change
3
+ create_table :ecm_cms_page_content_blocks do |t|
4
+ t.text :body
5
+
6
+ # associations
7
+ t.references :ecm_cms_page
8
+ t.references :ecm_cms_content_box
9
+
10
+ t.timestamps
11
+ end
12
+ add_index :ecm_cms_page_content_blocks, :ecm_cms_page_id
13
+ add_index :ecm_cms_page_content_blocks, :ecm_cms_content_box_id
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ ActiveAdmin.register Ecm::Cms::ContentBox do
2
+ # Menu
3
+ menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
4
+
5
+ index do
6
+ selectable_column
7
+ column :name
8
+ column :created_at
9
+ column :updated_at
10
+ default_actions
11
+ end
12
+
13
+ show do
14
+ panel Ecm::Cms::ContentBox.human_attribute_name(:ecm_cms_page_content_blocks) do
15
+ table_for ecm_cms_content_box.ecm_cms_page_content_blocks, :i18n => Ecm::Cms::Page::ContentBlock do |content_block|
16
+ column :ecm_cms_page
17
+ column :body
18
+ column :created_at
19
+ column :updated_at
20
+ end
21
+ end
22
+ end
23
+
24
+ sidebar Ecm::Cms::ContentBox.human_attribute_name(:details), :only => :show do
25
+ attributes_table_for ecm_cms_content_box do
26
+ row :name
27
+ row :created_at
28
+ row :updated_at
29
+ row :ecm_cms_page_content_blocks_count
30
+ end
31
+ end # sidebar
32
+ end
@@ -7,7 +7,7 @@ ActiveAdmin.register Ecm::Cms::NavigationItem do
7
7
 
8
8
  form do |f|
9
9
  f.inputs do
10
- f.input :ecm_cms_navigation
10
+ f.input :ecm_cms_navigation, :collection => Ecm::Cms::Navigation.all.collect { |navigation| [navigation.to_s, navigation.id] }
11
11
  f.input :parent
12
12
  f.input :name
13
13
  end
@@ -28,7 +28,7 @@ ActiveAdmin.register Ecm::Cms::NavigationItem do
28
28
  index :as => :nested_set do
29
29
  selectable_column
30
30
  sortable_tree_columns
31
- column :ecm_cms_navigation
31
+ column(:ecm_cms_navigation) { |ni| link_to(ni.ecm_cms_navigation.to_s, [:admin, ni.ecm_cms_navigation]) }
32
32
  column :name
33
33
  column :url
34
34
  column :ecm_cms_page do |ni|
@@ -3,12 +3,27 @@ ActiveAdmin.register Ecm::Cms::Page do
3
3
  menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
4
4
 
5
5
  form do |f|
6
+ # f.inputs do
7
+ # f.object.errors.inspect
8
+ # end
9
+
6
10
  f.inputs do
7
11
  f.input :title
8
12
  f.input :meta_description
9
13
  f.input :body
10
14
  end
11
15
 
16
+ f.has_many :ecm_cms_page_content_blocks do |cb|
17
+ # cb.inputs do
18
+ if cb.object.persisted?
19
+ cb.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
20
+ end
21
+
22
+ cb.input :ecm_cms_content_box
23
+ cb.input :body
24
+ # end
25
+ end if Ecm::Cms::ContentBox.count > 0
26
+
12
27
  f.inputs do
13
28
  f.input :pathname
14
29
  f.input :basename
@@ -58,6 +73,12 @@ ActiveAdmin.register Ecm::Cms::Page do
58
73
  panel Ecm::Cms::Page.human_attribute_name(:body) do
59
74
  pre { ecm_cms_page.body }
60
75
  end
76
+
77
+ ecm_cms_page.ecm_cms_page_content_blocks.each do |content_block|
78
+ panel content_block.content_box_name do
79
+ pre { content_block.body }
80
+ end
81
+ end
61
82
  end
62
83
 
63
84
  sidebar Ecm::Cms::Page.human_attribute_name(:details), :only => :show do
@@ -10,14 +10,22 @@ module Ecm
10
10
  include Ecm::Cms::DatabaseResolver
11
11
 
12
12
  def build_source(record)
13
- if record.body.nil?
14
- source = ''
15
- else
16
- source = record.body
13
+ output = ''
14
+ record.ecm_cms_page_content_blocks.each do |content_block|
15
+ # rendered_body = RedCloth.new(begin;content_block.body;end).to_html.html_safe
16
+ rendered_body = RedCloth.new(content_block.body).to_html
17
+ output << "<% content_for :#{content_block.content_box_name} do %>#{rendered_body}<% end %>"
17
18
  end
19
+
18
20
  content_for_title = "<% content_for :title do %>#{record.title}<% end %>"
19
21
  content_for_meta_description = "<% content_for :meta_description do %>#{record.meta_description}<% end %>"
20
- source << content_for_title << content_for_meta_description
22
+ output << content_for_title << content_for_meta_description
23
+
24
+ unless record.body.nil?
25
+ output << record.body
26
+ end
27
+
28
+ return output
21
29
  end
22
30
 
23
31
  def normalize_basename(basename)
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Cms
3
- VERSION = "0.0.13.pre"
3
+ VERSION = "1.0.0.pre"
4
4
  end
5
5
  end
@@ -10,6 +10,9 @@ module Ecm
10
10
  copy_file "ecm.cms.en.yml", "config/locales/ecm.cms.en.yml"
11
11
  copy_file "ecm.cms.de.yml", "config/locales/ecm.cms.de.yml"
12
12
 
13
+ copy_file "ecm.cms.content_box.en.yml", "config/locales/ecm.cms.content_box.en.yml"
14
+ copy_file "ecm.cms.content_box.de.yml", "config/locales/ecm.cms.content_box.de.yml"
15
+
13
16
  copy_file "ecm.cms.navigation.en.yml", "config/locales/ecm.cms.navigation.en.yml"
14
17
  copy_file "ecm.cms.navigation.de.yml", "config/locales/ecm.cms.navigation.de.yml"
15
18
 
@@ -19,6 +22,9 @@ module Ecm
19
22
  copy_file "ecm.cms.page.en.yml", "config/locales/ecm.cms.page.en.yml"
20
23
  copy_file "ecm.cms.page.de.yml", "config/locales/ecm.cms.page.de.yml"
21
24
 
25
+ copy_file "ecm.cms.page.content_block.en.yml", "config/locales/ecm.cms.page.content_block.en.yml"
26
+ copy_file "ecm.cms.page.content_block.de.yml", "config/locales/ecm.cms.page.content_block.de.yml"
27
+
22
28
  copy_file "ecm.cms.partial.en.yml", "config/locales/ecm.cms.partial.en.yml"
23
29
  copy_file "ecm.cms.partial.de.yml", "config/locales/ecm.cms.partial.de.yml"
24
30
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_cms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961916016
5
- prerelease: 7
4
+ hash: 961915988
5
+ prerelease: 6
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 13
10
10
  - pre
11
- version: 0.0.13.pre
11
+ version: 1.0.0.pre
12
12
  platform: ruby
13
13
  authors:
14
14
  - Roberto Vasquez Angel
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-02-07 00:00:00 Z
19
+ date: 2013-03-16 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 25
29
+ hash: 23
30
30
  segments:
31
31
  - 3
32
32
  - 2
33
- - 11
34
- version: 3.2.11
33
+ - 12
34
+ version: 3.2.12
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -175,7 +175,7 @@ dependencies:
175
175
  type: :development
176
176
  version_requirements: *id011
177
177
  - !ruby/object:Gem::Dependency
178
- name: activeadmin
178
+ name: coffee-rails
179
179
  prerelease: false
180
180
  requirement: &id012 !ruby/object:Gem::Requirement
181
181
  none: false
@@ -217,7 +217,7 @@ dependencies:
217
217
  type: :development
218
218
  version_requirements: *id014
219
219
  - !ruby/object:Gem::Dependency
220
- name: coffee-rails
220
+ name: therubyracer
221
221
  prerelease: false
222
222
  requirement: &id015 !ruby/object:Gem::Requirement
223
223
  none: false
@@ -231,7 +231,7 @@ dependencies:
231
231
  type: :development
232
232
  version_requirements: *id015
233
233
  - !ruby/object:Gem::Dependency
234
- name: therubyracer
234
+ name: twitter-bootstrap-rails
235
235
  prerelease: false
236
236
  requirement: &id016 !ruby/object:Gem::Requirement
237
237
  none: false
@@ -245,7 +245,7 @@ dependencies:
245
245
  type: :development
246
246
  version_requirements: *id016
247
247
  - !ruby/object:Gem::Dependency
248
- name: twitter-bootstrap-rails
248
+ name: capybara
249
249
  prerelease: false
250
250
  requirement: &id017 !ruby/object:Gem::Requirement
251
251
  none: false
@@ -259,7 +259,7 @@ dependencies:
259
259
  type: :development
260
260
  version_requirements: *id017
261
261
  - !ruby/object:Gem::Dependency
262
- name: capybara
262
+ name: rspec-rails
263
263
  prerelease: false
264
264
  requirement: &id018 !ruby/object:Gem::Requirement
265
265
  none: false
@@ -273,7 +273,7 @@ dependencies:
273
273
  type: :development
274
274
  version_requirements: *id018
275
275
  - !ruby/object:Gem::Dependency
276
- name: rspec-rails
276
+ name: shoulda-matchers
277
277
  prerelease: false
278
278
  requirement: &id019 !ruby/object:Gem::Requirement
279
279
  none: false
@@ -286,24 +286,10 @@ dependencies:
286
286
  version: "0"
287
287
  type: :development
288
288
  version_requirements: *id019
289
- - !ruby/object:Gem::Dependency
290
- name: shoulda-matchers
291
- prerelease: false
292
- requirement: &id020 !ruby/object:Gem::Requirement
293
- none: false
294
- requirements:
295
- - - ">="
296
- - !ruby/object:Gem::Version
297
- hash: 3
298
- segments:
299
- - 0
300
- version: "0"
301
- type: :development
302
- version_requirements: *id020
303
289
  - !ruby/object:Gem::Dependency
304
290
  name: factory_girl_rails
305
291
  prerelease: false
306
- requirement: &id021 !ruby/object:Gem::Requirement
292
+ requirement: &id020 !ruby/object:Gem::Requirement
307
293
  none: false
308
294
  requirements:
309
295
  - - ~>
@@ -314,27 +300,26 @@ dependencies:
314
300
  - 0
315
301
  version: "1.0"
316
302
  type: :development
317
- version_requirements: *id021
303
+ version_requirements: *id020
318
304
  - !ruby/object:Gem::Dependency
319
305
  name: rb-inotify
320
306
  prerelease: false
321
- requirement: &id022 !ruby/object:Gem::Requirement
307
+ requirement: &id021 !ruby/object:Gem::Requirement
322
308
  none: false
323
309
  requirements:
324
310
  - - ~>
325
311
  - !ruby/object:Gem::Version
326
- hash: 47
312
+ hash: 25
327
313
  segments:
328
314
  - 0
329
- - 8
330
- - 8
331
- version: 0.8.8
315
+ - 9
316
+ version: "0.9"
332
317
  type: :development
333
- version_requirements: *id022
318
+ version_requirements: *id021
334
319
  - !ruby/object:Gem::Dependency
335
320
  name: guard-rspec
336
321
  prerelease: false
337
- requirement: &id023 !ruby/object:Gem::Requirement
322
+ requirement: &id022 !ruby/object:Gem::Requirement
338
323
  none: false
339
324
  requirements:
340
325
  - - ">="
@@ -344,11 +329,11 @@ dependencies:
344
329
  - 0
345
330
  version: "0"
346
331
  type: :development
347
- version_requirements: *id023
332
+ version_requirements: *id022
348
333
  - !ruby/object:Gem::Dependency
349
334
  name: guard-bundler
350
335
  prerelease: false
351
- requirement: &id024 !ruby/object:Gem::Requirement
336
+ requirement: &id023 !ruby/object:Gem::Requirement
352
337
  none: false
353
338
  requirements:
354
339
  - - ">="
@@ -358,7 +343,7 @@ dependencies:
358
343
  - 0
359
344
  version: "0"
360
345
  type: :development
361
- version_requirements: *id024
346
+ version_requirements: *id023
362
347
  description: CMS Module for active admin.
363
348
  email:
364
349
  - roberto@vasquez-angel.de
@@ -374,12 +359,15 @@ files:
374
359
  - app/models/ecm/cms.rb
375
360
  - app/models/ecm/cms/navigation_item.rb
376
361
  - app/models/ecm/cms/partial.rb
362
+ - app/models/ecm/cms/page/content_block.rb
377
363
  - app/models/ecm/cms/navigation.rb
378
364
  - app/models/ecm/cms/page.rb
365
+ - app/models/ecm/cms/content_box.rb
379
366
  - app/models/ecm/cms/folder.rb
380
367
  - app/models/ecm/cms/template.rb
381
368
  - app/assets/stylesheets/ecm_cms.css.less
382
369
  - config/locales/ecm.cms.page.en.yml
370
+ - config/locales/ecm.cms.content_box.de.yml
383
371
  - config/locales/ecm.cms.partial.en.yml
384
372
  - config/locales/ecm.cms.template.de.yml
385
373
  - config/locales/ecm.cms.navigation_item.de.yml
@@ -390,11 +378,16 @@ files:
390
378
  - config/locales/ecm.cms.navigation.de.yml
391
379
  - config/locales/ecm.cms.navigation.en.yml
392
380
  - config/locales/ecm.cms.navigation_item.en.yml
381
+ - config/locales/ecm.cms.content_box.en.yml
393
382
  - config/locales/ecm.cms.partial.de.yml
383
+ - config/locales/ecm.cms.page.content_block.en.yml
384
+ - config/locales/ecm.cms.page.content_block.de.yml
394
385
  - db/migrate/005_create_ecm_cms_navigations.rb
395
386
  - db/migrate/003_create_ecm_cms_templates.rb
396
387
  - db/migrate/001_create_ecm_cms_folders.rb
397
388
  - db/migrate/002_create_ecm_cms_pages.rb
389
+ - db/migrate/008_create_ecm_cms_page_content_blocks.rb
390
+ - db/migrate/007_create_ecm_cms_content_boxes.rb
398
391
  - db/migrate/004_create_ecm_cms_partials.rb
399
392
  - db/migrate/006_create_ecm_cms_navigation_items.rb
400
393
  - lib/rails_tools/i18n_controller.rb
@@ -412,6 +405,7 @@ files:
412
405
  - lib/ecm/cms/active_admin/ecm_cms_navigation_items.rb
413
406
  - lib/ecm/cms/active_admin/ecm_cms_pages.rb
414
407
  - lib/ecm/cms/active_admin/ecm_cms_navigations.rb
408
+ - lib/ecm/cms/active_admin/ecm_cms_content_box.rb
415
409
  - lib/ecm/cms/active_admin/ecm_cms_templates.rb
416
410
  - lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
417
411
  - lib/ecm/cms/resolvers/ecm/cms/template_resolver.rb