camaleon_cms 1.0.7 → 1.0.8

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.

Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/apps/plugins/contact_form/contact_form_helper.rb +2 -2
  3. data/app/apps/plugins/contact_form/front_controller.rb +1 -1
  4. data/app/apps/plugins/front_cache/config/initializer.rb +3 -0
  5. data/app/apps/plugins/front_cache/front_cache_helper.rb +7 -1
  6. data/app/assets/javascripts/admin/actions.js +11 -1
  7. data/app/assets/javascripts/admin/elfinder/upload_elfinder.js +1 -0
  8. data/app/assets/javascripts/admin/libraries.js +24 -0
  9. data/app/assets/javascripts/admin/modal.js +1 -0
  10. data/app/assets/javascripts/admin/nav-menu.js +14 -1
  11. data/app/assets/stylesheets/admin/custom_admin.css.scss +25 -3
  12. data/app/controllers/admin/settings_controller.rb +5 -0
  13. data/app/controllers/api/api_controller.rb +17 -20
  14. data/app/controllers/concerns/frontend_concern.rb +6 -2
  15. data/app/decorators/site_decorator.rb +19 -2
  16. data/app/helpers/admin/menus_helper.rb +1 -0
  17. data/app/helpers/camaleon_helper.rb +2 -0
  18. data/app/helpers/session_helper.rb +14 -13
  19. data/app/helpers/short_code_helper.rb +104 -39
  20. data/app/views/admin/appearances/nav_menus/_custom_menus.html.erb +29 -0
  21. data/app/views/admin/appearances/nav_menus/index.html.erb +5 -5
  22. data/app/views/admin/posts/form.html.erb +1 -1
  23. data/app/views/admin/settings/custom_fields/_render.html.erb +4 -3
  24. data/app/views/admin/settings/shortcodes.html.erb +37 -0
  25. data/app/views/default_theme/sitemap.html.erb +6 -3
  26. data/app/views/default_theme/sitemap.xml.builder +13 -1
  27. data/app/views/layouts/admin/_footer.html.erb +1 -1
  28. data/config/locales/admin/en.yml +3 -1
  29. data/config/routes/admin.rb +1 -2
  30. data/config/routes/frontend.rb +2 -2
  31. data/lib/camaleon_cms/version.rb +1 -1
  32. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 131a13eefc84861802b2115956ae6dd952a34b04
4
- data.tar.gz: f66a3b0b3b430310afd29eea8f2ab31ff5520ab0
3
+ metadata.gz: 8e67f1be72288c728d249247f0dfe7f6caea78f3
4
+ data.tar.gz: 75092f52ee20f970a60b5f3fccd28905d1d21304
5
5
  SHA512:
6
- metadata.gz: 149b43772e79e4f34b89606db246b88122f7e3aad450b657d7fc0a0f097722b0ce0b56ad1eb3b6a7d38bab04042890210b4f82493c2d3302ca1bc40fb7bd6058
7
- data.tar.gz: 5c86f3f41673b761f2d78616a4afe158c5f499b4055520d5a4b6016781540977d65d9556955d1d5343bf0a50c2514a636cac91ca586b84948015f8ce105d5d71
6
+ metadata.gz: a20628ee74729584fccc227a9c1c1c80748449a9ddfa780ad21c9ec7328efd507e6da8150895dd4fe28689fe3a4ccdea49acee34133aa27514e6d61dd74b12ce
7
+ data.tar.gz: 5265b4b7ebeed15f0c1f35e99f961560dfcc29c9bf73b67c9275269f248019fa7030a7cc39b15dfe00ffca48cdecb0be7a130bb701a49a0188abebc9c592728b
@@ -78,11 +78,11 @@ module Plugins::ContactForm::ContactFormHelper
78
78
  end
79
79
 
80
80
  def contact_form_app_before_load
81
-
81
+ shortcode_add('forms', plugin_view("contact_form", "forms_shorcode"), "This is a shortocode for contact form to permit you to put your contact form in any content.
82
+ Sample: [forms slug='key-for-my-form']")
82
83
  end
83
84
 
84
85
  def contact_form_front_before_load
85
- shortcode_add('forms', plugin_view("contact_form", "forms_shorcode"))
86
86
  append_asset_libraries({"plugin_contact_form"=> { css: [plugin_asset_path("contact_form", "css/front/railsform")] }})
87
87
  end
88
88
  end
@@ -37,7 +37,7 @@ class Plugins::ContactForm::FrontController < Apps::PluginsFrontController
37
37
  validate = false
38
38
  end
39
39
  if f[:field_type].to_s == "email"
40
- if !fields[cid].match(/\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/)
40
+ if !fields[cid].match(/\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,10}\z/)
41
41
  errors << "#{label}: #{settings[:railscf_message][:invalid_email]}"
42
42
  validate = false
43
43
  end
@@ -0,0 +1,3 @@
1
+ Site.all.each do |site|
2
+ site.set_option("refresh_cache", true)
3
+ end
@@ -10,7 +10,13 @@ module Plugins::FrontCache::FrontCacheHelper
10
10
 
11
11
  # save as cache all pages configured on settings of this plugin for public users
12
12
  def front_cache_front_before_load
13
- return if signin?
13
+ if current_site.get_option("refresh_cache") # clear cache every restart server
14
+ front_cache_clean
15
+ current_site.set_option("refresh_cache", false)
16
+ end
17
+
18
+ return if signin? # avoid cache if current visitor is logged in
19
+
14
20
  cache_key = front_cache_get_key
15
21
  ActionController::Base.page_cache_directory = Rails.root.join("tmp", "cache", "pages")
16
22
  if page_cache_exist?(cache_key) # recover cache file
@@ -80,4 +80,14 @@ Object.size = function(obj) {
80
80
  }
81
81
  return size;
82
82
  };
83
- /* EOF NEW OBJECT(GET SIZE OF ARRAY) */
83
+ /* EOF NEW OBJECT(GET SIZE OF ARRAY) */
84
+
85
+ // this is a fix for multiples modals when a modal was closed (reactivate scroll for next modal)
86
+ function modal_fix_multiple(){
87
+ var activeModal = $('.modal.in:last', 'body').data('bs.modal');
88
+ if (activeModal) {
89
+ activeModal.$body.addClass('modal-open');
90
+ activeModal.enforceFocus();
91
+ activeModal.handleUpdate();
92
+ }
93
+ }
@@ -186,6 +186,7 @@
186
186
  });
187
187
  modal_elfinder.on('hidden.bs.modal', function (e){
188
188
  $("#modal_elfinder").remove();
189
+ try{ modal_fix_multiple(); }catch(e){}
189
190
  });
190
191
  }
191
192
 
@@ -122,6 +122,30 @@ var init_form_validations = function(form){
122
122
  if($that.val()) set_texts($that.val())
123
123
  });
124
124
  };
125
+
126
+ // create inline input file uploader with an icon to upload file
127
+ // options: all options needed for uploader
128
+ // you can add an attribute "data-format" in the input to define the file formats required
129
+ $.fn.input_upload_field = function(options){
130
+ this.each(function(){
131
+ var input = $(this);
132
+ var def = {
133
+ type: (input.attr("data-format") || "image"),
134
+ selected: function(res){
135
+ var file = _.first(res);
136
+ input.val(file.url.to_url());
137
+ }
138
+ };
139
+ if(!input.parent().hasClass("input-group")){
140
+ input.wrap('<div class="group-input-fields-content input-group"></div>');
141
+ input.after('<span class="input-group-addon btn_upload"><i class="fa fa-upload"></i> </span>');
142
+ input.addClass("form-control");
143
+ }
144
+ input.next("span").click(function(){
145
+ $.fn.upload_elfinder($.extend({}, def, (options || {})));
146
+ });
147
+ });
148
+ }
125
149
  })(jQuery);
126
150
 
127
151
  // jquery custom validations and default values
@@ -103,6 +103,7 @@ function open_modal(settings){
103
103
  // on modal hide
104
104
  modal.on("hidden.bs.modal", function(e){
105
105
  if(!$(e["currentTarget"]).attr("data-skip_destroy")) $(e["currentTarget"]).remove();
106
+ modal_fix_multiple();
106
107
  });
107
108
 
108
109
  if(settings.zindex) modal.css("z-index", settings.zindex);
@@ -18,7 +18,7 @@ function do_add_item_menu(data){
18
18
 
19
19
  }
20
20
  // custom fields icon
21
- if(main_menus_panel.attr("data-fields_support")) link_data += '<a class="text-edit" title="'+I18n("button.settings")+'" href="'+data.url_content+'" onclick="do_settings_menu(this); return false;" rel="1"><i class="fa fa-cog"></i></a>';
21
+ if(main_menus_panel.attr("data-fields_support") == "true") link_data += '<a class="text-edit" title="'+I18n("button.settings")+'" href="'+data.url_content+'" onclick="do_settings_menu(this); return false;" rel="1"><i class="fa fa-cog"></i></a>';
22
22
 
23
23
  var item = $('<li class="dd-item dd3-item" data-type="'+type+'" data-id="'+id+'" data-parent="'+(parent_id ? parent_id : "")+'"><div class="dd-handle dd3-handle"></div> <div class="dd3-content"><span>'+text + "</span> " + extra_html +' <span class="label">'+type+'</span> '+ link_data +' <a href="#" onclick="do_delete_menu(this); return false;" class="text-danger" title="'+I18n("button.delete")+'"><i class="fa fa-times-circle"></i></a> </div></li>');
24
24
  item.attr("data-fields", data.fields).attr("data-label", text).attr("data-link", link);
@@ -60,6 +60,19 @@ function manage_external_links(){
60
60
  f[0].reset();
61
61
  return false;
62
62
  });
63
+
64
+ // custom menus
65
+ main_menus_panel.find(".add_links_custom_to_menu").click(function(){
66
+ var $parent = $(this).parents(".panel");
67
+ $parent.find(":checkbox").filter(":checked").each(function()
68
+ {
69
+ var data = $(this).parents(".class_type").data();
70
+ var data_l = $(this).parents(".class_slug").data();
71
+ do_add_item_menu({type: 'external', link: $(this).val(), text: $(this).parent().text(), url_content: RENDER_FORM});
72
+ $(this).removeAttr("checked");
73
+ });
74
+ return false;
75
+ });
63
76
  }
64
77
 
65
78
  function do_delete_menu(link){
@@ -141,8 +141,19 @@
141
141
  //margin-top: -25px;
142
142
  }
143
143
 
144
+ // custom fields render in forms
144
145
  .item-custom-field{
145
146
  margin-bottom: 15px;
147
+ > label{
148
+ display: block;
149
+ .shortcode_field{
150
+ display: none;
151
+ font-weight: normal;
152
+ }
153
+ }
154
+ &:hover > label .shortcode_field{
155
+ display: block;
156
+ }
146
157
  .actions{
147
158
  overflow: hidden;
148
159
  width: 67px;
@@ -159,13 +170,24 @@
159
170
  }
160
171
 
161
172
  // intro js custom
162
- .main-header.introjs-fixParent{
163
- width: 100%;
164
- .navbar{
173
+ .main-header{
174
+ &.introjs-fixParent{
165
175
  width: 100%;
176
+ .navbar{
177
+ width: 100%;
178
+ }
179
+ }
180
+ .logo img{
181
+ max-width: 100%;
182
+ max-height: 100%;
166
183
  }
167
184
  }
168
185
  //.introjs-skipbutton{ display: none; }
169
186
  #modal_elfinder{
170
187
  z-index: 99999;
188
+ }
189
+
190
+ // fix tinymce fullscreen
191
+ div.mce-fullscreen{
192
+ z-index: 9999;
171
193
  }
@@ -37,6 +37,11 @@ class Admin::SettingsController < AdminController
37
37
  def languages
38
38
  end
39
39
 
40
+ # render the list of shortcodes
41
+ def shortcodes
42
+
43
+ end
44
+
40
45
  # save language customizations
41
46
  def save_languages
42
47
  current_site.set_meta("languages_site", params[:lang])
@@ -1,28 +1,25 @@
1
- class Api::ApiController < ActionController::Base
2
- include CamaleonHelper
3
- include SessionHelper
4
- include SiteHelper
5
- include HtmlHelper
6
- include UserRolesHelper
7
- include ShortCodeHelper
8
- include PluginsHelper
9
- include ThemeHelper
10
- include HooksHelper
11
- include ContentHelper
12
- include CaptchaHelper
13
- include UploaderHelper
14
-
15
- before_action -> { doorkeeper_authorize! :client }
16
- respond_to :json
1
+ class Api::ApiController < CamaleonController
2
+ #before_action -> { doorkeeper_authorize! :client }
17
3
 
18
4
  def account
19
- render json: current_resource_owner
5
+ render json: current_user
20
6
  end
21
7
 
22
- private
8
+ def render_json_error(internal_message = 'Unexpected error', code = 100, status = 404, user_message = 'Unexpected error')
9
+ error = {
10
+ 'userMessage': user_message,
11
+ 'internalMessage': internal_message,
12
+ 'code': code
13
+ }
14
+ render :json => error, :status => status
15
+ end
23
16
 
24
- def current_resource_owner
25
- User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
17
+ def render_json_ok(message = 'Success', status = 200, more_info = {})
18
+ msg = {
19
+ message: message,
20
+ more_info: more_info
21
+ }
22
+ render :json => msg, :status => status
26
23
  end
27
24
 
28
25
  end
@@ -8,10 +8,14 @@
8
8
  =end
9
9
  module FrontendConcern extend ActiveSupport::Concern
10
10
  # visiting sitemap.xml
11
+ # With hook "on_render_sitemap" you can skip post_types, categories, tags or posts
12
+ # you can change render file and layout
13
+ # you can add custom sitemap elements in the attr "custom", like: https://github.com/owen2345/camaleon-cms/issues/106#issuecomment-146232211
14
+ # you can customize your content for html or xml format
11
15
  def sitemap
12
- r = {layout: (params[:format] == "html" ? (self.send :_layout) : false), render: "sitemap", custom: "", format: params[:format]}
16
+ r = {layout: (params[:format] == "html" ? (self.send :_layout) : false), render: "sitemap", custom: {a: a}, format: params[:format], skip_post_ids: [], skip_posttype_ids: [], skip_cat_ids: [], skip_tag_ids: []}
13
17
  hooks_run("on_render_sitemap", r)
14
- @custom_sitemap = r[:custom]
18
+ @r = r
15
19
  render r[:render], layout: r[:layout]
16
20
  end
17
21
 
@@ -68,8 +68,8 @@ class SiteDecorator < TermTaxonomyDecorator
68
68
 
69
69
  # return the category object with id or slug = slug_or_id from this site
70
70
  def the_category(slug_or_id)
71
- return the_full_categories.where(id: slug_or_id).first if slug_or_id.is_a?(Integer)
72
- return the_full_categories.find_by_slug(slug_or_id) if slug_or_id.is_a?(String)
71
+ return the_full_categories.where(id: slug_or_id).first.decorate rescue nil if slug_or_id.is_a?(Integer)
72
+ return the_full_categories.find_by_slug(slug_or_id).decorate rescue nil if slug_or_id.is_a?(String)
73
73
  end
74
74
 
75
75
  # return all categories for ths site (include all children categories)
@@ -82,6 +82,18 @@ class SiteDecorator < TermTaxonomyDecorator
82
82
  object.post_tags
83
83
  end
84
84
 
85
+ # return the post_tag object with id or slug = slug_or_id from this site
86
+ def the_tag(slug_or_id)
87
+ return object.post_tags.where(id: slug_or_id).first.decorate rescue nil if slug_or_id.is_a?(Integer)
88
+ return object.post_tags.find_by_slug(slug_or_id).decorate rescue nil if slug_or_id.is_a?(String)
89
+ end
90
+
91
+ # return the user object with id or username = id_or_username from this site
92
+ def the_user(id_or_username)
93
+ return object.users.where(id: id_or_username).first.decorate rescue nil if id_or_username.is_a?(Integer)
94
+ return object.users.find_by_username(id_or_username).decorate rescue nil if id_or_username.is_a?(String)
95
+ end
96
+
85
97
  # return all post types for this site
86
98
  def the_post_types
87
99
  object.post_types.eager_load(:metas)
@@ -145,6 +157,11 @@ class SiteDecorator < TermTaxonomyDecorator
145
157
  h.url_to_fixed("root_url", args)
146
158
  end
147
159
 
160
+ # draw bread crumb for current site
161
+ def generate_breadcrumb(add_post_type = true)
162
+ h.breadcrumb_add(self.the_title)
163
+ end
164
+
148
165
  # =============================== ADMIN =======================
149
166
  # admin root url for this site
150
167
  def the_admin_url
@@ -57,6 +57,7 @@ module Admin::MenusHelper
57
57
  items << {icon: "files-o", title: t('admin.sidebar.content_groups'), url: admin_settings_post_types_path, datas: "data-intro='#{t("admin.intro.post_type")}' data-position='right'"}
58
58
  items << {icon: "cog", title: t('admin.sidebar.custom_fields'), url: admin_settings_custom_fields_path, datas: "data-intro='#{t("admin.intro.custom_fields")}' data-position='right'"}
59
59
  items << {icon: "language", title: t('admin.sidebar.languages'), url: admin_settings_languages_path, datas: "data-intro='#{t("admin.intro.languages")}' data-position='right'"}
60
+ items << {icon: "code", title: t('admin.table.shorcodes', default: "Shortcodes"), url: admin_settings_shortcodes_path, datas: "data-intro='#{t("admin.intro.shortcodes")}' data-position='right'"}
60
61
  admin_menu_add_menu("settings", {icon: "cogs", title: t('admin.sidebar.settings'), url: "", items: items, datas: "data-intro='#{t("admin.intro.settings")}' data-position='right' data-wait='500'"})
61
62
  end
62
63
 
@@ -77,8 +77,10 @@ module CamaleonHelper
77
77
  def cama_sitemap_cats_generator(cats)
78
78
  res = []
79
79
  cats.decorate.each do |cat|
80
+ next if @r[:skip_cat_ids].include?(cat.id)
80
81
  res_posts = []
81
82
  cat.the_posts.decorate.each do |post|
83
+ next if @r[:skip_post_ids].include?(post.id)
82
84
  res_posts << "<li><a href='#{post.the_url}'>#{post.the_title}</a></li>"
83
85
  end
84
86
  res << "<li><h4><a href='#{cat.the_url}'>#{cat.the_title}</a></h4><ul>#{res_posts.join("")}</ul></li>"
@@ -33,19 +33,10 @@ module SessionHelper
33
33
  end
34
34
  end
35
35
 
36
- def login_user_with_password(username, password, remember_me=false, redirect_url = nil)
37
- data_user = {}
38
- cipher = Gibberish::AES::CBC.new(get_session_id)
39
- data_user[:password] = cipher.decrypt(password) rescue nil
36
+ def login_user_with_password(username, password)
40
37
  @user = current_site.users.find_by_username(username)
41
- r = {user: @user, params: params, password: data_user[:password], captcha_validate: true}; hooks_run('user_before_login', r)
42
- if @user && @user.authenticate(data_user[:password])
43
- login_user(@user, remember_me, redirect_url)
44
- else
45
- #TODO change flash error
46
- #flash[:error] = t('admin.login.message.fail')
47
- end
48
- @user if @user
38
+ r = {user: @user, params: params, password: password, captcha_validate: true}; hooks_run('user_before_login', r)
39
+ @user && @user.authenticate(password)
49
40
  end
50
41
 
51
42
  # check if current host is heroku
@@ -94,6 +85,10 @@ module SessionHelper
94
85
  # return current user logged in
95
86
  def current_user
96
87
  return @current_user if defined?(@current_user)
88
+ # api current user...
89
+ @current_user = calc_api_current_user
90
+ return @current_user unless @current_user.nil?
91
+
97
92
  return nil unless cookies[:auth_token].present?
98
93
  c = cookies[:auth_token].split("&")
99
94
  return nil unless c.size == 3
@@ -119,4 +114,10 @@ module SessionHelper
119
114
  session[:autor] = "Owen Peredo Diaz" unless request.session_options[:id].present?
120
115
  request.session_options[:id]
121
116
  end
122
- end
117
+
118
+ private
119
+
120
+ def calc_api_current_user
121
+ current_site.users_include_admins.find(doorkeeper_token.resource_owner_id).decorate if doorkeeper_token rescue nil
122
+ end
123
+ end
@@ -13,32 +13,14 @@ module ShortCodeHelper
13
13
  @_shortcodes_template = {}
14
14
  @_shortcodes_descr = {}
15
15
 
16
- # shortcode_add("load_libraries", nil, "Renderize the widget content in this place. Sample: [widget widget_key]")
16
+ shortcode_add("widget", nil, "Renderize the widget content in this place.
17
+ Don't forget to create and copy the shortcode of your widgets in appearance -> widgets
18
+ Sample: [widget widget_key]")
17
19
 
18
20
  shortcode_add("load_libraries",
19
21
  lambda{|attrs, args| add_asset_library(*attrs["data"].to_s.split(",")); return ""; },
20
22
  "Permit to load libraries on demand, sample: [load_libraries data='datepicker,tinymce']")
21
23
 
22
- shortcode_add("custom_field",
23
- lambda{|attrs, args|
24
- post = args[:owner]
25
- post = current_site.the_posts.find_by_slug(attrs["post_slug"]).decorate rescue nil if attrs["post_slug"].present?
26
- return "" unless post.present?
27
- field = post.get_field_object(attrs["key"])
28
- if attrs["render"].present?
29
- return render :file => "custom_fields/#{field.options["field_key"]}", :locals => {object: post, field: field, field_key: attrs["key"], attibutes: attrs}
30
- else
31
- return post.the_field(attrs["key"])
32
- end
33
- },
34
- "Permit you to include your custom fields in anywhere.
35
- key: slug or key of the custom_field
36
- attrs: custom html attributes
37
- render: (true) enable to render the custom field as html. (Sample text_field: <span>my_field_value</span>)
38
- post_slug: (Optional, default current post) slug or key of a Post.
39
- Sample1: [custom_field key='subtitle']
40
- Sample2: [custom_field key='subtitle' post_slug='contact' render=true attrs='style=\"width: 50px;\"'] // return the custom field of page with slug = contact")
41
-
42
24
  shortcode_add("asset",
43
25
  lambda{|attrs, args|
44
26
  url = attrs["as_path"].present? ? ActionController::Base.helpers.asset_url(attrs["file"]) : ActionController::Base.helpers.asset_url(attrs["file"])
@@ -56,26 +38,27 @@ module ShortCodeHelper
56
38
  add image='true' to generate the image tag with this url),
57
39
  sample: <img src=\"[asset as_path='true' file='themes/my_theme/assets/img/signature.png']\" /> or [asset image='true' file='themes/my_theme/assets/img/signature.png' style='height: 50px;']")
58
40
 
59
- shortcode_add("post_url",
41
+ shortcode_add("data",
60
42
  lambda{|attrs, args|
61
- post = current_site.the_post(attrs["id"].to_i) if attrs["id"].present?
62
- post = current_site.the_post(attrs["key"].to_s) if attrs["key"].present?
63
- if post.present?
64
- if attrs["link"].present?
65
- return ActionController::Base.helpers.link_to(attrs["title"].present? ? attrs["title"].html_safe : post.the_title, post.the_url, target: attrs["target"])
66
- else
67
- return post.the_url
68
- end
69
- end
70
- return ""
43
+ cama_shortcode_data(attrs, args) rescue ""
71
44
  },
72
- "Permit to generate the url of a post (add path='' to generate the path and not the full url,
73
- add id='123' to use the POST ID,
74
- add key='my_slug' to use the POST SLUG,
75
- add link='true' to generate the full link,
76
- add title='my title' text of the link (default post title),
77
- add target='_blank' to open the link in a new window this is valid only if link is present),
78
- sample: [post_url id='122' link=true target='_blank']")
45
+ "Permit to generate specific data of a post.
46
+ Attributes:
47
+ object: (String, defaut post) Model name: post | post_type | category | post_tag | site | user
48
+ id: (Integer) Post id
49
+ key: (String) Post slug
50
+ field: (String) Custom field key, you can add render_field='true' to render field as html element, also you can add index=2 to indicate the value in position 2 for multitple values
51
+ attr: (String) attribute name: title | created_at | excerpt | url | link | thumb | updated_at | author_name | author_url
52
+ Note: If id and key is not present, then will be rendered of current model
53
+ Sample:
54
+ [data id='122' attr='title'] ==> return the title of post with id = 122
55
+ [data key='contact' attr='url'] ==> return the url of post with slug = contact
56
+ [data key='contact' attr='link'] ==> return the link with title as text of the link of post with slug = contact
57
+ [data object='site' attr='url'] ==> return the url of currrent site
58
+ [data key='page' object='post_type' attr='url'] ==> return the url of post_type with slug = page
59
+ [data field=icon index=2] ==> return the second value (multiple values) for this custom field with key=icon of current object
60
+ [data key='contact' field='sub_title'] ==> return the value of the custom_field with key=sub_title registered for post.slug = contact
61
+ [data object='site' field='sub_title'] ==> return the value of the custom_field with key=sub_title registered for current_site")
79
62
  end
80
63
 
81
64
  # add shortcode
@@ -174,4 +157,86 @@ module ShortCodeHelper
174
157
  end
175
158
  res
176
159
  end
160
+
161
+ # execute shortcode data
162
+ def cama_shortcode_data(attrs, args)
163
+ res = ""
164
+ object = attrs["object"] || "post"
165
+ attr = attrs["attr"] || "title"
166
+ model = cama_shortcode_model_parser(object, attrs) || args[:owner]
167
+ return res unless model.present?
168
+
169
+ if attrs["field"].present? # model custom fields
170
+ field = model.get_field_object(attrs["field"])
171
+ if attrs["render_field"].present?
172
+ return render :file => "custom_fields/#{field.options["field_key"]}", :locals => {object: model, field: field, field_key: attrs["field"], attibutes: attrs}
173
+ else
174
+ if attrs["index"]
175
+ res = model.the_fields(attrs["field"])[attrs["index"].to_i-1] rescue ""
176
+ else
177
+ res = model.the_field(attrs["field"])
178
+ end
179
+ return res
180
+ end
181
+
182
+ else # model attributes
183
+ case attr
184
+ when "title"
185
+ res = model.the_title
186
+ when "created_at"
187
+ res = model.the_created_at
188
+ when "updated_at"
189
+ res = model.the_updated_at
190
+ when "excerpt"
191
+ res = model.the_excerpt rescue ""
192
+ when "url"
193
+ res = model.the_url rescue ""
194
+ when "link"
195
+ res = model.the_link rescue ""
196
+ when "thumb"
197
+ case object
198
+ when "site"
199
+ res = model.the_logo
200
+ when "user"
201
+ res = model.the_avatar
202
+ else
203
+ res = model.the_thumb_url
204
+ end
205
+ when "author_name"
206
+ res = object=="post" ? model.the_author.the_name : ""
207
+ when "author_url"
208
+ res = object=="post" ? model.the_author.the_url : ""
209
+ end
210
+ end
211
+ res
212
+ end
213
+
214
+ # return the model object according to the type
215
+ def cama_shortcode_model_parser(object, attrs)
216
+ model = nil
217
+ case object
218
+ when "post"
219
+ model = current_site.the_post(attrs["id"].to_i) if attrs["id"].present?
220
+ model = current_site.the_post(attrs["key"].to_s) if attrs["key"].present?
221
+
222
+ when "post_type"
223
+ model = current_site.the_post_type(attrs["id"].to_i) if attrs["id"].present?
224
+ model = current_site.the_post_type(attrs["key"].to_s) if attrs["key"].present?
225
+
226
+ when "category"
227
+ model = current_site.the_category(attrs["id"].to_i) if attrs["id"].present?
228
+ model = current_site.the_category(attrs["key"].to_s) if attrs["key"].present?
229
+
230
+ when "post_tag"
231
+ model = current_site.the_tag(attrs["id"].to_i) if attrs["id"].present?
232
+ model = current_site.the_tag(attrs["key"].to_s) if attrs["key"].present?
233
+
234
+ when "site"
235
+ model = current_site
236
+ when "user"
237
+ model = current_site.the_user(attrs["id"].to_i) if attrs["id"].present?
238
+ model = current_site.the_user(attrs["key"].to_s) if attrs["key"].present?
239
+ end
240
+ model
241
+ end
177
242
  end
@@ -0,0 +1,29 @@
1
+ <% r = {custom_menus: {}, menu: @nav_menu}; hooks_run("nav_menu_custom", r) %>
2
+ <% if r[:custom_menus].present? %>
3
+ <div class="panel panel-default panel-toggled custom_menus">
4
+ <div class="panel-heading">
5
+ <h4 data-type="post_type" class="panel-title class_type">
6
+ <%= t("admin.menus.custom_menus", default: "Custom Menus") %>
7
+ </h4>
8
+ <ul class="panel-controls">
9
+ <li><a class="panel-collapse" href="#" title=""><span class="fa fa-angle-down"></span></a></li>
10
+ </ul>
11
+ </div>
12
+ <div class="panel-body">
13
+ <div class="tab-pane active class_type">
14
+ <ul class="">
15
+ <% r[:custom_menus].each do |k, item| %>
16
+ <li>
17
+ <label class="class_slug">
18
+ <input type="checkbox" value="<%= item[:url] %>"> <%= item[:title] %>
19
+ </label>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ </div>
24
+ <div class="panel-footer">
25
+ <button type="" class="add_links_custom_to_menu btn btn-primary pull-right"><%= t('admin.button.add_menu') %> <i class="fa fa-arrow-right"></i></button>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ <% end %>
@@ -20,9 +20,7 @@
20
20
  <%= pt.the_title %>
21
21
  </h4>
22
22
  <ul class="panel-controls">
23
- <!--<li><a href="#" class="panel-fullscreen"><span class="fa fa-expand"></span></a></li>-->
24
- <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a>
25
- </li>
23
+ <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a> </li>
26
24
  </ul>
27
25
  </div>
28
26
  <div class="panel-body nav-tabs-vertical0" id="acc-<%= pt.slug %>" style="padding: 0">
@@ -70,12 +68,14 @@
70
68
  </div>
71
69
  </div>
72
70
  <div class="panel-footer">
73
- <button class="add_links_to_menu btn btn-primary pull-right" type=""><%= t('admin.button.add_menu') %>
74
- <i class="fa fa-arrow-right"></i></button>
71
+ <button class="add_links_to_menu btn btn-primary pull-right" type=""><%= t('admin.button.add_menu') %><i class="fa fa-arrow-right"></i></button>
75
72
  </div>
76
73
  </div>
77
74
  </div>
78
75
  <% end %>
76
+
77
+ <%= render "custom_menus" %>
78
+
79
79
  <div class="panel panel-default panel-toggled">
80
80
  <div class="panel-heading">
81
81
  <h4 class="panel-title"><%= t('admin.menus.external_link') %></h4>
@@ -53,7 +53,7 @@
53
53
  </div>
54
54
 
55
55
  <!-- render all custom fields assigned to this post -->
56
- <%= render partial: "admin/settings/custom_fields/render", locals: {record: @post, field_groups: @post.get_field_groups({kind: "Post", include_parent: true})} %>
56
+ <%= render partial: "admin/settings/custom_fields/render", locals: {record: @post, field_groups: @post.get_field_groups({kind: "Post", include_parent: true}), show_shortcode: true} %>
57
57
 
58
58
  <% unless @post.draft? || @post.new_record? %>
59
59
  <% if @post.manage_comments?(@post_type) %>
@@ -30,11 +30,12 @@
30
30
  <%= @field.the_name %>
31
31
  <small class="hidden">(<%= @field.options[:field_key] %>)</small>
32
32
  <%= raw "<em class='text-danger'>*</em>" if @field.options[:required].to_s.to_bool %>
33
+ <% if defined? show_shortcode %>
34
+ <small class="pull-right shortcode_field"><code>[data field='<%= @field.slug %>']</code></small>
35
+ <% end %>
33
36
  </label><br>
34
37
  <% if @field.description.present? %>
35
- <p>
36
- <small><%= @field.the_description %></small>
37
- </p>
38
+ <p><small><%= @field.the_description %></small></p>
38
39
  <% end %>
39
40
  <input name="<%= @field_name %>[<%= @field.slug %>][id]" type="hidden" value="<%= @field.id %>"/>
40
41
  <div id="content-field-<%= @rand %>" class="editor-custom-fields">
@@ -0,0 +1,37 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <div class="panel panel-default">
4
+ <div class="panel-heading">
5
+ <h3 class="panel-title"><%= t("admin.table.short_code") %></h3>
6
+ </div>
7
+ <div class="panel-body">
8
+ <table class="table" id="shortcodes_list">
9
+ <thead>
10
+ <tr>
11
+ <th><%= t("admin.shortcodes.key", default: "Key") %></th>
12
+ <th><%= t("admin.table.description") %></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% @_shortcodes.each do |code| %>
17
+ <tr>
18
+ <td>
19
+ <code>[<%= code %>]</code>
20
+ </td>
21
+ <td class="col_descr"><%= @_shortcodes_descr[code] %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+ <%= content_tag("div", t('admin.message.data_found_list'), class: "alert alert-warning") if @_shortcodes.empty? %>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <script>
32
+ jQuery(function(){
33
+ $("#shortcodes_list .col_descr").each(function(){
34
+ $(this).html($(this).html().replace(/\n/g, "<br>"));
35
+ });
36
+ })
37
+ </script>
@@ -2,19 +2,22 @@
2
2
  <li>
3
3
  <h2><a href="<%= current_site.the_url %>"><%= current_site.the_title %></a></h2>
4
4
  </li>
5
- <% current_site.post_types.decorate.each do |ptype| %>
5
+ <% current_site.post_types.decorate.each do |ptype| next if @r[:skip_posttype_ids].include?(ptype.id) %>
6
6
  <li>
7
7
  <h3><a href="<%= ptype.the_url %>"><%= ptype.the_title %></a></h3>
8
8
  <% if ptype.manage_categories? %>
9
9
  <%= raw(cama_sitemap_cats_generator(ptype.the_categories)) %>
10
10
  <% else %>
11
11
  <ul>
12
- <% ptype.the_posts.decorate.each do |post| %>
12
+ <% ptype.the_posts.decorate.each do |post| next if @r[:skip_post_ids].include?(post.id) %>
13
13
  <li><a href='<%= post.the_url %>'><%= post.the_title %></a></li>
14
14
  <% end %>
15
15
  </ul>
16
16
  <% end %>
17
17
  </li>
18
18
  <% end %>
19
- <%= raw @custom_sitemap %>
19
+
20
+ <% @r[:custom].each do |key, item| %>
21
+ <li><a href='<%= item[:url] %>'><%= item[:title] %></a></li>
22
+ <% end %>
20
23
  </ul>
@@ -9,6 +9,7 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
9
9
  end
10
10
 
11
11
  for post in current_site.the_posts.decorate do
12
+ next if @r[:skip_post_ids].include?(post.id)
12
13
  xml.url do
13
14
  xml.loc post.the_url(locale: lang)
14
15
  xml.lastmod post.updated_at
@@ -18,6 +19,7 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
18
19
  end
19
20
 
20
21
  for cat in current_site.full_categories.no_empty.decorate do
22
+ next if @r[:skip_cat_ids].include?(cat.id)
21
23
  xml.url do
22
24
  xml.loc cat.the_url(locale: lang)
23
25
  xml.lastmod cat.updated_at
@@ -27,6 +29,7 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
27
29
  end
28
30
 
29
31
  for ptype in current_site.post_types.decorate do
32
+ next if @r[:skip_posttype_ids].include?(ptype.id)
30
33
  xml.url do
31
34
  xml.loc ptype.the_url(locale: lang)
32
35
  xml.lastmod ptype.updated_at
@@ -36,6 +39,7 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
36
39
  end
37
40
 
38
41
  for tag in current_site.post_tags.decorate do
42
+ next if @r[:skip_tag_ids].include?(tag.id)
39
43
  xml.url do
40
44
  xml.loc tag.the_url(locale: lang)
41
45
  xml.lastmod tag.updated_at
@@ -44,5 +48,13 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
44
48
  end
45
49
  end
46
50
  end
47
- instance_eval(@custom_sitemap)
51
+
52
+ @r[:custom].each do |key, item|
53
+ xml.url do
54
+ xml.loc item[:url]
55
+ xml.lastmod item[:lastmod] || Date.today.to_s
56
+ xml.changefreq item[:changefreq] || "monthly"
57
+ xml.priority item[:priority] || "0.5"
58
+ end
59
+ end
48
60
  end
@@ -6,7 +6,7 @@
6
6
  <a id="link_see_intro" href="#" onclick="init_intro(); return false;"><i class="fa fa-tv"></i> See Intro.</a>
7
7
  </div>
8
8
  <div class="pull-right">
9
- <b>Version</b><%= CamaleonCms::VERSION %>
9
+ <b>Version </b><%= CamaleonCms::VERSION %>
10
10
  </div>
11
11
  </div>
12
12
  </div>
@@ -485,6 +485,7 @@ en:
485
485
  youtube: 'Youtube'
486
486
  more_actions: 'More actions'
487
487
  more_actions_info: 'More actions...'
488
+ shorcodes: "Shortcodes"
488
489
  themes:
489
490
  footer_copyright: 'Footer Copyright'
490
491
  theme_select: 'Select Theme'
@@ -603,4 +604,5 @@ en:
603
604
  sites: "This module permit you to manage your sub sites, i.e. you can create unlimited sites like this (This is visible only for main site). Check /config/system.json to customize settings."
604
605
  custom_fields: "This section permit you to extend easily your contents, themes,... by custom fields."
605
606
  post_type: "In this module you can manage your content groups without programing anything."
606
- languages: "This module permit you to manage all languages for your site. Also you can configure the language for your admin panel."
607
+ languages: "This module permit you to manage all languages for your site. Also you can configure the language for your admin panel."
608
+ shortcodes: "In this section you can see all available shortcodes to use in your contents."
@@ -44,16 +44,15 @@ Rails.application.routes.draw do
44
44
 
45
45
  namespace :settings do
46
46
  resources :post_types
47
-
48
47
  resources :custom_fields do
49
48
  collection do
50
49
  post 'get_items/:key', action: :get_items, as: :get_items
51
50
  post "reorder"
52
51
  end
53
52
  end
54
-
55
53
  get 'site'
56
54
  get "languages"
55
+ get "shortcodes"
57
56
  post "languages" => :save_languages
58
57
  patch 'site_saved'
59
58
 
@@ -29,7 +29,7 @@ Rails.application.routes.draw do
29
29
 
30
30
  instance_eval(PluginRoutes.load("front"))
31
31
 
32
- get "*slug" => 'frontend#post', format: true, :as => :post1, defaults: { format: :html }, constraints: { slug: /(?!admin)[a-zA-Z0-9\._=\s\-]+/}
33
- get "*slug" => 'frontend#post', :as => :post, constraints: { slug: /(?!admin)[a-zA-Z0-9\._=\s\-]+/}
32
+ get "*slug" => 'frontend#post', format: true, :as => :post1, defaults: { format: :html }, constraints: { slug: /(?!admin)[a-zA-Z0-9\._=\s\-\/]+/}
33
+ get "*slug" => 'frontend#post', :as => :post, constraints: { slug: /(?!admin)[a-zA-Z0-9\._=\s\-\/]+/}
34
34
  end
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module CamaleonCms
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo Diaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack-page_caching
@@ -268,6 +268,7 @@ files:
268
268
  - app/apps/plugins/contact_form/views/front/index.html.erb
269
269
  - app/apps/plugins/front_cache/admin_controller.rb
270
270
  - app/apps/plugins/front_cache/config/config.json
271
+ - app/apps/plugins/front_cache/config/initializer.rb
271
272
  - app/apps/plugins/front_cache/config/locales/readme.txt
272
273
  - app/apps/plugins/front_cache/config/locales/translation.yml
273
274
  - app/apps/plugins/front_cache/config/routes_admin.txt
@@ -658,6 +659,7 @@ files:
658
659
  - app/models/widget/sidebar.rb
659
660
  - app/views/_flash_messages.html.erb
660
661
  - app/views/admin/appearances/nav_menus/_custom_fields.html.erb
662
+ - app/views/admin/appearances/nav_menus/_custom_menus.html.erb
661
663
  - app/views/admin/appearances/nav_menus/_external_menu.html.erb
662
664
  - app/views/admin/appearances/nav_menus/_menu_form.html.erb
663
665
  - app/views/admin/appearances/nav_menus/_menu_list.html.erb
@@ -724,6 +726,7 @@ files:
724
726
  - app/views/admin/settings/post_types/_form.html.erb
725
727
  - app/views/admin/settings/post_types/edit.html.erb
726
728
  - app/views/admin/settings/post_types/index.html.erb
729
+ - app/views/admin/settings/shortcodes.html.erb
727
730
  - app/views/admin/settings/site.html.erb
728
731
  - app/views/admin/settings/sites/form.html.erb
729
732
  - app/views/admin/settings/sites/index.html.erb