rails_admin_cms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +26 -0
- data/app/assets/javascripts/rails_admin_cms/all.js.coffee +2 -0
- data/app/assets/javascripts/rails_admin_cms/cms.js.coffee +18 -0
- data/app/assets/javascripts/rails_admin_cms/cms/flashes.js.coffee +2 -0
- data/app/assets/javascripts/rails_admin_cms/cms/with_scope/forms.js.coffee +4 -0
- data/app/assets/javascripts/rails_admin_cms/cms/with_scope/viewables.js.coffee +14 -0
- data/app/assets/stylesheets/rails_admin_cms/all.css.sass +0 -0
- data/app/controllers/cms/attachments_controller.rb +20 -0
- data/app/controllers/cms/files_controller.rb +19 -0
- data/app/controllers/cms/forms_controller.rb +89 -0
- data/app/controllers/cms/pages_controller.rb +13 -0
- data/app/controllers/cms/viewables_controller.rb +49 -0
- data/app/controllers/concerns/cms/editing.rb +21 -0
- data/app/controllers/concerns/cms/localize.rb +15 -0
- data/app/helpers/cms/cache_helper.rb +26 -0
- data/app/helpers/cms/form_helper.rb +67 -0
- data/app/helpers/cms/locale_helper.rb +34 -0
- data/app/helpers/cms/view_helper.rb +37 -0
- data/app/helpers/cms/viewable_helper.rb +155 -0
- data/app/helpers/rails_admin/form_builder_decorator.rb +11 -0
- data/app/helpers/rails_admin/navigation_helper.rb +77 -0
- data/app/mailers/cms/forms_mailer.rb +48 -0
- data/app/models/admin/form/email.rb +41 -0
- data/app/models/admin/form/field.rb +25 -0
- data/app/models/admin/form/row.rb +36 -0
- data/app/models/admin/form/static/object.rb +15 -0
- data/app/models/admin/form/structure.rb +18 -0
- data/app/models/admin/setting.rb +21 -0
- data/app/models/admin/unique_key.rb +15 -0
- data/app/models/admin/viewable/block.rb +25 -0
- data/app/models/admin/viewable/form.rb +36 -0
- data/app/models/admin/viewable/image.rb +18 -0
- data/app/models/admin/viewable/link.rb +21 -0
- data/app/models/admin/viewable/page.rb +27 -0
- data/app/models/admin/viewable/select.rb +15 -0
- data/app/models/admin/viewable/text.rb +16 -0
- data/app/models/callbacks/form/field_after_create.rb +16 -0
- data/app/models/callbacks/form/field_after_destroy.rb +16 -0
- data/app/models/callbacks/form/field_before_update.rb +29 -0
- data/app/models/callbacks/restrictor.rb +30 -0
- data/app/models/callbacks/unique_key_before_update.rb +46 -0
- data/app/models/callbacks/viewable_after_destroy.rb +27 -0
- data/app/models/callbacks/viewable_before_update.rb +15 -0
- data/app/models/form.rb +43 -0
- data/app/models/form/email.rb +21 -0
- data/app/models/form/field.rb +75 -0
- data/app/models/form/row.rb +30 -0
- data/app/models/form/static.rb +17 -0
- data/app/models/form/static/attachment.rb +62 -0
- data/app/models/form/static/base.rb +10 -0
- data/app/models/form/static/email.rb +23 -0
- data/app/models/form/static/object.rb +12 -0
- data/app/models/form/structure.rb +90 -0
- data/app/models/setting.rb +85 -0
- data/app/models/unique_key.rb +62 -0
- data/app/models/viewable.rb +93 -0
- data/app/models/viewable/block.rb +39 -0
- data/app/models/viewable/field/url.rb +45 -0
- data/app/models/viewable/field/uuid.rb +61 -0
- data/app/models/viewable/form.rb +67 -0
- data/app/models/viewable/image.rb +6 -0
- data/app/models/viewable/link.rb +10 -0
- data/app/models/viewable/page.rb +24 -0
- data/app/models/viewable/select.rb +6 -0
- data/app/models/viewable/text.rb +6 -0
- data/app/presenters/base_list_presenter.rb +42 -0
- data/app/presenters/base_presenter.rb +17 -0
- data/app/presenters/viewable/block_presenter.rb +10 -0
- data/app/presenters/viewable/form_presenter.rb +15 -0
- data/app/presenters/viewable/image_presenter.rb +11 -0
- data/app/presenters/viewable/link_list_presenter.rb +44 -0
- data/app/presenters/viewable/link_presenter.rb +64 -0
- data/app/presenters/viewable/page_presenter.rb +4 -0
- data/app/presenters/viewable/select_list_presenter.rb +7 -0
- data/app/presenters/viewable/select_presenter.rb +15 -0
- data/app/presenters/viewable/text_presenter.rb +11 -0
- data/app/presenters/viewable/view_presenter.rb +38 -0
- data/app/presenters/viewable_list_presenter.rb +54 -0
- data/app/presenters/viewable_presenter.rb +27 -0
- data/app/views/cms/forms/create.js.erb +3 -0
- data/app/views/cms/shared/_flash_messages.js.erb +2 -0
- data/app/views/cms/viewables/update.js.erb +1 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +10 -0
- data/config/initializers/assets.rb +6 -0
- data/config/initializers/route_translator.rb +3 -0
- data/config/locales/cms.en.yml +32 -0
- data/config/locales/cms.fr.yml +32 -0
- data/config/locales/flash.en.yml +43 -0
- data/config/locales/flash.fr.yml +43 -0
- data/config/locales/routes.en.yml +3 -0
- data/config/locales/routes.fr.yml +3 -0
- data/config/routes.rb +36 -0
- data/config/spring.rb +1 -0
- data/db/migrate/20151226023652_create_unique_key.rb +19 -0
- data/db/migrate/20151226054335_create_viewable_link.rb +14 -0
- data/db/migrate/20151227064933_create_viewable_text.rb +10 -0
- data/db/migrate/20151227072412_create_rich_rich_images.rich.rb +18 -0
- data/db/migrate/20151227072413_add_uri_cache_to_rich_image.rich.rb +6 -0
- data/db/migrate/20151227072414_refactor_image_to_file.rich.rb +13 -0
- data/db/migrate/20151228231201_create_viewable_image.rb +10 -0
- data/db/migrate/20151230050603_create_setting.rb +13 -0
- data/db/migrate/20151230072904_add_cms_mail_from_and_bcc_settings.rb +14 -0
- data/db/migrate/20151230085947_create_viewable_select.rb +10 -0
- data/db/migrate/20151231054310_create_viewable_block.rb +9 -0
- data/db/migrate/20151231102148_create_viewable_page.rb +13 -0
- data/db/migrate/20160101124428_create_viewable_form.rb +15 -0
- data/db/migrate/20160101140244_create_form_structure.rb +9 -0
- data/db/migrate/20160101141844_create_form_row.rb +13 -0
- data/db/migrate/20160102010317_create_form_field.rb +17 -0
- data/db/migrate/20160103120544_create_form_email.rb +18 -0
- data/lib/generators/cms/install/USAGE +8 -0
- data/lib/generators/cms/install/install_generator.rb +14 -0
- data/lib/generators/cms/install/templates/Gemfile +47 -0
- data/lib/generators/cms/install/templates/app/assets/javascripts/application.js +19 -0
- data/lib/generators/cms/install/templates/app/assets/stylesheets/application.css +17 -0
- data/lib/generators/cms/install/templates/app/controllers/application_controller.rb +9 -0
- data/lib/generators/cms/install/templates/app/controllers/cms/authenticate.rb +34 -0
- data/lib/generators/cms/install/templates/app/models/form/contact.rb +20 -0
- data/lib/generators/cms/install/templates/app/views/cms/blocks/_example.html.erb +13 -0
- data/lib/generators/cms/install/templates/app/views/cms/forms/contact/_form.html.erb +30 -0
- data/lib/generators/cms/install/templates/app/views/cms/forms/contact/new.html.erb +19 -0
- data/lib/generators/cms/install/templates/app/views/cms/forms_mailer/contact.html.erb +6 -0
- data/lib/generators/cms/install/templates/app/views/cms/forms_mailer/contact.text.erb +6 -0
- data/lib/generators/cms/install/templates/app/views/cms/pages/page.html.erb +29 -0
- data/lib/generators/cms/install/templates/app/views/layouts/application.html.erb +23 -0
- data/lib/generators/cms/install/templates/config/application.rb +36 -0
- data/lib/generators/cms/install/templates/config/initializers/rails_admin.rb +97 -0
- data/lib/generators/cms/install/templates/config/initializers/rich.rb +142 -0
- data/lib/generators/cms/install/templates/config/initializers/simple_form.rb +165 -0
- data/lib/generators/cms/install/templates/config/initializers/simple_form_bootstrap.rb +149 -0
- data/lib/generators/cms/install/templates/config/locales/routes.en.yml +4 -0
- data/lib/generators/cms/install/templates/config/locales/simple_form.en.yml +31 -0
- data/lib/generators/cms/install/templates/config/routes.rb +61 -0
- data/lib/generators/cms/install/templates/vendor/assets/javascripts/rails_admin/custom/ui.js.coffee +1 -0
- data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/mixins.sass +0 -0
- data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/theming.sass +1 -0
- data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/variables.sass +0 -0
- data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rich/editor.css +20 -0
- data/lib/rails_admin_cms.rb +28 -0
- data/lib/rails_admin_cms/config.rb +45 -0
- data/lib/rails_admin_cms/core_ext/boolean.rb +29 -0
- data/lib/rails_admin_cms/engine.rb +11 -0
- data/lib/rails_admin_cms/inflections.rb +4 -0
- data/lib/rails_admin_cms/utils.rb +30 -0
- data/lib/rails_admin_cms/version.rb +3 -0
- data/lib/tasks/rails_admin_cms_tasks.rake +4 -0
- metadata +669 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Form
|
2
|
+
class Contact < Static::Object # < Static::Base
|
3
|
+
include Admin::Form::Static::Object
|
4
|
+
|
5
|
+
include Static::Email
|
6
|
+
include Static::Attachment
|
7
|
+
|
8
|
+
# has_attachments :letter, :resume
|
9
|
+
has_collections :periods
|
10
|
+
|
11
|
+
attribute :name, :string
|
12
|
+
attribute :email, :string
|
13
|
+
attribute :periods, :text
|
14
|
+
|
15
|
+
with_options presence: true do
|
16
|
+
validates :name
|
17
|
+
validates :email, email: true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%# cms_form %>
|
2
|
+
|
3
|
+
<% cms_cache do
|
4
|
+
select = cms_select(1, Float::INFINITY)
|
5
|
+
-%>
|
6
|
+
|
7
|
+
<%#= @cms_view.edit_link %>
|
8
|
+
<%#= @cms_view.add_link %>
|
9
|
+
|
10
|
+
<%= cms_form_for do |f| %>
|
11
|
+
<%= f.input :name, input_html: cms_validate_presence %>
|
12
|
+
<%= f.input :email, input_html: cms_validate_email %>
|
13
|
+
<%= f.input :periods, as: :check_boxes, collection: select.options, input_html: cms_validates(check_boxes: true) %>
|
14
|
+
<%= select.edit_links(:value) %>
|
15
|
+
|
16
|
+
<%# cms_form_instance.fields.each do |field| %>
|
17
|
+
<%#= f.input field.column_key,
|
18
|
+
as: field.input_type,
|
19
|
+
required: field.required?,
|
20
|
+
label: field.label,
|
21
|
+
input_html: cms_validates(field.input_type => field.required?)
|
22
|
+
-%>
|
23
|
+
<%# end %>
|
24
|
+
|
25
|
+
<%#= f.input :structure_id, as: :hidden, input_html: { value: cms_form_instance.structure_id } %>
|
26
|
+
|
27
|
+
<%= f.submit cms_form_send, cms_form_sending %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% cms_cache('top') do
|
2
|
+
text = cms_text('top')
|
3
|
+
-%>
|
4
|
+
|
5
|
+
<%= text.html %>
|
6
|
+
<%= text.edit_link %>
|
7
|
+
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= render cms_form_partial %>
|
11
|
+
|
12
|
+
<% cms_cache('bottom') do
|
13
|
+
text = cms_text('bottom')
|
14
|
+
-%>
|
15
|
+
|
16
|
+
<%= text.html %>
|
17
|
+
<%= text.edit_link %>
|
18
|
+
|
19
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%# cms_page %>
|
2
|
+
|
3
|
+
<% cms_cache do
|
4
|
+
menu = cms_link(0, Float::INFINITY)
|
5
|
+
image = cms_image
|
6
|
+
blocks = cms_example(1, 4)
|
7
|
+
# view_image = cms_view_image
|
8
|
+
# view_block = cms_view_example
|
9
|
+
-%>
|
10
|
+
|
11
|
+
<%#= @cms_view.edit_link %>
|
12
|
+
<%#= @cms_view.add_link %>
|
13
|
+
|
14
|
+
<%= menu.ul_sortable_tag do %>
|
15
|
+
<% menu.each do |link| %>
|
16
|
+
<%= link.li_link_to_with_edit %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<%= menu.add_link %>
|
20
|
+
|
21
|
+
<%= image_tag image.path %>
|
22
|
+
<%= image.edit_link %>
|
23
|
+
|
24
|
+
<% blocks.each do |block| %>
|
25
|
+
<%= block.render %>
|
26
|
+
<% end %>
|
27
|
+
<%= blocks.edit_links(:position) %>
|
28
|
+
|
29
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= cms_title 'AppRailsAdminCMS' %></title>
|
5
|
+
<%= cms_meta_data_tags %>
|
6
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
7
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body class="<%= cms_body_class %>">
|
11
|
+
|
12
|
+
<%= cms_flash_messages %>
|
13
|
+
<div>
|
14
|
+
<%= cms_locale_selector %>
|
15
|
+
</div>
|
16
|
+
<div>
|
17
|
+
<%= cms_link_to_edit_mode %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<%= yield %>
|
21
|
+
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
# Pick the frameworks you want:
|
5
|
+
require "active_model/railtie"
|
6
|
+
require "active_job/railtie"
|
7
|
+
require "active_record/railtie"
|
8
|
+
require "action_controller/railtie"
|
9
|
+
require "action_mailer/railtie"
|
10
|
+
require "action_view/railtie"
|
11
|
+
require "sprockets/railtie"
|
12
|
+
# require "rails/test_unit/railtie"
|
13
|
+
|
14
|
+
# Require the gems listed in Gemfile, including any gems
|
15
|
+
# you've limited to :test, :development, or :production.
|
16
|
+
Bundler.require(*Rails.groups)
|
17
|
+
|
18
|
+
module AppRailsAdminCMS
|
19
|
+
class Application < Rails::Application
|
20
|
+
# Settings in config/environments/* take precedence over those specified here.
|
21
|
+
# Application configuration should go into files in config/initializers
|
22
|
+
# -- all .rb files in that directory are automatically loaded.
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
config.i18n.default_locale = :en
|
31
|
+
config.i18n.available_locales = [:en] # [:fr, :en]
|
32
|
+
|
33
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
34
|
+
config.active_record.raise_in_transactional_callbacks = true
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
RailsAdmin.config do |config|
|
2
|
+
### Popular gems integration
|
3
|
+
config.browser_validations = false
|
4
|
+
|
5
|
+
## == Devise ==
|
6
|
+
# config.authenticate_with do
|
7
|
+
# warden.authenticate! scope: :user
|
8
|
+
# end
|
9
|
+
# config.current_user_method(&:current_user)
|
10
|
+
|
11
|
+
## == Cancan ==
|
12
|
+
# config.authorize_with :cancan
|
13
|
+
|
14
|
+
## == Pundit ==
|
15
|
+
# config.authorize_with :pundit
|
16
|
+
|
17
|
+
## == PaperTrail ==
|
18
|
+
# config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
|
19
|
+
|
20
|
+
### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
|
21
|
+
|
22
|
+
config.actions do
|
23
|
+
dashboard # mandatory
|
24
|
+
index # mandatory
|
25
|
+
new do
|
26
|
+
except Viewable.models + Form.structure_models + %w[
|
27
|
+
UniqueKey
|
28
|
+
Setting
|
29
|
+
Rich::RichFile
|
30
|
+
Form::Row
|
31
|
+
]
|
32
|
+
end
|
33
|
+
export do
|
34
|
+
except Viewable.models + Form.structure_models + %w[
|
35
|
+
UniqueKey
|
36
|
+
]
|
37
|
+
end
|
38
|
+
bulk_delete do
|
39
|
+
except Viewable.models + Form.structure_models + %w[
|
40
|
+
UniqueKey
|
41
|
+
Setting
|
42
|
+
]
|
43
|
+
end
|
44
|
+
show do
|
45
|
+
except Viewable.models + Form.structure_models + %w[
|
46
|
+
UniqueKey
|
47
|
+
]
|
48
|
+
end
|
49
|
+
edit do
|
50
|
+
except %w[
|
51
|
+
UniqueKey
|
52
|
+
]
|
53
|
+
end
|
54
|
+
delete do
|
55
|
+
except Form.structure_models + %w[
|
56
|
+
UniqueKey
|
57
|
+
Setting
|
58
|
+
]
|
59
|
+
end
|
60
|
+
show_in_app
|
61
|
+
|
62
|
+
## With an audit adapter, you can add:
|
63
|
+
# history_index
|
64
|
+
# history_show
|
65
|
+
end
|
66
|
+
|
67
|
+
config.model 'Rich::RichFile' do
|
68
|
+
navigation_label I18n.t('rich.file.navigation')
|
69
|
+
label I18n.t('rich.file.one')
|
70
|
+
label_plural I18n.t('rich.file.other')
|
71
|
+
|
72
|
+
configure :rich_file, :jcrop
|
73
|
+
|
74
|
+
list do
|
75
|
+
field :rich_file
|
76
|
+
field :rich_file_file_name
|
77
|
+
field :simplified_type
|
78
|
+
field :owner_type
|
79
|
+
end
|
80
|
+
|
81
|
+
show do
|
82
|
+
field :rich_file
|
83
|
+
field :owner_type
|
84
|
+
end
|
85
|
+
|
86
|
+
edit do
|
87
|
+
field :rich_file do
|
88
|
+
fit_image true
|
89
|
+
end
|
90
|
+
field :owner_type, :enum do
|
91
|
+
enum do
|
92
|
+
['cms']
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require "rich"
|
2
|
+
|
3
|
+
if Object.const_defined?("Rich")
|
4
|
+
Rich.setup do |config|
|
5
|
+
# == Backend configuration
|
6
|
+
# Rich uses Paperclip (https://github.com/thoughtbot/paperclip) by default.
|
7
|
+
# You will need to add it to your Gemfile, however.
|
8
|
+
# config.backend = :paperclip
|
9
|
+
#
|
10
|
+
# Optionally, you can use CarrierWave (https://github.com/carrierwaveuploader/carrierwave).
|
11
|
+
# You will need to add it to your Gemfile.
|
12
|
+
# config.backend = :carrierwave
|
13
|
+
|
14
|
+
# == CKEditor configuration
|
15
|
+
#
|
16
|
+
# Rich ships with what I hope are sensible defaults.
|
17
|
+
# You may want to override these.
|
18
|
+
#
|
19
|
+
# For example, the elements available in the formats
|
20
|
+
# dropdown are defined like this:
|
21
|
+
config.editor[:format_tags] = "h1;h2;h3;h4;h5;h6;p;pre"
|
22
|
+
#
|
23
|
+
# By default, Rich visualizes what type of element
|
24
|
+
# you are editing. To disable this:
|
25
|
+
# config.editor[:startupOutlineBlocks] = false
|
26
|
+
|
27
|
+
|
28
|
+
# == Image styles
|
29
|
+
#
|
30
|
+
# Rich uses paperclip for image processing. You can
|
31
|
+
# define the styles you would like to use here. You
|
32
|
+
# can use the standard syntax allowed by paperclip.
|
33
|
+
# See: https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation
|
34
|
+
#
|
35
|
+
# When you change these after uploading some files,
|
36
|
+
# remember to re-generate your styles by running:
|
37
|
+
# rake rich:refresh_assets
|
38
|
+
config.image_styles = {
|
39
|
+
mini: '60x60>',
|
40
|
+
thumb: '120x120>',
|
41
|
+
small: '240x240>',
|
42
|
+
medium: '480x480>',
|
43
|
+
large: '960x960>',
|
44
|
+
full: '1480x1480>',
|
45
|
+
huge: '1920x1920>',
|
46
|
+
}
|
47
|
+
|
48
|
+
# == Convert options
|
49
|
+
#
|
50
|
+
# You can pass additional commands to ImageMagick to set image quality,
|
51
|
+
# apply a blur, and other fancy tricks.
|
52
|
+
config.convert_options = {
|
53
|
+
all: %{
|
54
|
+
-unsharp 3x1+0.5
|
55
|
+
-quality 85
|
56
|
+
-strip
|
57
|
+
-auto-orient
|
58
|
+
-colorspace sRGB
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
# == Allowed styles (in file manager)
|
63
|
+
#
|
64
|
+
# Of the styles specified above, which should be user
|
65
|
+
# selectable in the file manager?
|
66
|
+
#
|
67
|
+
# Example:
|
68
|
+
# config.allowed_styles = [ :large, :thumb ]
|
69
|
+
#
|
70
|
+
# Default:
|
71
|
+
# config.allowed_styles = :all
|
72
|
+
|
73
|
+
# == Default Style
|
74
|
+
#
|
75
|
+
# The style to insert by default. In addition to the
|
76
|
+
# styles defined above you can also use :original to get
|
77
|
+
# the unprocessed file. Make sure this style exists.
|
78
|
+
config.default_style = :medium
|
79
|
+
|
80
|
+
# == Upload non-image files
|
81
|
+
#
|
82
|
+
# Setting this option to true will add a second Rich filebrowser icon to
|
83
|
+
# the editor toolbar. In this filebrowser you can upload non-image files.
|
84
|
+
# Inserting these files into your editor will result in a direct (A) link.
|
85
|
+
#
|
86
|
+
# Default:
|
87
|
+
config.allow_document_uploads = true
|
88
|
+
|
89
|
+
# == Set allowed filetypes for non-image files
|
90
|
+
#
|
91
|
+
# If you want, you can restrict the types of documents that users can upload.
|
92
|
+
# Default behavior is to allow any kind of file to be uploaded. You can set
|
93
|
+
# the accepted types by providing an array of mimetypes to check against.
|
94
|
+
# Note that for this to have any effect, you first need to enable document
|
95
|
+
# uploads using the setting above.
|
96
|
+
#
|
97
|
+
# Default, allow any file to be uploaded:
|
98
|
+
# config.allowed_document_types = :all
|
99
|
+
#
|
100
|
+
# Example, only allow PDF uploads:
|
101
|
+
config.allowed_document_types = %w[
|
102
|
+
text/plain
|
103
|
+
application/pdf
|
104
|
+
application/msword
|
105
|
+
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
106
|
+
image/jpeg
|
107
|
+
image/png
|
108
|
+
image/gif
|
109
|
+
]
|
110
|
+
|
111
|
+
# == Asset insertion
|
112
|
+
#
|
113
|
+
# Set this to true to keep the filebrowser open after inserting an asset.
|
114
|
+
# Also configurable per-use from within the filebrowser.
|
115
|
+
#
|
116
|
+
# Default:
|
117
|
+
# config.insert_many = false
|
118
|
+
|
119
|
+
# == User Authentication
|
120
|
+
#
|
121
|
+
# When defined, Rich will automatically call this method
|
122
|
+
# in a before filter to ensure that the user is logged in.
|
123
|
+
#
|
124
|
+
# If you do not change this value from the default, anyone
|
125
|
+
# will be able to see your images, and upload files.
|
126
|
+
#
|
127
|
+
# Example for Devise with an AdminUser model:
|
128
|
+
config.authentication_method = :authenticate_admin_user!
|
129
|
+
#
|
130
|
+
# Default (NOT recommended in production environments):
|
131
|
+
# config.authentication_method = :none
|
132
|
+
|
133
|
+
# == Pagination
|
134
|
+
#
|
135
|
+
# By default, file picker loads up assets in blocks of 34.
|
136
|
+
#
|
137
|
+
# Default:
|
138
|
+
# config.paginates_per = 34
|
139
|
+
end
|
140
|
+
|
141
|
+
Rich.insert
|
142
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
2
|
+
SimpleForm.setup do |config|
|
3
|
+
# Wrappers are used by the form builder to generate a
|
4
|
+
# complete input. You can remove any component from the
|
5
|
+
# wrapper, change the order or even add your own to the
|
6
|
+
# stack. The options given below are used to wrap the
|
7
|
+
# whole input.
|
8
|
+
config.wrappers :default, class: :input,
|
9
|
+
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
10
|
+
## Extensions enabled by default
|
11
|
+
# Any of these extensions can be disabled for a
|
12
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
13
|
+
# You can make any of these extensions optional by
|
14
|
+
# renaming `b.use` to `b.optional`.
|
15
|
+
|
16
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
17
|
+
# and required attributes
|
18
|
+
b.use :html5
|
19
|
+
|
20
|
+
# Calculates placeholders automatically from I18n
|
21
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
22
|
+
b.use :placeholder
|
23
|
+
|
24
|
+
## Optional extensions
|
25
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
26
|
+
# to the input. If so, they will retrieve the values from the model
|
27
|
+
# if any exists. If you want to enable any of those
|
28
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
29
|
+
|
30
|
+
# Calculates maxlength from length validations for string inputs
|
31
|
+
b.optional :maxlength
|
32
|
+
|
33
|
+
# Calculates pattern from format validations for string inputs
|
34
|
+
b.optional :pattern
|
35
|
+
|
36
|
+
# Calculates min and max from length validations for numeric inputs
|
37
|
+
b.optional :min_max
|
38
|
+
|
39
|
+
# Calculates readonly automatically from readonly attributes
|
40
|
+
b.optional :readonly
|
41
|
+
|
42
|
+
## Inputs
|
43
|
+
b.use :label_input
|
44
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
45
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
46
|
+
|
47
|
+
## full_messages_for
|
48
|
+
# If you want to display the full error message for the attribute, you can
|
49
|
+
# use the component :full_error, like:
|
50
|
+
#
|
51
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
52
|
+
end
|
53
|
+
|
54
|
+
# The default wrapper to be used by the FormBuilder.
|
55
|
+
config.default_wrapper = :default
|
56
|
+
|
57
|
+
# Define the way to render check boxes / radio buttons with labels.
|
58
|
+
# Defaults to :nested for bootstrap config.
|
59
|
+
# inline: input + label
|
60
|
+
# nested: label > input
|
61
|
+
config.boolean_style = :nested
|
62
|
+
|
63
|
+
# Default class for buttons
|
64
|
+
config.button_class = 'btn'
|
65
|
+
|
66
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
67
|
+
# :first lists the first message for each field.
|
68
|
+
# Use :to_sentence to list all errors for each field.
|
69
|
+
# config.error_method = :first
|
70
|
+
|
71
|
+
# Default tag used for error notification helper.
|
72
|
+
config.error_notification_tag = :div
|
73
|
+
|
74
|
+
# CSS class to add for error notification helper.
|
75
|
+
config.error_notification_class = 'error_notification'
|
76
|
+
|
77
|
+
# ID to add for error notification helper.
|
78
|
+
# config.error_notification_id = nil
|
79
|
+
|
80
|
+
# Series of attempts to detect a default label method for collection.
|
81
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
82
|
+
|
83
|
+
# Series of attempts to detect a default value method for collection.
|
84
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
85
|
+
|
86
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
87
|
+
# config.collection_wrapper_tag = nil
|
88
|
+
|
89
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
90
|
+
# config.collection_wrapper_class = nil
|
91
|
+
|
92
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
93
|
+
# defaulting to :span.
|
94
|
+
# config.item_wrapper_tag = :span
|
95
|
+
|
96
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
97
|
+
# config.item_wrapper_class = nil
|
98
|
+
|
99
|
+
# How the label text should be generated altogether with the required text.
|
100
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
101
|
+
|
102
|
+
# You can define the class to use on all labels. Default is nil.
|
103
|
+
# config.label_class = nil
|
104
|
+
|
105
|
+
# You can define the default class to be used on forms. Can be overriden
|
106
|
+
# with `html: { :class }`. Defaulting to none.
|
107
|
+
# config.default_form_class = nil
|
108
|
+
|
109
|
+
# You can define which elements should obtain additional classes
|
110
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
111
|
+
|
112
|
+
# Whether attributes are required by default (or not). Default is true.
|
113
|
+
# config.required_by_default = true
|
114
|
+
|
115
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
116
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
117
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
118
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
119
|
+
# change this configuration to true.
|
120
|
+
config.browser_validations = false
|
121
|
+
|
122
|
+
# Collection of methods to detect if a file type was given.
|
123
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
124
|
+
|
125
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
126
|
+
# to match as key, and the input type that will be used when the field name
|
127
|
+
# matches the regexp as value.
|
128
|
+
# config.input_mappings = { /count/ => :integer }
|
129
|
+
|
130
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
131
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
132
|
+
# config.wrapper_mappings = { string: :prepend }
|
133
|
+
|
134
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
135
|
+
# override default inputs.
|
136
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
137
|
+
|
138
|
+
# Default priority for time_zone inputs.
|
139
|
+
# config.time_zone_priority = nil
|
140
|
+
|
141
|
+
# Default priority for country inputs.
|
142
|
+
# config.country_priority = nil
|
143
|
+
|
144
|
+
# When false, do not use translations for labels.
|
145
|
+
# config.translate_labels = true
|
146
|
+
|
147
|
+
# Automatically discover new inputs in Rails' autoload path.
|
148
|
+
# config.inputs_discovery = true
|
149
|
+
|
150
|
+
# Cache SimpleForm inputs discovery
|
151
|
+
# config.cache_discovery = !Rails.env.development?
|
152
|
+
|
153
|
+
# Default class for inputs
|
154
|
+
# config.input_class = nil
|
155
|
+
|
156
|
+
# Define the default class of the input wrapper of the boolean input.
|
157
|
+
config.boolean_label_class = 'checkbox'
|
158
|
+
|
159
|
+
# Defines if the default input wrapper class should be included in radio
|
160
|
+
# collection wrappers.
|
161
|
+
# config.include_default_input_wrapper_class = true
|
162
|
+
|
163
|
+
# Defines which i18n scope will be used in Simple Form.
|
164
|
+
# config.i18n_scope = 'simple_form'
|
165
|
+
end
|