camaleon_cms 0.2.1 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of camaleon_cms might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +266 -0
- data/app/apps/plugins/attack/config/config.json +1 -1
- data/app/apps/plugins/contact_form/config/config.json +1 -1
- data/app/apps/plugins/contact_form/contact_form_html_helper.rb +15 -10
- data/app/apps/plugins/contact_form/front_controller.rb +1 -0
- data/app/apps/plugins/contact_form/views/admin_forms/edit.html.erb +1 -2
- data/app/apps/plugins/contact_form/views/admin_forms/index.html.erb +1 -1
- data/app/apps/plugins/contact_form/views/admin_forms/responses.html.erb +1 -1
- data/app/apps/plugins/contact_form/views/forms_shorcode.html.erb +6 -6
- data/app/apps/plugins/front_cache/config/config.json +1 -1
- data/app/apps/plugins/front_cache/views/admin/settings.html.erb +1 -1
- data/app/apps/plugins/visibility_post/config/config.json +1 -1
- data/app/apps/themes/camaleon_first/assets/css/style-ver.css.scss +59 -32
- data/app/apps/themes/camaleon_first/views/layouts/index.html.erb +2 -2
- data/app/apps/themes/default/assets/css/style.css.scss +3 -0
- data/app/apps/themes/default/views/category.html.erb +1 -1
- data/app/apps/themes/default/views/post_tag.html.erb +1 -1
- data/app/apps/themes/default/views/post_type.html.erb +1 -1
- data/app/apps/themes/default/views/search.html.erb +1 -1
- data/app/apps/themes/new/views/category.html.erb +1 -1
- data/app/apps/themes/new/views/layouts/index.html.erb +2 -2
- data/app/apps/themes/new/views/post_tag.html.erb +1 -1
- data/app/apps/themes/new/views/post_type.html.erb +1 -1
- data/app/apps/themes/new/views/search.html.erb +1 -1
- data/app/assets/{stylesheets/admin/bootstrap/images → images/admin}/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/admin/actions.js +12 -205
- data/app/assets/javascripts/admin/admin-basic-manifest.js +3 -0
- data/app/assets/javascripts/admin/admin-manifest.js +14 -4
- data/app/assets/javascripts/admin/custom_fields.js +4 -2
- data/app/assets/javascripts/admin/data.js +49 -20
- data/app/assets/javascripts/admin/elfinder/upload_elfinder.js +4 -4
- data/app/assets/javascripts/admin/grid-editor.js +390 -113
- data/app/assets/javascripts/admin/i18n.js +22 -0
- data/app/assets/javascripts/admin/jquery.validate.js +2 -54
- data/app/assets/javascripts/admin/{core.js → libraries.js} +92 -76
- data/app/assets/javascripts/admin/login_manifest.js +0 -3
- data/app/assets/javascripts/admin/lte/app.js +758 -0
- data/app/assets/javascripts/admin/modal.js +76 -22
- data/app/assets/javascripts/admin/nav-menu.js +98 -39
- data/app/assets/javascripts/admin/post.js +28 -29
- data/app/assets/javascripts/admin/tinymce/skins/lightgray/content.min.css.scss +1 -1
- data/app/assets/javascripts/admin/tinymce/tinymce.min.js +11 -11
- data/app/assets/javascripts/admin/translator.js +9 -7
- data/app/assets/javascripts/admin/widgets.js +1 -0
- data/app/assets/stylesheets/admin/admin-basic-manifest.css +15 -0
- data/app/assets/stylesheets/admin/admin-manifest.css +7 -11
- data/app/assets/stylesheets/admin/bootstrap-datepicker.css.scss +472 -0
- data/app/assets/stylesheets/admin/bootstrap-datetimepicker.css.scss +339 -0
- data/app/assets/stylesheets/admin/colorpicker.css.scss +95 -0
- data/app/assets/stylesheets/admin/custom_admin.css.scss +160 -0
- data/app/assets/stylesheets/admin/elfinder-manifest.css +1 -1
- data/app/assets/stylesheets/admin/grid-editor.css.scss +14 -299
- data/app/assets/stylesheets/admin/lte/admin.css.scss +4747 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-black-light.css +176 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-black.css +154 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-blue-light.css +167 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-blue.css +142 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-green-light.css +156 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-green.css +134 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-purple-light.css +156 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-purple.css +134 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-red-light.css +156 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-red.css +134 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-yellow-light.css +156 -0
- data/app/assets/stylesheets/admin/lte/skins/skin-yellow.css +134 -0
- data/app/assets/stylesheets/admin/nav-menu.css.scss +33 -0
- data/app/controllers/admin/appearances/nav_menus_controller.rb +13 -10
- data/app/controllers/admin/appearances/themes_controller.rb +1 -2
- data/app/controllers/admin/appearances_controller.rb +0 -4
- data/app/controllers/admin/categories_controller.rb +9 -15
- data/app/controllers/admin/comments_controller.rb +8 -14
- data/app/controllers/admin/grid_editor_controller.rb +55 -0
- data/app/controllers/admin/installers_controller.rb +1 -1
- data/app/controllers/admin/media_controller.rb +1 -3
- data/app/controllers/admin/plugins_controller.rb +2 -2
- data/app/controllers/admin/post_tags_controller.rb +9 -18
- data/app/controllers/admin/posts/drafts_controller.rb +1 -9
- data/app/controllers/admin/posts_controller.rb +12 -15
- data/app/controllers/admin/sessions_controller.rb +6 -7
- data/app/controllers/admin/settings/custom_fields_controller.rb +4 -9
- data/app/controllers/admin/settings/post_types_controller.rb +6 -16
- data/app/controllers/admin/settings/sites_controller.rb +5 -7
- data/app/controllers/admin/settings_controller.rb +0 -4
- data/app/controllers/admin/user_roles_controller.rb +8 -8
- data/app/controllers/admin/users_controller.rb +8 -9
- data/app/controllers/admin_controller.rb +4 -5
- data/app/controllers/apps/plugins_admin_controller.rb +3 -3
- data/app/controllers/apps/plugins_front_controller.rb +2 -2
- data/app/controllers/apps/themes_admin_controller.rb +2 -2
- data/app/controllers/apps/themes_front_controller.rb +2 -2
- data/app/controllers/camaleon_controller.rb +0 -1
- data/app/controllers/concerns/frontend_concern.rb +1 -2
- data/app/controllers/frontend_controller.rb +25 -9
- data/app/decorators/category_decorator.rb +0 -1
- data/app/decorators/custom_field_decorator.rb +0 -1
- data/app/decorators/custom_fields_concern.rb +9 -3
- data/app/decorators/post_comment_decorator.rb +0 -1
- data/app/decorators/post_decorator.rb +10 -4
- data/app/decorators/post_tag_decorator.rb +0 -1
- data/app/decorators/post_type_decorator.rb +0 -1
- data/app/decorators/site_decorator.rb +35 -11
- data/app/decorators/term_taxonomy_decorator.rb +1 -3
- data/app/decorators/theme_decorator.rb +0 -1
- data/app/decorators/user_decorator.rb +7 -5
- data/app/decorators/widget_decorator.rb +0 -1
- data/app/helpers/admin/application_helper.rb +14 -0
- data/app/helpers/admin/menus_helper.rb +8 -8
- data/app/helpers/camaleon_helper.rb +10 -3
- data/app/helpers/captcha_helper.rb +2 -2
- data/app/helpers/frontend/application_helper.rb +0 -1
- data/app/helpers/frontend/nav_menu_helper.rb +2 -1
- data/app/helpers/frontend/seo_helper.rb +1 -2
- data/app/helpers/frontend/site_helper.rb +4 -4
- data/app/helpers/hooks_helper.rb +2 -5
- data/app/helpers/html_helper.rb +9 -7
- data/app/helpers/plugins_helper.rb +34 -8
- data/app/helpers/session_helper.rb +1 -2
- data/app/helpers/short_code_helper.rb +91 -10
- data/app/helpers/site_helper.rb +17 -8
- data/app/helpers/theme_helper.rb +34 -7
- data/app/helpers/uploader_helper.rb +6 -2
- data/app/mailers/html_mailer.rb +15 -6
- data/app/models/category.rb +2 -1
- data/app/models/concerns/custom_fields_read.rb +14 -3
- data/app/models/concerns/metas.rb +7 -4
- data/app/models/custom_field_group.rb +3 -0
- data/app/models/{concerns/metas_saved.rb → grid_template.rb} +7 -2
- data/app/models/meta.rb +0 -1
- data/app/models/nav_menu.rb +15 -1
- data/app/models/nav_menu_item.rb +10 -0
- data/app/models/post.rb +100 -6
- data/app/models/post_comment.rb +6 -0
- data/app/models/post_default.rb +9 -8
- data/app/models/post_relationship.rb +2 -0
- data/app/models/post_type.rb +36 -24
- data/app/models/site.rb +7 -16
- data/app/models/term_taxonomy.rb +3 -2
- data/app/models/theme.rb +5 -0
- data/app/models/widget/assigned.rb +3 -2
- data/app/views/admin/appearances/nav_menus/_custom_fields.html.erb +6 -0
- data/app/views/admin/appearances/{_external_menu.html.erb → nav_menus/_external_menu.html.erb} +8 -10
- data/app/views/admin/appearances/nav_menus/_menu_form.html.erb +35 -0
- data/app/views/admin/appearances/nav_menus/_menu_list.html.erb +22 -0
- data/app/views/admin/appearances/nav_menus/index.html.erb +110 -0
- data/app/views/admin/appearances/themes/index.html.erb +4 -3
- data/app/views/admin/appearances/widgets/main/_sidebar.html.erb +29 -0
- data/app/views/admin/appearances/widgets/main/form.html.erb +1 -1
- data/app/views/admin/appearances/widgets/main/index.html.erb +19 -41
- data/app/views/admin/categories/edit.html.erb +2 -6
- data/app/views/admin/categories/index.html.erb +7 -11
- data/app/views/admin/comments/form.html.erb +4 -7
- data/app/views/admin/comments/index.html.erb +24 -41
- data/app/views/admin/comments/reply.html.erb +9 -10
- data/app/views/admin/grid_editor/form.html.erb +31 -0
- data/app/views/admin/grid_editor/index.html.erb +29 -0
- data/app/views/admin/media/index.html.erb +3 -15
- data/app/views/admin/plugins/_plugins_list.html.erb +1 -2
- data/app/views/admin/post_tags/edit.html.erb +2 -6
- data/app/views/admin/post_tags/index.html.erb +3 -8
- data/app/views/admin/posts/_sidebar.html.erb +136 -0
- data/app/views/admin/posts/form.html.erb +87 -281
- data/app/views/admin/posts/index.html.erb +89 -104
- data/app/views/admin/sessions/forgot.html.erb +7 -13
- data/app/views/admin/sessions/login.html.erb +21 -11
- data/app/views/admin/sessions/register.html.erb +3 -6
- data/app/views/admin/settings/custom_fields/_meta_data.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/_render.html.erb +6 -14
- data/app/views/admin/settings/custom_fields/fields/audio.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/fields/field_attrs.html.erb +3 -5
- data/app/views/admin/settings/custom_fields/fields/file.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/fields/image.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/fields/posts.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/fields/select.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/fields/users.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/fields/video.html.erb +1 -1
- data/app/views/admin/settings/custom_fields/form.html.erb +11 -9
- data/app/views/admin/settings/custom_fields/get_items.html.erb +3 -6
- data/app/views/admin/settings/custom_fields/index.html.erb +3 -10
- data/app/views/admin/settings/languages.html.erb +2 -10
- data/app/views/admin/settings/post_types/_form.html.erb +1 -1
- data/app/views/admin/settings/post_types/edit.html.erb +2 -6
- data/app/views/admin/settings/post_types/index.html.erb +4 -12
- data/app/views/admin/settings/site.html.erb +143 -149
- data/app/views/admin/settings/sites/form.html.erb +4 -19
- data/app/views/admin/settings/sites/index.html.erb +8 -9
- data/app/views/admin/taxonomy/index.html.erb +1 -1
- data/app/views/admin/user_roles/form.html.erb +2 -3
- data/app/views/admin/user_roles/index.html.erb +2 -8
- data/app/views/admin/users/form.html.erb +14 -9
- data/app/views/admin/users/index.html.erb +3 -8
- data/app/views/admin/users/profile_edit.html.erb +21 -14
- data/app/views/default_theme/custom_fields/audio.html.erb +3 -0
- data/app/views/default_theme/custom_fields/checkbox.html.erb +3 -0
- data/app/views/default_theme/custom_fields/checkboxes.html.erb +3 -0
- data/app/views/default_theme/custom_fields/colorpicker.html.erb +3 -0
- data/app/views/default_theme/custom_fields/date.html.erb +3 -0
- data/app/views/default_theme/custom_fields/editor.html.erb +3 -0
- data/app/views/default_theme/custom_fields/email.html.erb +3 -0
- data/app/views/default_theme/custom_fields/field_attrs.html.erb +3 -0
- data/app/views/default_theme/custom_fields/file.html.erb +3 -0
- data/app/views/default_theme/custom_fields/image.html.erb +3 -0
- data/app/views/default_theme/custom_fields/numeric.html.erb +3 -0
- data/app/views/default_theme/custom_fields/phone.html.erb +3 -0
- data/app/views/default_theme/custom_fields/posts.html.erb +3 -0
- data/app/views/default_theme/custom_fields/radio.html.erb +3 -0
- data/app/views/default_theme/custom_fields/select.html.erb +3 -0
- data/app/views/default_theme/custom_fields/select_eval.html.erb +3 -0
- data/app/views/default_theme/custom_fields/text_area.html.erb +3 -0
- data/app/views/default_theme/custom_fields/text_box.html.erb +3 -0
- data/app/views/default_theme/custom_fields/url.html.erb +3 -0
- data/app/views/default_theme/custom_fields/users.html.erb +3 -0
- data/app/views/default_theme/custom_fields/video.html.erb +3 -0
- data/app/views/default_theme/layouts/index.html.erb +2 -2
- data/app/views/default_theme/{post.html.erb → single.html.erb} +1 -1
- data/app/views/default_theme/{post.rss.builder → single.rss.builder} +0 -0
- data/app/views/layouts/admin.html.erb +35 -133
- data/app/views/layouts/admin/_flash_messages.html.erb +1 -15
- data/app/views/layouts/admin/_footer.html.erb +6 -0
- data/app/views/layouts/admin/_header.html.erb +51 -0
- data/app/views/layouts/admin/_sidebar.html.erb +21 -30
- data/app/views/layouts/admin/installer.html.erb +2 -2
- data/app/views/layouts/login.html.erb +15 -33
- data/config/initializers/active_record_extension.rb +14 -2
- data/config/initializers/assets.rb +21 -7
- data/config/initializers/page_caching.rb +1 -2
- data/config/locales/admin/en.yml +17 -9
- data/config/locales/admin/es.yml +8 -3
- data/config/locales/admin/it.yml +4 -2
- data/config/locales/admin/js.yml +147 -0
- data/config/routes/admin.rb +4 -4
- data/config/routes/frontend.rb +2 -2
- data/config/system.json +1 -0
- data/db/migrate/20150926095310_rename_column_posts.rb +18 -0
- data/lib/camaleon_cms.rb +1 -1
- data/lib/camaleon_cms/engine.rb +17 -2
- data/lib/camaleon_cms/version.rb +1 -1
- data/lib/generators/camaleon_cms/gem_plugin_generator.rb +122 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/admin_controller.rb +8 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/front_controller.rb +8 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/helpers/plugins/my_plugin/main_helper.rb +22 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/models/plugins/my_plugin/my_plugin.rb +12 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/admin/index.html.erb +2 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/front/index.html.erb +2 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/layouts/readme.txt +2 -0
- data/lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json +21 -0
- data/lib/generators/camaleon_cms/install_generator.rb +1 -2
- data/lib/generators/camaleon_cms/install_template/plugin_routes.rb +1 -10
- data/lib/generators/ctheme_template/app/apps/themes/my_theme/config/config.json +5 -5
- data/lib/generators/ctheme_template/app/apps/themes/my_theme/main_helper.rb +6 -5
- data/lib/generators/ctheme_template/app/apps/themes/my_theme/views/layouts/index.html.erb +2 -2
- data/lib/plugin_routes.rb +40 -2
- metadata +257 -22
- data/app/assets/stylesheets/admin/animate/animate.min.css +0 -6
- data/app/assets/stylesheets/admin/bootstrap/bootstrap-datetimepicker.css.scss +0 -339
- data/app/assets/stylesheets/admin/bootstrap/bootstrap.min.css +0 -5
- data/app/assets/stylesheets/admin/core.scss +0 -349
- data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.eot +0 -0
- data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.svg +0 -1831
- data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.ttf +0 -0
- data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.woff +0 -0
- data/app/assets/stylesheets/admin/nav-menu.css +0 -54
- data/app/assets/stylesheets/admin/theme-default.scss +0 -8462
- data/app/models/concerns/site_public.rb +0 -23
- data/app/views/admin/appearances/menu.html.erb +0 -199
- data/lib/Gemfile +0 -25
data/app/helpers/site_helper.rb
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
See the GNU Affero General Public License (GPLv3) for more details.
|
8
8
|
=end
|
9
9
|
module SiteHelper
|
10
|
-
|
11
10
|
# return current site or assign a site as a current site
|
12
11
|
def current_site(site = nil)
|
13
12
|
@current_site = site.decorate if site.present?
|
@@ -52,18 +51,29 @@ module SiteHelper
|
|
52
51
|
@_current_theme ||= current_site.get_theme.decorate
|
53
52
|
end
|
54
53
|
|
55
|
-
# get list templates files
|
54
|
+
# get list templates files of current theme
|
56
55
|
def get_list_template_files
|
57
|
-
base_path = Rails.root.join("app", "apps", 'themes', current_theme.slug, 'views')
|
58
|
-
base_path = Pathname.new(base_path)
|
59
56
|
contained_files = []
|
60
|
-
Dir[File.join(
|
61
|
-
|
62
|
-
contained_files <<
|
57
|
+
Dir[File.join(current_theme.settings["path"], "views", '*.html.erb')].each do |path|
|
58
|
+
f_name = File.basename(path)
|
59
|
+
contained_files << f_name.split(".").first if f_name.include?('template_')
|
63
60
|
end
|
64
61
|
contained_files
|
65
62
|
end
|
66
63
|
|
64
|
+
# get list layouts files of current theme
|
65
|
+
# return an array of layouts for current theme
|
66
|
+
def get_list_layouts_files
|
67
|
+
contained_files = []
|
68
|
+
Dir[File.join(current_theme.settings["path"], "views", "layouts", '*')].each do |path|
|
69
|
+
f_name = File.basename(path)
|
70
|
+
contained_files << f_name.split(".").first unless f_name.start_with?('_')
|
71
|
+
end
|
72
|
+
contained_files
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
67
77
|
# get locale language
|
68
78
|
def current_locale
|
69
79
|
I18n.locale.to_s
|
@@ -123,5 +133,4 @@ module SiteHelper
|
|
123
133
|
$current_site = site
|
124
134
|
site_load_custom_models($current_site)
|
125
135
|
end
|
126
|
-
|
127
136
|
end
|
data/app/helpers/theme_helper.rb
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
See the GNU Affero General Public License (GPLv3) for more details.
|
8
8
|
=end
|
9
9
|
module ThemeHelper
|
10
|
-
|
11
10
|
def theme_init()
|
12
11
|
@_front_breadcrumb = []
|
13
12
|
end
|
@@ -27,7 +26,11 @@ module ThemeHelper
|
|
27
26
|
# sample: <script src="<%= theme_asset_path("js/admin.js") %>"></script> => return: /assets/themes/my_theme/assets/css/main-54505620f.css
|
28
27
|
def theme_asset_path(asset = nil, theme_name = nil)
|
29
28
|
p = "themes/#{theme_name || current_theme.slug }/assets/#{asset}"
|
30
|
-
|
29
|
+
begin
|
30
|
+
asset_url(p)
|
31
|
+
rescue NoMethodError => e
|
32
|
+
p
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
36
|
# return the full url for asset of current theme:
|
@@ -37,7 +40,25 @@ module ThemeHelper
|
|
37
40
|
# theme_asset_url("css/main.css") => return: http://myhost.com/assets/themes/my_theme/assets/css/main-54505620f.css
|
38
41
|
def theme_asset_url(asset, theme_name = nil)
|
39
42
|
p = "themes/#{theme_name || current_theme.slug }/assets/#{asset}"
|
40
|
-
|
43
|
+
begin
|
44
|
+
asset_url(p)
|
45
|
+
rescue NoMethodError => e
|
46
|
+
p
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# built asset file for current theme
|
51
|
+
# theme_name: theme key, if nill will be used current_theme.slug
|
52
|
+
# return (String), sample: theme_asset("css/mains.css") => themes/my_theme/assets/css/main.css
|
53
|
+
def theme_asset(asset, theme_name = nil)
|
54
|
+
"themes/#{theme_name || self_theme_key || current_theme.slug }/assets/#{asset}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# built asset file for current theme
|
58
|
+
# theme_name: theme key, if nill will be used current_theme.slug
|
59
|
+
# return (String), sample: theme_asset("mains.css") => themes/my_theme/main.css
|
60
|
+
def theme_gem_asset(asset, theme_name = nil)
|
61
|
+
"themes/#{theme_name || self_theme_key || current_theme.slug }/#{asset}"
|
41
62
|
end
|
42
63
|
|
43
64
|
# return theme full view path
|
@@ -54,8 +75,14 @@ module ThemeHelper
|
|
54
75
|
|
55
76
|
# return theme key for current theme file (helper|controller|view)
|
56
77
|
def self_theme_key
|
57
|
-
k = "app/apps/themes/"
|
58
|
-
|
59
|
-
f
|
78
|
+
# k = "app/apps/themes/"
|
79
|
+
k = "/themes/"
|
80
|
+
f = caller[0]
|
81
|
+
f2 = caller[1]
|
82
|
+
if f.include?(k)
|
83
|
+
f.split(k).last.split("/").first
|
84
|
+
elsif f2.include?(k)
|
85
|
+
f2.split(k).last.split("/").first
|
86
|
+
end
|
60
87
|
end
|
61
|
-
end
|
88
|
+
end
|
@@ -128,6 +128,11 @@ module UploaderHelper
|
|
128
128
|
file_path.sub(Rails.public_path.to_s, root_url)
|
129
129
|
end
|
130
130
|
|
131
|
+
# convert public url to file path
|
132
|
+
def url_to_file_path(url)
|
133
|
+
File.join(Rails.public_path, URI(url.to_s).path)
|
134
|
+
end
|
135
|
+
|
131
136
|
# crop and image and saved as imagename_crop.ext
|
132
137
|
# file: file path
|
133
138
|
# w: new width
|
@@ -206,5 +211,4 @@ module UploaderHelper
|
|
206
211
|
|
207
212
|
return [ horizontal_offset, vertical_offset ]
|
208
213
|
end
|
209
|
-
|
210
|
-
end
|
214
|
+
end
|
data/app/mailers/html_mailer.rb
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
See the GNU Affero General Public License (GPLv3) for more details.
|
8
8
|
=end
|
9
9
|
class HtmlMailer < ActionMailer::Base
|
10
|
+
include SiteHelper
|
11
|
+
include HooksHelper
|
12
|
+
include PluginsHelper
|
10
13
|
#include ApplicationHelper
|
11
14
|
default from: "Camaleon CMS <owenperedo@gmail.com>"
|
12
15
|
after_action :set_delivery_options
|
@@ -17,10 +20,6 @@ class HtmlMailer < ActionMailer::Base
|
|
17
20
|
@url_base = url_base
|
18
21
|
@current_site = current_site
|
19
22
|
|
20
|
-
if attachs.present?
|
21
|
-
attachs.each{|attach| attachments["#{File.basename(attach)}"] = File.open(attach, 'rb'){|f| f.read} }
|
22
|
-
end
|
23
|
-
|
24
23
|
mail_data = {to: email, subject: subject}
|
25
24
|
mail_data[:from] = from if from.present?
|
26
25
|
|
@@ -42,8 +41,18 @@ class HtmlMailer < ActionMailer::Base
|
|
42
41
|
self.prepend_view_path(File.join($camaleon_engine_dir, views_dir).to_s)
|
43
42
|
self.prepend_view_path(Rails.root.join(views_dir).to_s)
|
44
43
|
|
45
|
-
#
|
46
|
-
|
44
|
+
# run hook "email" to customize values
|
45
|
+
r = {template_name: template_name, layout_name: layout_name, mail_data: mail_data, files: attachs, format: "html" }
|
46
|
+
hooks_run("email", r)
|
47
|
+
|
48
|
+
if r[:files].present?
|
49
|
+
r[:files].each{|attach| attachments["#{File.basename(attach)}"] = File.open(attach, 'rb'){|f| f.read} }
|
50
|
+
end
|
51
|
+
|
52
|
+
mail(r[:mail_data]){|format| format.html { render r[:template_name], layout: r[:layout_name] } } if r[:format] == "html"
|
53
|
+
mail(r[:mail_data]){|format| format.text { render r[:template_name], layout: r[:layout_name] } } if r[:format] == "txt"
|
54
|
+
mail(r[:mail_data]) unless r[:format].present?
|
55
|
+
|
47
56
|
end
|
48
57
|
|
49
58
|
private
|
data/app/models/category.rb
CHANGED
@@ -18,7 +18,8 @@ class Category < TermTaxonomy
|
|
18
18
|
belongs_to :post_type_parent, class_name: "PostType", foreign_key: :parent_id
|
19
19
|
belongs_to :owner, class_name: "User", foreign_key: :user_id
|
20
20
|
|
21
|
-
scope :no_empty, ->{ where("count > 0") }
|
21
|
+
scope :no_empty, ->{ where("count > 0") } # return all categories that contains at least one post
|
22
|
+
scope :empty, ->{ where(count: [0,nil]) } # return all categories that does not contain any post
|
22
23
|
|
23
24
|
#scope :parents, -> { where("term_taxonomy.parent_id IS NULL") }
|
24
25
|
|
@@ -10,6 +10,7 @@ module CustomFieldsRead extend ActiveSupport::Concern
|
|
10
10
|
included do
|
11
11
|
has_many :fields, ->(object){ where(:object_class => object.class.to_s.gsub("Decorator",""))} , :class_name => "CustomField" ,foreign_key: :objectid
|
12
12
|
has_many :field_values, ->(object){where(object_class: object.class.to_s.gsub("Decorator",""))}, :class_name => "CustomFieldsRelationship", foreign_key: :objectid, dependent: :destroy
|
13
|
+
has_many :custom_field_values, :class_name => "CustomFieldsRelationship", foreign_key: :objectid, dependent: :destroy
|
13
14
|
before_destroy :_destroy_custom_field_groups
|
14
15
|
end
|
15
16
|
|
@@ -38,6 +39,9 @@ module CustomFieldsRead extend ActiveSupport::Concern
|
|
38
39
|
self.site.custom_field_groups.where(object_class: class_name, objectid: self.id)
|
39
40
|
when 'Site'
|
40
41
|
self.custom_field_groups.where(object_class: class_name)
|
42
|
+
when 'NavMenuItem'
|
43
|
+
# self.main_menu.custom_field_groups //verify this problem
|
44
|
+
NavMenu.find(self.main_menu.id).get_field_groups
|
41
45
|
when 'PostType'
|
42
46
|
if args[:kind] == "all"
|
43
47
|
self.site.custom_field_groups.where(object_class: ["PostType_Post", "PostType_Post", "PostType_PostTag", "PostType"], objectid: self.id )
|
@@ -63,6 +67,7 @@ module CustomFieldsRead extend ActiveSupport::Concern
|
|
63
67
|
# get custom field value
|
64
68
|
# _key: custom field key
|
65
69
|
# if value is not present, then return default
|
70
|
+
# return default only if the field was not registered
|
66
71
|
def get_field_value(_key, _default = nil)
|
67
72
|
v = _default
|
68
73
|
v = get_field_values(_key).first rescue _default
|
@@ -71,11 +76,19 @@ module CustomFieldsRead extend ActiveSupport::Concern
|
|
71
76
|
end
|
72
77
|
alias_method :get_field, :get_field_value
|
73
78
|
|
79
|
+
# the same as the_field() but if the value is not present, this will return default value
|
80
|
+
def get_field!(_key, _default = nil)
|
81
|
+
v = _default
|
82
|
+
v = get_field_values(_key).first rescue _default
|
83
|
+
v.present? ? v : _default
|
84
|
+
end
|
85
|
+
|
74
86
|
# get custom field values
|
75
87
|
# _key: custom field key
|
76
88
|
def get_field_values(_key)
|
77
89
|
self.field_values.where(custom_field_slug: _key).pluck(:value)
|
78
90
|
end
|
91
|
+
alias_method :get_fields, :get_field_values
|
79
92
|
|
80
93
|
# ------------- new function update field value -------------
|
81
94
|
def update_field_value(_key, value = nil)
|
@@ -206,14 +219,12 @@ module CustomFieldsRead extend ActiveSupport::Concern
|
|
206
219
|
def _destroy_custom_field_groups
|
207
220
|
class_name = self.class.to_s.gsub("Decorator","")
|
208
221
|
if ['Category','Post','PostTag'].include?(class_name)
|
209
|
-
# get_field_groups("Post").destroy_all
|
210
222
|
CustomFieldGroup.where(objectid: self.id, object_class: class_name).destroy_all
|
211
223
|
elsif ['PostType'].include?(class_name)
|
212
224
|
get_field_groups("Post").destroy_all
|
213
225
|
get_field_groups("Category").destroy_all
|
214
226
|
get_field_groups("PostTag").destroy_all
|
215
|
-
elsif ["NavMenuItem"].include?(class_name)
|
216
|
-
|
227
|
+
elsif ["NavMenuItem"].include?(class_name) # menu items doesn't include field groups
|
217
228
|
else
|
218
229
|
get_field_groups().destroy_all if get_field_groups.present?
|
219
230
|
end
|
@@ -108,10 +108,13 @@ module Metas extend ActiveSupport::Concern
|
|
108
108
|
def after_finding_meta(reset = false)
|
109
109
|
if @meta_data.nil? || reset
|
110
110
|
options = {}
|
111
|
-
if metas.count > 0
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
# if metas.count > 0
|
112
|
+
# metas.all.each do |item|
|
113
|
+
# options[item.key] = JSON.parse(item.value) rescue item.value
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
metas.all.each do |item|
|
117
|
+
options[item.key] = JSON.parse(item.value) rescue item.value
|
115
118
|
end
|
116
119
|
@meta_data = options.to_sym
|
117
120
|
end
|
@@ -25,6 +25,7 @@ class CustomFieldGroup < CustomField
|
|
25
25
|
# for select, radio and checkboxes add:
|
26
26
|
# -- multiple_options: [{"title"=>"Option Title", "value"=>"2", "default"=>"1"}, {"title"=>"abcde", "value"=>"3"}]
|
27
27
|
# -- add default for default value
|
28
|
+
# SAMPLE: my_model.add_field({"name"=>"Sub Title", "slug"=>"subtitle"}, {"field_key"=>"text_box", "translate"=>true, default_value: "Get in Touch"})
|
28
29
|
|
29
30
|
def add_manual_field(item, options)
|
30
31
|
c = get_field(item[:slug] || item["slug"])
|
@@ -85,6 +86,8 @@ class CustomFieldGroup < CustomField
|
|
85
86
|
caption = "Fields for Widget <b>(#{Widget::Main.find(self.objectid).name.translate})</b>"
|
86
87
|
when 'Theme'
|
87
88
|
caption = "Field settings for Theme <b>(#{self.objectid})</b>"
|
89
|
+
when 'NavMenu'
|
90
|
+
caption = "Field settings for Menus <b>(#{NavMenu.find(self.objectid).name})</b>"
|
88
91
|
when 'Site'
|
89
92
|
caption = "Field settings the site"
|
90
93
|
when 'PostType'
|
@@ -6,5 +6,10 @@
|
|
6
6
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
7
7
|
See the GNU Affero General Public License (GPLv3) for more details.
|
8
8
|
=end
|
9
|
-
|
10
|
-
|
9
|
+
class GridTemplate < TermTaxonomy
|
10
|
+
default_scope { where(taxonomy: :grid_template) }
|
11
|
+
# name: "title"
|
12
|
+
# description: "content of grid template"
|
13
|
+
# slug: "key for this grid template"
|
14
|
+
|
15
|
+
end
|
data/app/models/meta.rb
CHANGED
data/app/models/nav_menu.rb
CHANGED
@@ -12,26 +12,40 @@ class NavMenu < TermTaxonomy
|
|
12
12
|
has_many :children, class_name: "NavMenuItem", foreign_key: :parent_id, dependent: :destroy
|
13
13
|
belongs_to :site, :class_name => "Site", foreign_key: :parent_id
|
14
14
|
|
15
|
+
# add multiple menu items for current menu
|
15
16
|
def add_menu_items(menu_data=[])
|
16
17
|
children.destroy_all
|
17
18
|
saved_nav_items(self, menu_data) if menu_data.present?
|
18
19
|
end
|
19
20
|
|
21
|
+
# add menu item for current menu
|
22
|
+
# value: (Hash) is a hash object that contains label, type, link
|
23
|
+
# options for type: post | category | post_type | post_tag | external
|
24
|
+
# sample: {label: "my label", type: "external", link: "http://camaleon.tuzitio.com"}
|
25
|
+
# return item created
|
20
26
|
def append_menu_item (value)
|
21
27
|
item = children.new({name: value[:label]})
|
22
28
|
if item.save
|
23
29
|
item.set_meta('_default',{type: value[:type], object_id: value[:link]})
|
24
30
|
end
|
31
|
+
item
|
25
32
|
end
|
26
33
|
|
27
34
|
private
|
28
|
-
|
29
35
|
def saved_nav_items (nav_menu_item, items)
|
30
36
|
items.each do |key, value|
|
31
37
|
item = nav_menu_item.children.new({name: value[:label]})
|
32
38
|
if item.save
|
33
39
|
item.set_meta('_default',{type: value[:type], object_id: value[:link]})
|
34
40
|
saved_nav_items(item, value[:children]) if value[:children].present?
|
41
|
+
|
42
|
+
# save custom fields for this menu item
|
43
|
+
if value[:fields].present?
|
44
|
+
value[:fields].each do |k, v|
|
45
|
+
item.save_field_value(k, v)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
35
49
|
end
|
36
50
|
end
|
37
51
|
end
|
data/app/models/nav_menu_item.rb
CHANGED
@@ -16,6 +16,16 @@ class NavMenuItem < TermTaxonomy
|
|
16
16
|
after_create :update_count
|
17
17
|
#before_destroy :update_count
|
18
18
|
|
19
|
+
# return the main menu
|
20
|
+
def main_menu
|
21
|
+
ctg = self
|
22
|
+
begin
|
23
|
+
main_menu = ctg.parent
|
24
|
+
ctg = ctg.parent_item
|
25
|
+
end while ctg.present?
|
26
|
+
main_menu
|
27
|
+
end
|
28
|
+
|
19
29
|
# return the type of this menu (post|category|post_tag|post_type|external)
|
20
30
|
def get_type
|
21
31
|
self.get_option('type')
|
data/app/models/post.rb
CHANGED
@@ -29,10 +29,14 @@ end
|
|
29
29
|
|
30
30
|
class Post < PostDefault
|
31
31
|
include CategoriesTagsForPosts
|
32
|
-
default_scope ->{ where(post_class: self.name) }
|
32
|
+
default_scope ->{ where(post_class: self.name).order(post_order: :asc) }
|
33
33
|
has_many :metas, ->{ where(object_class: 'Post')}, :class_name => "Meta", foreign_key: :objectid, dependent: :destroy
|
34
|
+
|
35
|
+
# DEPRECATED
|
34
36
|
has_many :post_relationships, class_name: "PostRelationship", foreign_key: :objectid, dependent: :destroy, inverse_of: :posts
|
35
37
|
has_many :post_types, class_name: "PostType", through: :post_relationships, :source => :post_type
|
38
|
+
# END DEPRECATED
|
39
|
+
|
36
40
|
has_many :term_relationships, class_name: "TermRelationship", foreign_key: :objectid, dependent: :destroy, inverse_of: :objects
|
37
41
|
has_many :categories, class_name: "Category", through: :term_relationships, :source => :term_taxonomies
|
38
42
|
has_many :post_tags, class_name: "PostTag", through: :term_relationships, :source => :term_taxonomies
|
@@ -42,6 +46,7 @@ class Post < PostDefault
|
|
42
46
|
|
43
47
|
belongs_to :owner, class_name: "User", foreign_key: :user_id
|
44
48
|
belongs_to :parent, class_name: "Post", foreign_key: :post_parent
|
49
|
+
belongs_to :post_type, class_name: "PostType", foreign_key: :taxonomy_id
|
45
50
|
|
46
51
|
scope :visible_frontend, -> {where(status: 'published')}
|
47
52
|
scope :public_posts, -> {visible_frontend.where(visibility: ['public', ""]) } #public posts (not passwords, not privates)
|
@@ -55,11 +60,9 @@ class Post < PostDefault
|
|
55
60
|
|
56
61
|
validates_with PostUniqValidator
|
57
62
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
def post_type
|
62
|
-
@_cache_post_type ||= (post_types.reorder(nil).first || post_relationships.first.post_type)
|
63
|
+
# return the post type of this post (DEPRECATED)
|
64
|
+
def get_post_type_depre
|
65
|
+
post_types.reorder(nil).first
|
63
66
|
end
|
64
67
|
|
65
68
|
# return template assigned to this post
|
@@ -86,4 +89,95 @@ class Post < PostDefault
|
|
86
89
|
def trash?
|
87
90
|
status == 'trash'
|
88
91
|
end
|
92
|
+
|
93
|
+
# check if current post can manage content
|
94
|
+
# return boolean
|
95
|
+
def manage_content?(posttype = nil)
|
96
|
+
get_option('has_content', (posttype || self.post_type).get_option('has_content', true))
|
97
|
+
end
|
98
|
+
|
99
|
+
# check if current post can manage summary
|
100
|
+
# return boolean
|
101
|
+
def manage_summary?(posttype = nil)
|
102
|
+
get_option('has_summary', (posttype || self.post_type).get_option('has_summary', true))
|
103
|
+
end
|
104
|
+
|
105
|
+
# check if current post can manage keywords
|
106
|
+
# return boolean
|
107
|
+
def manage_keywords?(posttype = nil)
|
108
|
+
get_option('has_keywords', (posttype || self.post_type).get_option('has_keywords', true))
|
109
|
+
end
|
110
|
+
|
111
|
+
# check if current post can manage picture
|
112
|
+
# return boolean
|
113
|
+
def manage_picture?(posttype = nil)
|
114
|
+
get_option('has_picture', (posttype || self.post_type).get_option('has_picture', true))
|
115
|
+
end
|
116
|
+
|
117
|
+
# check if current post can manage template
|
118
|
+
# return boolean
|
119
|
+
def manage_template?(posttype = nil)
|
120
|
+
get_option('has_template', (posttype || self.post_type).get_option('has_template', true))
|
121
|
+
end
|
122
|
+
|
123
|
+
# check if current post can manage comments
|
124
|
+
# return boolean
|
125
|
+
def manage_comments?(posttype = nil)
|
126
|
+
get_option('has_comments', (posttype || self.post_type).get_option('has_comments', false))
|
127
|
+
end
|
128
|
+
|
129
|
+
# define post configuration for current post
|
130
|
+
# possible key values (String):
|
131
|
+
# has_content, boolean (default true)
|
132
|
+
# has_summary, boolean (default true)
|
133
|
+
# has_keywords, boolean (default true)
|
134
|
+
# has_picture, boolean (default true)
|
135
|
+
# has_template, boolean (default true)
|
136
|
+
# has_comments, boolean (default false)
|
137
|
+
# val: value for the setting
|
138
|
+
def set_setting(key, val)
|
139
|
+
set_option(key, val)
|
140
|
+
end
|
141
|
+
|
142
|
+
# assign multiple settings
|
143
|
+
def set_settings(settings = {})
|
144
|
+
settings.each do |key, val|
|
145
|
+
set_setting(key, val)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# put a new order position for this post
|
150
|
+
# new_order_position: (Integer) position number
|
151
|
+
# return nil
|
152
|
+
def set_position(new_order_position)
|
153
|
+
self.update_column("post_order", new_order_position)
|
154
|
+
end
|
155
|
+
|
156
|
+
# save the summary for current post
|
157
|
+
# summary: Text String without html
|
158
|
+
def set_summary(summary)
|
159
|
+
set_meta("summary", summary)
|
160
|
+
end
|
161
|
+
|
162
|
+
# save the thumbnail url for current post
|
163
|
+
# thumb_url: String url
|
164
|
+
def set_thumb(thumb_url)
|
165
|
+
set_meta("thumb", thumb_url)
|
166
|
+
end
|
167
|
+
|
168
|
+
# increment the counter of visitors
|
169
|
+
def increment_visits!
|
170
|
+
set_meta("visits", total_visits+1)
|
171
|
+
end
|
172
|
+
|
173
|
+
# return the quantity of visits for this post
|
174
|
+
def total_visits
|
175
|
+
get_meta("visits", 0).to_i
|
176
|
+
end
|
177
|
+
|
178
|
+
# return the quantity of comments for this post
|
179
|
+
# TODO comments count
|
180
|
+
def total_comments
|
181
|
+
self.get_meta("comments_count", 0).to_i
|
182
|
+
end
|
89
183
|
end
|