rails_admin_cms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +36 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/javascripts/rails_admin_cms/all.js.coffee +2 -0
  6. data/app/assets/javascripts/rails_admin_cms/cms.js.coffee +18 -0
  7. data/app/assets/javascripts/rails_admin_cms/cms/flashes.js.coffee +2 -0
  8. data/app/assets/javascripts/rails_admin_cms/cms/with_scope/forms.js.coffee +4 -0
  9. data/app/assets/javascripts/rails_admin_cms/cms/with_scope/viewables.js.coffee +14 -0
  10. data/app/assets/stylesheets/rails_admin_cms/all.css.sass +0 -0
  11. data/app/controllers/cms/attachments_controller.rb +20 -0
  12. data/app/controllers/cms/files_controller.rb +19 -0
  13. data/app/controllers/cms/forms_controller.rb +89 -0
  14. data/app/controllers/cms/pages_controller.rb +13 -0
  15. data/app/controllers/cms/viewables_controller.rb +49 -0
  16. data/app/controllers/concerns/cms/editing.rb +21 -0
  17. data/app/controllers/concerns/cms/localize.rb +15 -0
  18. data/app/helpers/cms/cache_helper.rb +26 -0
  19. data/app/helpers/cms/form_helper.rb +67 -0
  20. data/app/helpers/cms/locale_helper.rb +34 -0
  21. data/app/helpers/cms/view_helper.rb +37 -0
  22. data/app/helpers/cms/viewable_helper.rb +155 -0
  23. data/app/helpers/rails_admin/form_builder_decorator.rb +11 -0
  24. data/app/helpers/rails_admin/navigation_helper.rb +77 -0
  25. data/app/mailers/cms/forms_mailer.rb +48 -0
  26. data/app/models/admin/form/email.rb +41 -0
  27. data/app/models/admin/form/field.rb +25 -0
  28. data/app/models/admin/form/row.rb +36 -0
  29. data/app/models/admin/form/static/object.rb +15 -0
  30. data/app/models/admin/form/structure.rb +18 -0
  31. data/app/models/admin/setting.rb +21 -0
  32. data/app/models/admin/unique_key.rb +15 -0
  33. data/app/models/admin/viewable/block.rb +25 -0
  34. data/app/models/admin/viewable/form.rb +36 -0
  35. data/app/models/admin/viewable/image.rb +18 -0
  36. data/app/models/admin/viewable/link.rb +21 -0
  37. data/app/models/admin/viewable/page.rb +27 -0
  38. data/app/models/admin/viewable/select.rb +15 -0
  39. data/app/models/admin/viewable/text.rb +16 -0
  40. data/app/models/callbacks/form/field_after_create.rb +16 -0
  41. data/app/models/callbacks/form/field_after_destroy.rb +16 -0
  42. data/app/models/callbacks/form/field_before_update.rb +29 -0
  43. data/app/models/callbacks/restrictor.rb +30 -0
  44. data/app/models/callbacks/unique_key_before_update.rb +46 -0
  45. data/app/models/callbacks/viewable_after_destroy.rb +27 -0
  46. data/app/models/callbacks/viewable_before_update.rb +15 -0
  47. data/app/models/form.rb +43 -0
  48. data/app/models/form/email.rb +21 -0
  49. data/app/models/form/field.rb +75 -0
  50. data/app/models/form/row.rb +30 -0
  51. data/app/models/form/static.rb +17 -0
  52. data/app/models/form/static/attachment.rb +62 -0
  53. data/app/models/form/static/base.rb +10 -0
  54. data/app/models/form/static/email.rb +23 -0
  55. data/app/models/form/static/object.rb +12 -0
  56. data/app/models/form/structure.rb +90 -0
  57. data/app/models/setting.rb +85 -0
  58. data/app/models/unique_key.rb +62 -0
  59. data/app/models/viewable.rb +93 -0
  60. data/app/models/viewable/block.rb +39 -0
  61. data/app/models/viewable/field/url.rb +45 -0
  62. data/app/models/viewable/field/uuid.rb +61 -0
  63. data/app/models/viewable/form.rb +67 -0
  64. data/app/models/viewable/image.rb +6 -0
  65. data/app/models/viewable/link.rb +10 -0
  66. data/app/models/viewable/page.rb +24 -0
  67. data/app/models/viewable/select.rb +6 -0
  68. data/app/models/viewable/text.rb +6 -0
  69. data/app/presenters/base_list_presenter.rb +42 -0
  70. data/app/presenters/base_presenter.rb +17 -0
  71. data/app/presenters/viewable/block_presenter.rb +10 -0
  72. data/app/presenters/viewable/form_presenter.rb +15 -0
  73. data/app/presenters/viewable/image_presenter.rb +11 -0
  74. data/app/presenters/viewable/link_list_presenter.rb +44 -0
  75. data/app/presenters/viewable/link_presenter.rb +64 -0
  76. data/app/presenters/viewable/page_presenter.rb +4 -0
  77. data/app/presenters/viewable/select_list_presenter.rb +7 -0
  78. data/app/presenters/viewable/select_presenter.rb +15 -0
  79. data/app/presenters/viewable/text_presenter.rb +11 -0
  80. data/app/presenters/viewable/view_presenter.rb +38 -0
  81. data/app/presenters/viewable_list_presenter.rb +54 -0
  82. data/app/presenters/viewable_presenter.rb +27 -0
  83. data/app/views/cms/forms/create.js.erb +3 -0
  84. data/app/views/cms/shared/_flash_messages.js.erb +2 -0
  85. data/app/views/cms/viewables/update.js.erb +1 -0
  86. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +10 -0
  87. data/config/initializers/assets.rb +6 -0
  88. data/config/initializers/route_translator.rb +3 -0
  89. data/config/locales/cms.en.yml +32 -0
  90. data/config/locales/cms.fr.yml +32 -0
  91. data/config/locales/flash.en.yml +43 -0
  92. data/config/locales/flash.fr.yml +43 -0
  93. data/config/locales/routes.en.yml +3 -0
  94. data/config/locales/routes.fr.yml +3 -0
  95. data/config/routes.rb +36 -0
  96. data/config/spring.rb +1 -0
  97. data/db/migrate/20151226023652_create_unique_key.rb +19 -0
  98. data/db/migrate/20151226054335_create_viewable_link.rb +14 -0
  99. data/db/migrate/20151227064933_create_viewable_text.rb +10 -0
  100. data/db/migrate/20151227072412_create_rich_rich_images.rich.rb +18 -0
  101. data/db/migrate/20151227072413_add_uri_cache_to_rich_image.rich.rb +6 -0
  102. data/db/migrate/20151227072414_refactor_image_to_file.rich.rb +13 -0
  103. data/db/migrate/20151228231201_create_viewable_image.rb +10 -0
  104. data/db/migrate/20151230050603_create_setting.rb +13 -0
  105. data/db/migrate/20151230072904_add_cms_mail_from_and_bcc_settings.rb +14 -0
  106. data/db/migrate/20151230085947_create_viewable_select.rb +10 -0
  107. data/db/migrate/20151231054310_create_viewable_block.rb +9 -0
  108. data/db/migrate/20151231102148_create_viewable_page.rb +13 -0
  109. data/db/migrate/20160101124428_create_viewable_form.rb +15 -0
  110. data/db/migrate/20160101140244_create_form_structure.rb +9 -0
  111. data/db/migrate/20160101141844_create_form_row.rb +13 -0
  112. data/db/migrate/20160102010317_create_form_field.rb +17 -0
  113. data/db/migrate/20160103120544_create_form_email.rb +18 -0
  114. data/lib/generators/cms/install/USAGE +8 -0
  115. data/lib/generators/cms/install/install_generator.rb +14 -0
  116. data/lib/generators/cms/install/templates/Gemfile +47 -0
  117. data/lib/generators/cms/install/templates/app/assets/javascripts/application.js +19 -0
  118. data/lib/generators/cms/install/templates/app/assets/stylesheets/application.css +17 -0
  119. data/lib/generators/cms/install/templates/app/controllers/application_controller.rb +9 -0
  120. data/lib/generators/cms/install/templates/app/controllers/cms/authenticate.rb +34 -0
  121. data/lib/generators/cms/install/templates/app/models/form/contact.rb +20 -0
  122. data/lib/generators/cms/install/templates/app/views/cms/blocks/_example.html.erb +13 -0
  123. data/lib/generators/cms/install/templates/app/views/cms/forms/contact/_form.html.erb +30 -0
  124. data/lib/generators/cms/install/templates/app/views/cms/forms/contact/new.html.erb +19 -0
  125. data/lib/generators/cms/install/templates/app/views/cms/forms_mailer/contact.html.erb +6 -0
  126. data/lib/generators/cms/install/templates/app/views/cms/forms_mailer/contact.text.erb +6 -0
  127. data/lib/generators/cms/install/templates/app/views/cms/pages/page.html.erb +29 -0
  128. data/lib/generators/cms/install/templates/app/views/layouts/application.html.erb +23 -0
  129. data/lib/generators/cms/install/templates/config/application.rb +36 -0
  130. data/lib/generators/cms/install/templates/config/initializers/rails_admin.rb +97 -0
  131. data/lib/generators/cms/install/templates/config/initializers/rich.rb +142 -0
  132. data/lib/generators/cms/install/templates/config/initializers/simple_form.rb +165 -0
  133. data/lib/generators/cms/install/templates/config/initializers/simple_form_bootstrap.rb +149 -0
  134. data/lib/generators/cms/install/templates/config/locales/routes.en.yml +4 -0
  135. data/lib/generators/cms/install/templates/config/locales/simple_form.en.yml +31 -0
  136. data/lib/generators/cms/install/templates/config/routes.rb +61 -0
  137. data/lib/generators/cms/install/templates/vendor/assets/javascripts/rails_admin/custom/ui.js.coffee +1 -0
  138. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/mixins.sass +0 -0
  139. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/theming.sass +1 -0
  140. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/variables.sass +0 -0
  141. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rich/editor.css +20 -0
  142. data/lib/rails_admin_cms.rb +28 -0
  143. data/lib/rails_admin_cms/config.rb +45 -0
  144. data/lib/rails_admin_cms/core_ext/boolean.rb +29 -0
  145. data/lib/rails_admin_cms/engine.rb +11 -0
  146. data/lib/rails_admin_cms/inflections.rb +4 -0
  147. data/lib/rails_admin_cms/utils.rb +30 -0
  148. data/lib/rails_admin_cms/version.rb +3 -0
  149. data/lib/tasks/rails_admin_cms_tasks.rake +4 -0
  150. metadata +669 -0
@@ -0,0 +1,3 @@
1
+ en:
2
+ routes:
3
+ files: files
@@ -0,0 +1,3 @@
1
+ fr:
2
+ routes:
3
+ files: fichiers
@@ -0,0 +1,36 @@
1
+ Rails.application.routes.draw do
2
+ scope module: 'cms' do
3
+ get 'viewables/new' => 'viewables#create', format: false, as: :new_viewable
4
+ post 'viewables/edit' => 'viewables#update', format: true, constraints: { format: :js }, as: :edit_viewable
5
+
6
+ get 'attachments/*directory/:file' => 'attachments#show', format: true
7
+
8
+ Viewable::Page.with_url.each do |page|
9
+ get page.url => "pages#show", format: false,
10
+ defaults: { id: page.id, cms_view_type: page.view_name, cms_body_class: page.view_name, locale: page.locale }
11
+ end if ActiveRecord::Base.connection.table_exists? 'viewable_pages'
12
+
13
+ Viewable::Form.with_url.each do |form|
14
+ get form.url => "forms#new", format: false,
15
+ defaults: { id: form.id, cms_view_type: form.form_name, cms_body_class: form.form_name, locale: form.locale }
16
+ post form.url => 'forms#create',
17
+ defaults: { id: form.id, cms_view_type: form.form_name, cms_body_class: form.form_name, locale: form.locale }
18
+ end if ActiveRecord::Base.connection.table_exists? 'viewable_forms'
19
+
20
+ localized do
21
+ resources :files, format: false, only: [:show]
22
+
23
+ Viewable::Page.names.each do |name|
24
+ get name => 'pages#show', format: false,
25
+ defaults: { cms_view_type: name, cms_body_class: name }
26
+ end
27
+
28
+ Viewable::Form.names.each do |name|
29
+ get name => 'forms#new', format: false,
30
+ defaults: { cms_view_type: name, cms_body_class: name }
31
+ post name => 'forms#create',
32
+ defaults: { cms_view_type: name, cms_body_class: name }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1 @@
1
+ Spring.application_root = 'spec/dummy'
@@ -0,0 +1,19 @@
1
+ class CreateUniqueKey < ActiveRecord::Migration
2
+ def change
3
+ create_table :unique_keys do |t|
4
+ t.references :viewable, polymorphic: true, index: true
5
+ t.text :view_path, null: false
6
+ t.text :name, null: false
7
+ t.integer :position, null: false
8
+ t.string :locale, null: false
9
+
10
+ t.timestamps null: false
11
+ end
12
+
13
+ add_index(
14
+ :unique_keys,
15
+ [ :viewable_type, :view_path, :name, :position, :locale ],
16
+ { unique: true, name: 'index_unique_keys_on_unique_key' }
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ class CreateViewableLink < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_links do |t|
4
+ t.string :title
5
+ t.text :url
6
+ t.text :page
7
+ t.text :file
8
+ t.boolean :target_blank, default: false
9
+ t.boolean :turbolink, default: true
10
+
11
+ t.timestamps null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ class CreateViewableText < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_texts do |t|
4
+ t.string :title
5
+ t.text :text
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # This migration comes from rich (originally 20111002142937)
2
+ class CreateRichRichImages < ActiveRecord::Migration
3
+ def change
4
+ create_table :rich_rich_images do |t|
5
+
6
+ t.timestamps
7
+
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
+
13
+ t.string :owner_type
14
+ t.integer :owner_id
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ # This migration comes from rich (originally 20111117202133)
2
+ class AddUriCacheToRichImage < ActiveRecord::Migration
3
+ def change
4
+ add_column :rich_rich_images, :uri_cache, :text
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ # This migration comes from rich (originally 20111201095829)
2
+ class RefactorImageToFile < ActiveRecord::Migration
3
+ def change
4
+ rename_table :rich_rich_images, :rich_rich_files
5
+
6
+ rename_column :rich_rich_files, :image_file_name, :rich_file_file_name
7
+ rename_column :rich_rich_files, :image_content_type, :rich_file_content_type
8
+ rename_column :rich_rich_files, :image_file_size, :rich_file_file_size
9
+ rename_column :rich_rich_files, :image_updated_at, :rich_file_updated_at
10
+
11
+ add_column :rich_rich_files, :simplified_type, :string, :default => "file"
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class CreateViewableImage < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_images do |t|
4
+ t.string :title
5
+ t.text :image
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateSetting < ActiveRecord::Migration
2
+ def change
3
+ create_table :settings do |t|
4
+ t.string :name
5
+ t.text :value
6
+ t.string :unit
7
+
8
+ t.timestamps null: false
9
+ end
10
+
11
+ add_index :settings, :name, unique: true
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class AddCMSMailFromAndBccSettings < ActiveRecord::Migration
2
+ def up
3
+ Setting.apply_all(
4
+ cms_mail_from: 'rails@admin.cms',
5
+ cms_mail_bcc: 'rails@admin.cms',
6
+ )
7
+ end
8
+ def down
9
+ Setting.remove_all(
10
+ :cms_mail_from,
11
+ :cms_mail_bcc,
12
+ )
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ class CreateViewableSelect < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_selects do |t|
4
+ t.string :value
5
+ t.string :label
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class CreateViewableBlock < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_blocks do |t|
4
+ t.string :uuid
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateViewablePage < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_pages do |t|
4
+ t.string :uuid
5
+ t.text :url, index: true
6
+ t.string :title
7
+ t.text :meta_keywords
8
+ t.text :meta_description
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class CreateViewableForm < ActiveRecord::Migration
2
+ def change
3
+ create_table :viewable_forms do |t|
4
+ t.references :structure, index: true
5
+
6
+ t.string :uuid
7
+ t.text :url, index: true
8
+ t.string :title
9
+ t.text :meta_keywords
10
+ t.text :meta_description
11
+
12
+ t.timestamps null: false
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ class CreateFormStructure < ActiveRecord::Migration
2
+ def change
3
+ create_table :form_structures do |t|
4
+ t.references :email, index: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateFormRow < ActiveRecord::Migration
2
+ def change
3
+ create_table :form_rows do |t|
4
+ t.references :structure, index: true
5
+
6
+ RailsAdminCMS::Config.custom_form_max_size.times.each do |i|
7
+ t.text :"column_#{i}"
8
+ end
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ class CreateFormField < ActiveRecord::Migration
2
+ def change
3
+ create_table :form_fields do |t|
4
+ t.references :structure, index: true
5
+
6
+ t.integer :position
7
+ t.string :type
8
+ t.boolean :required, default: false
9
+
10
+ I18n.available_locales.each do |locale|
11
+ t.string :"label_#{locale}"
12
+ end
13
+
14
+ t.timestamps null: false
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ class CreateFormEmail < ActiveRecord::Migration
2
+ def change
3
+ create_table :form_emails do |t|
4
+ t.boolean :with_email, default: false
5
+ t.string :send_to
6
+
7
+ I18n.available_locales.each do |locale|
8
+ t.string :"subject_#{locale}"
9
+ end
10
+
11
+ I18n.available_locales.each do |locale|
12
+ t.text :"body_#{locale}"
13
+ end
14
+
15
+ t.timestamps null: false
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate install Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,14 @@
1
+ module Cms; end
2
+
3
+ class Cms::InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ desc "Overwrite the existing Rails application with the necessary files"
7
+
8
+ def copy_files
9
+ directory 'app', 'app'
10
+ directory 'config', 'config'
11
+ directory 'vendor', 'vendor'
12
+ copy_file 'Gemfile', 'Gemfile'
13
+ end
14
+ end
@@ -0,0 +1,47 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.2.5'
6
+ # Use postgresql as the database for Active Record
7
+ gem 'pg', '~> 0.15'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 5.0'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .coffee assets and views
13
+ gem 'coffee-rails', '~> 4.1.0'
14
+ # See https://github.com/rails/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ # Use ActiveModel has_secure_password
27
+ # gem 'bcrypt', '~> 3.1.7'
28
+
29
+ # Use Unicorn as the app server
30
+ # gem 'unicorn'
31
+
32
+ # Use Capistrano for deployment
33
+ # gem 'capistrano-rails', group: :development
34
+
35
+ group :development do
36
+ # Access an IRB console on exception pages or by using <%= console %> in views
37
+ gem 'web-console', '~> 2.0'
38
+
39
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
40
+ gem 'spring'
41
+
42
+ gem 'quiet_assets'
43
+ end
44
+
45
+ gem 'rails_admin_cms', github: 'o2web/rails_admin_cms'
46
+ gem 'rich', github: 'o2web/rich'
47
+ gem 'rails_admin_jcrop', github: 'o2web/rails_admin_jcrop', branch: 'feature/one_crop_per_page'
@@ -0,0 +1,19 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //
17
+ //= require rails_admin_cms/all
18
+ //
19
+ //= require_tree .
@@ -0,0 +1,17 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require rails_admin_cms/all
14
+ *
15
+ *= require_tree .
16
+ *= require_self
17
+ */
@@ -0,0 +1,9 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ include CMS::Localize
7
+ include CMS::Editing
8
+ include CMS::Authenticate
9
+ end
@@ -0,0 +1,34 @@
1
+ module CMS
2
+ module Authenticate
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # http_basic_authenticate_with name: 'user', password: 'pwd' if Rails.env.staging?
7
+
8
+ helper_method :current_user, :current_user?, :current_admin, :current_admin?
9
+ end
10
+
11
+ # TODO override or rewrite
12
+ def current_user
13
+ @current_user ||= Struct.new(:admin?).new(true)
14
+ end
15
+
16
+ def current_user?
17
+ return @is_current_user if defined? @is_current_user
18
+ @is_current_user = !!current_user
19
+ end
20
+
21
+ def current_admin
22
+ current_user if current_admin?
23
+ end
24
+
25
+ def current_admin?
26
+ return @is_current_admin if defined? @is_current_admin
27
+ @is_current_admin = !!current_user.try(:admin?)
28
+ end
29
+
30
+ def authenticate_admin_user!
31
+ raise SecurityError unless current_admin?
32
+ end
33
+ end
34
+ end