camaleon_cms 1.0.2 → 1.0.3

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 (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/apps/plugins/contact_form/assets/js/form-builder/formbuilder.js +1 -1
  3. data/app/apps/plugins/contact_form/contact_form_html_helper.rb +21 -43
  4. data/app/apps/plugins/contact_form/front_controller.rb +47 -36
  5. data/app/apps/plugins/contact_form/views/admin_forms/edit.html.erb +0 -20
  6. data/app/apps/plugins/contact_form/views/contact_form/_submission.html.erb +26 -0
  7. data/app/controllers/concerns/frontend_concern.rb +0 -53
  8. data/app/helpers/admin/application_helper.rb +1 -1
  9. data/app/helpers/site_helper.rb +1 -1
  10. data/app/views/layouts/admin/_footer.html.erb +2 -2
  11. data/config/initializers/sass.rb +83 -36
  12. data/config/sitemap.rb +1 -0
  13. data/lib/camaleon_cms.rb +1 -0
  14. data/lib/camaleon_cms/version.rb +1 -1
  15. data/lib/generators/camaleon_cms/gem_theme_generator.rb +122 -0
  16. data/lib/generators/camaleon_cms/gem_theme_template/app/controllers/plugins/my_plugin/admin_controller.rb +8 -0
  17. data/lib/generators/camaleon_cms/gem_theme_template/app/controllers/plugins/my_plugin/front_controller.rb +8 -0
  18. data/lib/generators/camaleon_cms/gem_theme_template/app/helpers/plugins/my_plugin/main_helper.rb +22 -0
  19. data/lib/generators/camaleon_cms/gem_theme_template/app/models/plugins/my_plugin/my_plugin.rb +12 -0
  20. data/lib/generators/camaleon_cms/gem_theme_template/app/views/plugins/my_plugin/admin/index.html.erb +2 -0
  21. data/lib/generators/camaleon_cms/gem_theme_template/app/views/plugins/my_plugin/front/index.html.erb +2 -0
  22. data/lib/generators/camaleon_cms/gem_theme_template/app/views/plugins/my_plugin/layouts/readme.txt +2 -0
  23. data/lib/generators/camaleon_cms/gem_theme_template/config/camaleon_plugin.json +21 -0
  24. data/lib/plugin_routes.rb +2 -0
  25. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f195f6cff8d88d9a9bc9232825dc047bc95bd9c
4
- data.tar.gz: d4e89d111af8947ac27e0d67c8b6d425745c94fc
3
+ metadata.gz: ac6264aa837e1bf65d11ef13a9ddee7d7d287a7c
4
+ data.tar.gz: 030b3f0ba1bc3720d79aa2b99923bb812f019f95
5
5
  SHA512:
6
- metadata.gz: 699091da7711e9a2c5dccf80d13dd43ff3184a12ee61acdf060f280ea900936ed605a50294e7fe3d2a5cc4eb92903167e4701c726d1cf10197ee80797c9da793
7
- data.tar.gz: 3f507c0b08044285f0b3f3ed9a1208090a2d79648d4955b1d89e5aa6be66740230bcd6ce1c48dd107e5bbf4e85108e170988d06a97f5780326441b373f03ab2d
6
+ metadata.gz: 14c3f2a6edc55438f0788693fa764c817a7b26bd899774ace020d402ab7208561380629b17a29720e2483368b7955252d98bd5379b0ce029c5f2a01eb63b39a4
7
+ data.tar.gz: b1939cf9c2dc983e74ce60eff0580a232aa534da332cca90addba07b9899ffb0db33a4089ff97be49f96915930f356ff21c168518f8c8b747bc39e0a98225d3e
@@ -1163,7 +1163,7 @@ with (obj) {
1163
1163
  '</ul>' +
1164
1164
  '</div>\n' +
1165
1165
  '<div class=\'panel-body\'>\n' +
1166
- '<div class=\'fb-no-response-fields\'>'+lang.message_no_response_fields+'</div>\n ' +
1166
+ '<div class=\'fb-no-response-fields\'>'+I18n("msg.no_response_fields")+'</div>\n ' +
1167
1167
  '<div class=\'fb-response-fields\'></div>\n' +
1168
1168
  '</div>\n' +
1169
1169
  '</div>\n' +
@@ -23,7 +23,7 @@ module Plugins::ContactForm::ContactFormHtmlHelper
23
23
  current_site.contact_forms.where({parent_id: id})
24
24
  end
25
25
 
26
- def form_value_rescue(form)
26
+ def form_value_rescue(form)
27
27
  JSON.parse(form.settings).to_sym rescue form.value
28
28
  end
29
29
 
@@ -34,7 +34,7 @@ module Plugins::ContactForm::ContactFormHtmlHelper
34
34
  object.each do |ob|
35
35
  temp = "<div class='form-group'>
36
36
  <label>[label ci]</span></label>
37
- #{ '<p>[descr ci]</p>' if ob[:field_options][:description].present?}
37
+ #{'<p>[descr ci]</p>' if ob[:field_options][:description].present?}
38
38
  <div>[ci]</div>
39
39
  </div>"
40
40
 
@@ -59,18 +59,16 @@ module Plugins::ContactForm::ContactFormHtmlHelper
59
59
  temp2= form_select_multiple_bootstrap(ob, ob[:label], "checkbox",values)
60
60
  when 'text', 'website', 'email'
61
61
  class_type = ""
62
-
63
62
  class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="website"
64
63
  class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="email"
65
-
66
- temp2= "<input #{ob[:custom_attrs].to_attr_format} type=\"#{ob[:field_type]}\" value=\"#{values[cid]}\" name=\"#{f_name}\" class=\"#{ob[:custom_class]} #{class_type}\">"
64
+ temp2 = "<input #{ob[:custom_attrs].to_attr_format} type=\"#{ob[:field_type]}\" value=\"#{values[cid]}\" name=\"#{f_name}\" class=\"#{ob[:custom_class]} #{class_type}\">"
67
65
  when 'captcha'
68
- temp2= captcha_tag(5, {}, {class: "#{ob[:custom_class]} field-captcha required"}.merge(ob[:custom_attrs]))
66
+ temp2 = captcha_tag(5, {}, {class: "#{ob[:custom_class]} field-captcha required"}.merge(ob[:custom_attrs]))
69
67
  when 'file'
70
68
  class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="website"
71
- temp2= "<input multiple=\"multiple\" type=\"file\" value=\"\" name=\"#{f_name}\" #{ob[:custom_attrs].to_attr_format} class=\"#{class_type} #{ob[:custom_class]}\">"
69
+ temp2 = "<input multiple=\"multiple\" type=\"file\" value=\"\" name=\"#{f_name}\" #{ob[:custom_attrs].to_attr_format} class=\"#{class_type} #{ob[:custom_class]}\">"
72
70
  when 'dropdown'
73
- temp2= form_select_multiple_bootstrap(ob, ob[:label], "select",values)
71
+ temp2 = form_select_multiple_bootstrap(ob, ob[:label], "select",values)
74
72
  else
75
73
  end
76
74
  r[:template] = r[:template].sub('[label ci]', for_name).sub('[ci]', temp2)
@@ -81,7 +79,6 @@ module Plugins::ContactForm::ContactFormHtmlHelper
81
79
  end
82
80
 
83
81
  def form_select_multiple_bootstrap(ob, title, type, values)
84
-
85
82
  options = ob[:field_options][:options]
86
83
  include_other_option = ob[:field_options][:include_other_option]
87
84
  other_input = ""
@@ -91,7 +88,7 @@ module Plugins::ContactForm::ContactFormHtmlHelper
91
88
  cid = ob[:cid].to_sym
92
89
  html = ""
93
90
 
94
- if type=="radio" || type=="checkbox"
91
+ if type == "radio" || type == "checkbox"
95
92
 
96
93
  other_input = (include_other_option)? "<div class=\"#{type} #{ob[:custom_class]}\"> <label for=\"#{ob[:cid]}\"><input id=\"#{ob[:cid]}-other\" type=\"#{type}\" name=\"#{title.downcase}[]\" class=\"\">Other <input type=\"text\" /></label></div>" : " "
97
94
 
@@ -101,62 +98,43 @@ module Plugins::ContactForm::ContactFormHtmlHelper
101
98
 
102
99
  options.each do |op|
103
100
  if type == "radio" || type == "checkbox"
104
- html += "<div class=\"#{type} #{ob[:custom_class]}\">
101
+ html += "<div class=\"#{type} #{ob[:custom_class]}\">
105
102
  <label for=\"#{ob[:cid]}\">
106
103
  <input #{ob[:custom_attrs].to_attr_format} type=\"#{type}\" name=\"#{f_name}[]\" class=\"\" value=\"#{op[:label].downcase}\">
107
104
  #{op[:label]}
108
105
  </label>
109
106
  </div>"
110
107
  else
111
- html += "<option value=\"#{op[:label].downcase.gsub(" ", "_")}\" #{"selected" if "#{op[:label].downcase.gsub(" ", "_")}" == values[cid]} >#{op[:label]}</option>"
108
+ html += "<option value=\"#{op[:label].downcase.gsub(" ", "_")}\" #{"selected" if "#{op[:label].downcase.gsub(" ", "_")}" == values[cid]} >#{op[:label]}</option>"
112
109
  end
113
110
  end
114
111
 
115
- if type=="radio" || type=="checkbox"
112
+ if type == "radio" || type == "checkbox"
116
113
  html += other_input
117
114
  else
118
115
  html += " </select>"
119
116
  end
120
-
121
117
  end
122
118
 
123
- def form_post_email_content(op_body, op_fields, fields, file_attachments)
124
- @values = {}
119
+ def convert_form_values(op_fields, fields)
120
+ values = {}
125
121
 
126
122
  op_fields.each do |field|
127
123
  cid = field[:cid].to_sym
128
124
  label = field[:label]
129
125
 
130
- @values[label] = []
126
+ values[label] = []
131
127
 
132
- if field[:field_type] == "file"
133
- @values[label] << fields[cid].original_filename if fields[cid].present?
134
- elsif field[:field_type] == "captcha"
135
- @values[label] << session[:captcha]
136
- elsif field[:field_type] == "radio" || field[:field_type] == "checkboxes"
137
- @values[label] << fields[cid].join(",") if fields[cid].present?
128
+ if field[:field_type] == 'file'
129
+ values[label] << fields[cid].original_filename if fields[cid].present?
130
+ elsif field[:field_type] == 'captcha'
131
+ values[label] << session[:captcha]
132
+ elsif field[:field_type] == 'radio' || field[:field_type] == 'checkboxes'
133
+ values[label] << fields[cid].join(',') if fields[cid].present?
138
134
  else
139
- @values[label] << fields[cid] if fields[cid].present?
140
- end
141
-
142
- end
143
-
144
- html = "<div class=\"data_body\"></div>"
145
- html += "<table style=\"width:100%; float:left\"><tbody><tr><td style=\"width:50%; float:left\">"
146
-
147
- @values.each do |ind, val|
148
- if val.to_s != "[]"
149
- html += "<div class=\"data_field\"><strong>"+ind + ":</strong>" + "#{val[0].to_s}" +"</div>"
135
+ values[label] << fields[cid] if fields[cid].present?
150
136
  end
151
137
  end
152
-
153
- html += "</td><td style=\"width:48%; float:left; vertical-align: top;\">"
154
-
155
- file_attachments.each do |attachment|
156
- html += "<div class=\"data_link\"> <strong>Attachment:</strong> <a href=\"'#{attachment}'\">'#{File.basename(attachment)}'</a></div>"
157
- end
158
-
159
- html += "</td></tr></tbody></table>"
138
+ return values
160
139
  end
161
-
162
140
  end
@@ -7,6 +7,7 @@
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
9
  class Plugins::ContactForm::FrontController < Apps::PluginsFrontController
10
+ before_filter :append_view_paths
10
11
 
11
12
  def index
12
13
  # here your actions for frontend module
@@ -19,10 +20,9 @@ class Plugins::ContactForm::FrontController < Apps::PluginsFrontController
19
20
  settings = JSON.parse(@form.settings).to_sym
20
21
  fields = params[:fields]
21
22
  attachments = []
22
- file_attachments = []
23
23
 
24
24
  errors = []
25
- succes = []
25
+ success = []
26
26
 
27
27
  validate = true
28
28
 
@@ -31,75 +31,86 @@ class Plugins::ContactForm::FrontController < Apps::PluginsFrontController
31
31
  label = f[:label].to_sym
32
32
 
33
33
  case f[:field_type].to_s
34
- when 'text', 'website', 'paragraph', 'textarea', 'email', 'radio', 'checkboxes', 'dropdown', 'file'
35
- if f[:required] && !fields[cid].present?
36
- errors << "#{label}: #{settings[:railscf_message][:invalid_required]}"
37
- validate = false
38
- end
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/)
41
- errors << "#{label}: #{settings[:railscf_message][:invalid_email]}"
42
- validate = false
43
- end
44
- end
45
- when 'radio'
46
-
47
- when 'checkboxes'
48
-
49
- when 'dropdown'
50
-
51
- when 'captcha'
52
- if !captcha_verified?
53
- errors << "#{label}: #{settings[:railscf_message][:captcha_not_match]}"
34
+ when 'text', 'website', 'paragraph', 'textarea', 'email', 'radio', 'checkboxes', 'dropdown', 'file'
35
+ if f[:required] && !fields[cid].present?
36
+ errors << "#{label}: #{settings[:railscf_message][:invalid_required]}"
37
+ validate = false
38
+ end
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/)
41
+ errors << "#{label}: #{settings[:railscf_message][:invalid_email]}"
54
42
  validate = false
55
43
  end
44
+ end
45
+ when 'captcha'
46
+ unless captcha_verified?
47
+ errors << "#{label}: #{settings[:railscf_message][:captcha_not_match]}"
48
+ validate = false
49
+ end
56
50
  end
57
51
  end
58
52
 
59
53
  if validate
60
54
  values[:fields].each do |f|
61
55
  cid = f[:cid].to_sym
62
- if f[:field_type] == "file"
56
+ if f[:field_type] == 'file'
63
57
  res = upload_file(fields[cid], {maximum: 5.megabytes, folder: current_site.upload_directory("uploads")})
64
58
  if res[:error].present?
65
59
  errors << res[:error]
66
60
  else
67
- attachments << res["file"]
61
+ attachments << res['file']
68
62
  end
69
63
  end
70
64
  end
71
65
 
72
66
  new_settings = {"fields" => fields, "created_at" => Time.now.strftime("%Y-%m-%d %H:%M:%S").to_s}.to_json
73
- @form_new = current_site.contact_forms.new(name: "response-#{Time.now}", description: @form.description, settings:fix_meta_value(new_settings), site_id: @form.site_id, parent_id: @form.id)
67
+ @form_new = current_site.contact_forms.new(name: "response-#{Time.now}", description: @form.description, settings:fix_meta_value(new_settings), site_id: @form.site_id, parent_id: @form.id)
74
68
 
75
69
  if @form_new.save
76
- template_path = "html_mailer"
77
-
78
- dir = Dir.glob("app/apps/themes/#{current_theme.the_slug.to_s}/views/html_mailer/*")
79
- content = form_post_email_content(settings[:railscf_mail][:body], values[:fields], fields, attachments)
80
- sendmail(settings[:railscf_mail][:to], settings[:railscf_mail][:subject], content, settings[:railscf_mail][:to], attachments) # send mail
81
- succes << settings[:railscf_message][:mail_sent_ok]
70
+ content = render_to_string partial: 'contact_form/submission',
71
+ layout: false,
72
+ locals: {
73
+ file_attachments: attachments,
74
+ fields: convert_form_values(
75
+ values[:fields],
76
+ fields
77
+ )
78
+ }
79
+ # send mail
80
+ sendmail(
81
+ settings[:railscf_mail][:to], settings[:railscf_mail][:subject],
82
+ content,
83
+ settings[:railscf_mail][:to],
84
+ attachments
85
+ )
86
+ success << settings[:railscf_message][:mail_sent_ok]
82
87
  else
83
88
  errors << settings[:railscf_message][:mail_sent_ng]
84
89
  end
85
90
  end
86
91
 
87
- if succes.present?
88
- flash[:notice] = succes.join("<br>")
92
+ if success.present?
93
+ flash[:notice] = success.join('<br>')
89
94
  else
90
- flash[:error] = errors.join("<br>")
95
+ flash[:error] = errors.join('<br>')
91
96
  flash[:values] = fields
92
97
  end
93
98
 
94
99
  redirect_to :back
95
100
  end
96
101
 
102
+ private
103
+
104
+ def append_view_paths
105
+ append_view_path File.join($camaleon_engine_dir, 'app', 'apps', 'plugins', self_plugin_key, 'views')
106
+ end
107
+
97
108
  def fix_meta_value(value)
98
- if (value.is_a?(Array) || value.is_a?(Hash))
109
+ if value.is_a?(Array) || value.is_a?(Hash)
99
110
  value = value.to_json
100
111
  elsif value.is_a?(String)
101
112
  value = value.to_var
102
113
  end
103
114
  value
104
115
  end
105
- end
116
+ end
@@ -97,26 +97,6 @@
97
97
  <label for="railscf_mail_body"><%= t('plugin.contact_form.body') %>:</label><br>
98
98
  <textarea rows="4" cols="5" id="railscf_mail_body" class="form-control" name="railscf_mail[body]"><%= t('plugin.contact_form.body_value') %></textarea>
99
99
  </div>
100
-
101
- <div class="form-group">
102
- <label for="railscf_mail_body"><%= t('admin.sidebar.themes') %>:</label><br>
103
- <% dir = Dir.glob("app/apps/themes/#{current_theme.the_slug.to_s}/views/html_mailer/*") %>
104
- <select id="railscf_mail_theme" name="railscf_mail[theme]">
105
- <% if dir.size > 0 %>
106
- <% dir.each do |archivo| file=File.basename(archivo) %>
107
- <% f=file.split('.') %>
108
- <option value="<%= f[0].to_s %>"><%= f[0].to_s.titleize %></option>
109
- <% end %>
110
- <% else %>
111
- <% dir = Dir.glob("app/views/html_mailer/*") %>
112
- <% dir.each do |archivo| file=File.basename(archivo) %>
113
- <% f=file.split('.') %>
114
- <option value="<%= f[0].to_s %>"><%= f[0].to_s.titleize %></option>
115
- <% end %>
116
-
117
- <% end %>
118
- </select>
119
- </div>
120
100
  </div>
121
101
  </div>
122
102
  </div>
@@ -0,0 +1,26 @@
1
+ <div class="data_body">
2
+ <table style="width: 100%; float: left;">
3
+ <tbody>
4
+ <tr>
5
+ <td style="width: 50%; float: left">
6
+ <% fields.each do |key, value| %>
7
+ <div class="data_field">
8
+ <strong><%= key %>:</strong>
9
+ <%= value[0] %>
10
+ </div>
11
+ <% end %>
12
+ </td>
13
+ <td style="width: 48%; float: left; vertical-align: top">
14
+ <% file_attachments.each do |attachment| %>
15
+ <div class="data_link">
16
+ <strong>Attachment: </strong>
17
+ <a href="<%= attachment %>">
18
+ <%= File.basename(attachment) %>
19
+ </a>
20
+ </div>
21
+ <% end %>
22
+ </td>
23
+ </tr>
24
+ </tbody>
25
+ </table>
26
+ </div>
@@ -9,59 +9,6 @@
9
9
  module FrontendConcern extend ActiveSupport::Concern
10
10
  # visiting sitemap.xml
11
11
  def sitemap
12
- # create sitemap directory
13
- sitemaps_dir = Rails.root.join("public", "sitemaps").to_s
14
- FileUtils.mkdir(sitemaps_dir) unless Dir.exist?(sitemaps_dir)
15
-
16
- site = current_site
17
- folder "sitemaps/#{site.slug}"
18
- host site.the_url.to_s.parse_domain
19
- langs = site.get_languages
20
-
21
- sitemap :site do
22
- url root_url, priority: 1.0, change_freq: "daily"
23
-
24
- langs.each_with_index{|l, index| url site.the_url(locale: index==0?nil:l), last_mod: site.updated_at, priority: 0.9 }
25
- url sitemap_url
26
- end
27
-
28
-
29
- sitemap_for site.posts.public_posts, name: :published_posts do |post|
30
- post = post.decorate
31
- langs.each_with_index{|l, index| url post.the_url(locale: index==0?nil:l), last_mod: post.updated_at, priority: 0.7 }
32
- end
33
-
34
- sitemap_for site.full_categories.no_empty, name: :categories do |cat|
35
- cat = cat.decorate
36
- langs.each_with_index{|l, index| url cat.the_url(locale: index==0?nil:l), last_mod: cat.updated_at, priority: 0.5 }
37
- end
38
-
39
- sitemap_for site.post_types, name: :groups do |ptype|
40
- ptype = ptype.decorate
41
- langs.each_with_index{|l, index| url ptype.the_url(locale: index==0?nil:l), last_mod: ptype.updated_at, priority: 0.3 }
42
- end
43
-
44
- sitemap_for site.post_tags, name: :tags do |ptag|
45
- ptag = ptag.decorate
46
- langs.each_with_index{|l, index| url ptag.the_url(locale: index==0?nil:l), last_mod: ptag.updated_at, priority: 0.2 }
47
- end
48
-
49
- # hooks
50
- c = CamaleonController.new
51
- c.instance_eval do
52
- @current_site = site
53
- @_hooks_skip = []
54
- end
55
-
56
- # sample: sitemap :site2 do \n url root_url \n end
57
- r = {site: site, eval: ""}; c.hooks_run("sitemap", r)
58
- instance_eval(r[:eval]) if r[:eval].present?
59
-
60
- ping_with "http://#{host}/sitemap.xml"
61
- end
62
-
63
-
64
- def sitemap2
65
12
  path = Rails.root.join("public", "sitemaps", current_site.slug, "sitemap.xml")
66
13
  if File.exists?(path)
67
14
  respond_to do |format|
@@ -16,7 +16,7 @@ module Admin::ApplicationHelper
16
16
  def admin_system_notifications(args)
17
17
  if Date.parse(current_site.get_option("date_notified", 2.days.ago).to_s) < Date.today
18
18
  current_site.set_option("date_notified", Date.today)
19
- url = "http://camaleon.tuzitio.com/plugins/camaleon_notification/?version=#{"CamaleonCms::VERSION"}&admin_locale=#{current_site.get_admin_language}&site=#{current_site.the_url}"
19
+ url = "http://camaleon.tuzitio.com/plugins/camaleon_notification/?version=#{CamaleonCms::VERSION}&admin_locale=#{current_site.get_admin_language}&site=#{current_site.the_url}"
20
20
  Thread.new do
21
21
  current_site.set_meta("date_notified_message", open(url).read)
22
22
  ActiveRecord::Base.connection.close #closing connection
@@ -54,7 +54,7 @@ module SiteHelper
54
54
  # get list templates files of current theme
55
55
  def get_list_template_files
56
56
  contained_files = []
57
- Dir[File.join(current_theme.settings["path"], "views", '*.html.erb')].each do |path|
57
+ Dir[File.join(current_theme.settings["path"], "views", '*')].each do |path|
58
58
  f_name = File.basename(path)
59
59
  contained_files << f_name.split(".").first if f_name.include?('template_')
60
60
  end
@@ -1,6 +1,6 @@
1
1
  <footer class="main-footer">
2
2
  <div class="pull-right hidden-xs">
3
- <b>Version</b> 1.x <%#= CamaleonCms::VERSION %>
3
+ <b>Version</b><%= CamaleonCms::VERSION %>
4
4
  </div>
5
5
  <strong>Copyright &copy; 2015-2016 <a href="http://camaleon.tuzitio.com">Camaleon CMS.</a> </strong> All rights reserved.
6
- </footer>
6
+ </footer>
@@ -1,42 +1,89 @@
1
- module Sass::Script::Functions
2
- # similar to asset_path with prefix for current theme asset
3
- # def theme_path(path, options = {})
4
- # asset_path("#{get_theme_prefix}#{path}", options)
5
- # end
1
+ # module Sass::Script::Functions
2
+ # # similar to asset_path with prefix for current theme asset
3
+ # # def theme_path(path, options = {})
4
+ # # asset_path("#{get_theme_prefix}#{path}", options)
5
+ # # end
6
+ #
7
+ # # similar to asset_url with prefix for current theme asset
8
+ # def theme_asset(path, options = {})
9
+ # asset_url("#{get_theme_prefix}#{path}", options)
10
+ # end
11
+ #
12
+ # # similar to asset_url with prefix for current theme asset
13
+ # def asset_owencio(path, options = {})
14
+ # puts "*****************************"
15
+ # puts "*****************************"
16
+ # puts "*****************************"
17
+ # puts "*****************************"
18
+ # puts "*****************************"
19
+ # puts "*****************************"
20
+ # puts "*****************************"
21
+ # puts "*****************************"
22
+ # puts "*****************************"
23
+ # puts "*****************************"
24
+ # puts "*****************************"
25
+ # puts "*****************************"
26
+ # asset_url("#{get_theme_prefix}#{path}", options)
27
+ # Autoload::Sass::Script::String.new("url(#{asset_path("#{get_theme_prefix}#{path}", options)})")
28
+ # end
29
+ #
30
+ # # # similar to asset_path with prefix for current plugin asset
31
+ # # def plugin_path(path, options = {})
32
+ # # asset_path("#{get_plugin_prefix}#{path}", options)
33
+ # # end
34
+ #
35
+ # # similar to asset_url with prefix for current plugin asset
36
+ # def plugin_asset(path, options = {})
37
+ # asset_url("#{get_plugin_prefix}#{path}", options)
38
+ # end
39
+ #
40
+ # private
41
+ # # get plugin asset prefix
42
+ # def get_plugin_prefix
43
+ # file = sprockets_context.filename
44
+ # res = ""
45
+ # if file.include?("/app/apps/plugins/")
46
+ # res = "themes/#{file.split("/app/apps/plugins/").last.split("/").first}/assets/"
47
+ # end
48
+ # res
49
+ # end
50
+ #
51
+ # # get theme asset prefix
52
+ # def get_theme_prefix
53
+ # file = sprockets_context.filename
54
+ # res = ""
55
+ # if file.include?("/app/apps/themes/")
56
+ # res = "themes/#{file.split("/app/apps/themes/").last.split("/").first}/assets/"
57
+ # end
58
+ # res
59
+ # end
60
+ # end
6
61
 
7
- # similar to asset_url with prefix for current theme asset
8
- def theme_asset(path, options = {})
9
- asset_url("#{get_theme_prefix}#{path}", options)
10
- end
11
-
12
- # # similar to asset_path with prefix for current plugin asset
13
- # def plugin_path(path, options = {})
14
- # asset_path("#{get_plugin_prefix}#{path}", options)
15
- # end
16
-
17
- # similar to asset_url with prefix for current plugin asset
18
- def plugin_asset(path, options = {})
19
- asset_url("#{get_plugin_prefix}#{path}", options)
20
- end
21
62
 
22
- private
23
- # get plugin asset prefix
24
- def get_plugin_prefix
25
- file = sprockets_context.filename
26
- res = ""
27
- if file.include?("/app/apps/plugins/")
28
- res = "themes/#{file.split("/app/apps/plugins/").last.split("/").first}/assets/"
29
- end
30
- res
31
- end
63
+ module Sprockets
64
+ # Processor engine class for the SASS/SCSS compiler. Depends on the `sass` gem.
65
+ #
66
+ # For more infomation see:
67
+ #
68
+ # https://github.com/sass/sass
69
+ # https://github.com/rails/sass-rails
70
+ #
71
+ class SassProcessor
72
+ module Functions
32
73
 
33
- # get theme asset prefix
34
- def get_theme_prefix
35
- file = sprockets_context.filename
36
- res = ""
37
- if file.include?("/app/apps/themes/")
38
- res = "themes/#{file.split("/app/apps/themes/").last.split("/").first}/assets/"
74
+ def asset_owencio(path, options = {})
75
+ puts "%%%%%%%%%%%%%%%"
76
+ puts "%%%%%%%%%%%%%%%"
77
+ puts "%%%%%%%%%%%%%%%"
78
+ puts "%%%%%%%%%%%%%%%"
79
+ puts "%%%%%%%%%%%%%%%"
80
+ puts "%%%%%%%%%%%%%%%"
81
+ puts "%%%%%%%%%%%%%%%"
82
+ puts "%%%%%%%%%%%%%%%"
83
+ puts "***************** #{path.inspect}---#{options.inspect}"
84
+ ass
85
+ Autoload::Sass::Script::String.new("url(#{asset_path(path, options).value})")
86
+ end
39
87
  end
40
- res
41
88
  end
42
89
  end
data/config/sitemap.rb CHANGED
@@ -15,6 +15,7 @@ Site.all.each do |site|
15
15
 
16
16
  sitemap :site do
17
17
  url root_url, priority: 1.0, change_freq: "daily"
18
+
18
19
  langs.each_with_index{|l, index| url site.the_url(locale: index==0?nil:l), last_mod: site.updated_at, priority: 0.9 }
19
20
  url sitemap_url
20
21
  end
data/lib/camaleon_cms.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'camaleon_cms/engine'
2
+ require 'camaleon_cms/version'
2
3
 
3
4
  module CamaleonCms
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module CamaleonCms
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -0,0 +1,122 @@
1
+ require 'rails/generators/base'
2
+ require 'securerandom'
3
+ module CamaleonCms
4
+ module Generators
5
+ class GemPluginGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../gem_plugin_template", __FILE__)
7
+ argument :plugin_name, :type => :string, :default => "my_plugin"
8
+ desc "This generator create all basic gem plugin structure."
9
+
10
+ def create_initializer_file
11
+
12
+ plugin_dir = Rails.root.join("plugins", get_plugin_name).to_s
13
+ plugin_app = File.join($camaleon_engine_dir, "lib", "generators", "camaleon_cms", "gem_plugin_#{get_plugin_name}")
14
+ FileUtils.rm_r(plugin_app) if Dir.exist?(plugin_app)
15
+
16
+ FileUtils.mkdir_p(plugin_dir)
17
+ system("cd #{Rails.root}; rails plugin new plugins/#{get_plugin_name} --full")
18
+
19
+ FileUtils.cp_r(File.join($camaleon_engine_dir, "lib", "generators", "camaleon_cms", "gem_theme_template"), plugin_app)
20
+
21
+ # tmp copy
22
+ helper_path = File.join(plugin_app, "app", "helpers", "plugins", get_plugin_name)
23
+ model_path = File.join(plugin_app, "app", "models", "plugins", get_plugin_name)
24
+ views_path = File.join(plugin_app, "app", "views", "plugins", get_plugin_name)
25
+ controller_path = File.join(plugin_app, "app", "controllers", "plugins", get_plugin_name)
26
+ FileUtils.mv(File.join(plugin_app, "app", "controllers", "plugins", "my_plugin"), controller_path) rescue nil
27
+ FileUtils.mv(File.join(plugin_app, "app", "helpers", "plugins", "my_plugin"), helper_path) rescue nil
28
+ FileUtils.mv(File.join(plugin_app, "app", "models", "plugins", "my_plugin"), model_path) rescue nil
29
+ FileUtils.mv(File.join(plugin_app, "app", "views", "plugins", "my_plugin"), views_path) rescue nil
30
+ FileUtils.mv(File.join(plugin_app, "app", "assets", "images", "plugins", "my_plugin"), File.join(plugin_app, "app", "assets", "images", "plugins", get_plugin_name)) rescue nil
31
+ FileUtils.mv(File.join(plugin_app, "app", "assets", "javascripts", "plugins", "my_plugin"), File.join(plugin_app, "app", "assets", "javascripts", "plugins", get_plugin_name)) rescue nil
32
+ FileUtils.mv(File.join(plugin_app, "app", "assets", "stylesheets", "plugins", "my_plugin"), File.join(plugin_app, "app", "assets", "stylesheets", "plugins", get_plugin_name)) rescue nil
33
+
34
+ # configuration
35
+ t = fix_text(File.read(File.join(plugin_app, "config", "camaleon_plugin.json")))
36
+ File.open(File.join(plugin_app, "config", "camaleon_plugin.json"), "w"){|f| f << t }
37
+
38
+ # helper
39
+ t = fix_text(File.read(File.join(helper_path, "main_helper.rb")))
40
+ File.open(File.join(helper_path, "main_helper.rb"), "w"){|f| f << t }
41
+
42
+ # controllers
43
+ t = fix_text(File.read(File.join(controller_path, "admin_controller.rb")))
44
+ File.open(File.join(controller_path, "admin_controller.rb"), "w"){|f| f << t }
45
+ t = fix_text(File.read(File.join(controller_path, "front_controller.rb")))
46
+ File.open(File.join(controller_path, "front_controller.rb"), "w"){|f| f << t }
47
+
48
+ # models
49
+ model_file = File.join(model_path, "my_plugin.rb")
50
+ t = fix_text(File.read(model_file))
51
+ File.open(model_file, "w"){|f| f << t }
52
+ FileUtils.mv(model_file, File.join(File.dirname(model_file), "#{get_plugin_name}.rb")) rescue nil
53
+
54
+
55
+ directory(plugin_app, plugin_dir)
56
+ gsub_file File.join(plugin_dir, "config", "routes.rb"), "end" do
57
+ "
58
+ scope '(:locale)', locale: /\#{PluginRoutes.all_locales}/, :defaults => { } do
59
+ # frontend
60
+ namespace :plugins do
61
+ namespace '#{get_plugin_name}' do
62
+ get 'index' => 'front#index'
63
+ end
64
+ end
65
+ end
66
+
67
+ #Admin Panel
68
+ scope 'admin', as: 'admin' do
69
+ namespace 'plugins' do
70
+ namespace '#{get_plugin_name}' do
71
+ get 'index' => 'admin#index'
72
+ end
73
+ end
74
+ end
75
+
76
+ # main routes
77
+ #scope '#{get_plugin_name}', module: 'plugins/#{get_plugin_name}/', as: '#{get_plugin_name}' do
78
+ # Here my routes for main routes
79
+ #end
80
+ end"
81
+ end
82
+
83
+ append_to_file Rails.root.join("Gemfile") do
84
+ "\n\ngem '#{get_plugin_name}', path: '#{plugin_dir}/'"
85
+ end
86
+
87
+ # destroy non used files
88
+ FileUtils.rm_r(plugin_app)
89
+ FileUtils.rm_r(File.join(plugin_dir, "app", "assets", "images", get_plugin_name))
90
+ FileUtils.rm_r(File.join(plugin_dir, "app", "assets", "javascripts", get_plugin_name))
91
+ FileUtils.rm_r(File.join(plugin_dir, "app", "assets", "stylesheets", get_plugin_name))
92
+
93
+ # remove TODO text from gem
94
+ gemspec_file = File.join(plugin_dir, "#{get_plugin_name}.gemspec")
95
+ t = File.read(gemspec_file).gsub("TODO", "")
96
+ File.open(gemspec_file, "w"){|f| f << t }
97
+
98
+ end
99
+
100
+ def fix_text(text = "")
101
+ text.gsub("pluginTitle", get_plugin_title).gsub("PluginClass", get_plugin_class).gsub("pluginKey", get_plugin_name)
102
+ end
103
+
104
+ def self.next_migration_number(dir)
105
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
106
+ end
107
+
108
+ private
109
+ def get_plugin_name
110
+ plugin_name.underscore.singularize
111
+ end
112
+
113
+ def get_plugin_title
114
+ plugin_name.titleize
115
+ end
116
+ def get_plugin_class
117
+ get_plugin_name.classify
118
+ end
119
+
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,8 @@
1
+ class Plugins::PluginClass::AdminController < Apps::PluginsAdminController
2
+ include Plugins::PluginClass::MainHelper
3
+ def index
4
+ # actions for admin panel
5
+ end
6
+
7
+ # add custom methods below
8
+ end
@@ -0,0 +1,8 @@
1
+ class Plugins::PluginClass::FrontController < Apps::PluginsFrontController
2
+ include Plugins::PluginClass::MainHelper
3
+ def index
4
+ # actions for frontend module
5
+ end
6
+
7
+ # add custom methods below
8
+ end
@@ -0,0 +1,22 @@
1
+ module Plugins::PluginClass::MainHelper
2
+ def self.included(klass)
3
+ # klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
4
+ end
5
+
6
+ # here all actions on going to active
7
+ # you can run sql commands like this:
8
+ # results = ActiveRecord::Base.connection.execute(query);
9
+ # plugin: plugin model
10
+ def pluginKey_on_active(plugin)
11
+ end
12
+
13
+ # here all actions on going to inactive
14
+ # plugin: plugin model
15
+ def pluginKey_on_inactive(plugin)
16
+ end
17
+
18
+ # here all actions to upgrade for a new version
19
+ # plugin: plugin model
20
+ def pluginKey_on_upgrade(plugin)
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ # class Plugins::PluginClass::Models::PluginClass < ActiveRecord::Base
2
+ # attr_accessible :path, :browser_key
3
+ # belongs_to :site
4
+
5
+ # here create your models normally
6
+ # notice: your tables in database will be plugins_pluginKey in plural (check rails documentation)
7
+ # end
8
+
9
+ # here your default models customization
10
+ # Site.class_eval do
11
+ # has_many :pluginKey, class_name: "Plugins::PluginClass::Models::PluginClass"
12
+ # end
@@ -0,0 +1,2 @@
1
+ <%#= javascript_include_tag plugin_gem_asset("js/my_file.js") %>
2
+ Plugin ready to use in admin panel!.
@@ -0,0 +1,2 @@
1
+ <%#= javascript_include_tag plugin_gem_asset("js/my_file.js") %>
2
+ Plugin ready to use! in frontend.
@@ -0,0 +1,2 @@
1
+ You can create your layouts here.
2
+ To load your custom layout you can use: layout: plugin_layout(<layout_name>) in your controller
@@ -0,0 +1,21 @@
1
+ {
2
+ "title": "pluginTitle",
3
+ "descr": "",
4
+ "version": "0.1",
5
+ "key": "pluginKey",
6
+ "helpers": [
7
+ "Plugins::PluginClass::MainHelper"
8
+ ],
9
+ "hooks": {
10
+ "on_active": [
11
+ "pluginKey_on_active"
12
+ ],
13
+ "on_inactive": [
14
+ "pluginKey_on_inactive"
15
+ ],
16
+ "on_upgrade": [
17
+ "pluginKey_on_upgrade"
18
+ ]
19
+ //here you can add all your hooks (read documentation)
20
+ }
21
+ }
data/lib/plugin_routes.rb CHANGED
@@ -233,6 +233,7 @@ class PluginRoutes
233
233
  r = cache_variable("all_plugins"); return r unless (r.nil? || r == [])
234
234
  res = get_gem_plugins
235
235
  entries = [".", ".."]
236
+ res.each{|plugin| entries << plugin["key"] }
236
237
  (Dir["#{apps_dir}/plugins/*"] + Dir["#{camaleon_gem.gem_dir}/app/apps/plugins/*"]).each do |path|
237
238
  entry = path.split("/").last
238
239
  config = File.join(path, "config", "config.json")
@@ -255,6 +256,7 @@ class PluginRoutes
255
256
  r = cache_variable("all_themes"); return r unless (r.nil? || r == [])
256
257
  res = get_gem_themes
257
258
  entries = [".", ".."]
259
+ res.each{|theme| entries << theme["key"] }
258
260
  (Dir["#{apps_dir}/themes/*"] + Dir["#{camaleon_gem.gem_dir}/app/apps/themes/*"]).each do |path|
259
261
  entry = path.split("/").last
260
262
  config = File.join(path, "config", "config.json")
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.2
4
+ version: 1.0.3
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-09-28 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack-page_caching
@@ -235,6 +235,7 @@ files:
235
235
  - app/apps/plugins/contact_form/views/admin_forms/index.html.erb
236
236
  - app/apps/plugins/contact_form/views/admin_forms/manual.html.erb
237
237
  - app/apps/plugins/contact_form/views/admin_forms/responses.html.erb
238
+ - app/apps/plugins/contact_form/views/contact_form/_submission.html.erb
238
239
  - app/apps/plugins/contact_form/views/forms_shorcode.html.erb
239
240
  - app/apps/plugins/contact_form/views/front/index.html.erb
240
241
  - app/apps/plugins/front_cache/admin_controller.rb
@@ -860,6 +861,15 @@ files:
860
861
  - lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/front/index.html.erb
861
862
  - lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/layouts/readme.txt
862
863
  - lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json
864
+ - lib/generators/camaleon_cms/gem_theme_generator.rb
865
+ - lib/generators/camaleon_cms/gem_theme_template/app/controllers/plugins/my_plugin/admin_controller.rb
866
+ - lib/generators/camaleon_cms/gem_theme_template/app/controllers/plugins/my_plugin/front_controller.rb
867
+ - lib/generators/camaleon_cms/gem_theme_template/app/helpers/plugins/my_plugin/main_helper.rb
868
+ - lib/generators/camaleon_cms/gem_theme_template/app/models/plugins/my_plugin/my_plugin.rb
869
+ - lib/generators/camaleon_cms/gem_theme_template/app/views/plugins/my_plugin/admin/index.html.erb
870
+ - lib/generators/camaleon_cms/gem_theme_template/app/views/plugins/my_plugin/front/index.html.erb
871
+ - lib/generators/camaleon_cms/gem_theme_template/app/views/plugins/my_plugin/layouts/readme.txt
872
+ - lib/generators/camaleon_cms/gem_theme_template/config/camaleon_plugin.json
863
873
  - lib/generators/camaleon_cms/install_generator.rb
864
874
  - lib/generators/camaleon_cms/install_template/apps/plugins/readme.txt
865
875
  - lib/generators/camaleon_cms/install_template/apps/themes/readme.txt