caboose-cms 0.9.175 → 0.9.176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/caboose/block_types_controller.rb +97 -4
  3. data/app/controllers/caboose/sites_controller.rb +19 -0
  4. data/app/controllers/caboose/theme_files_controller.rb +110 -0
  5. data/app/controllers/caboose/themes_controller.rb +27 -1
  6. data/app/models/caboose/block.rb +6 -2
  7. data/app/models/caboose/block_type.rb +9 -3
  8. data/app/models/caboose/block_type_site_membership.rb +1 -1
  9. data/app/models/caboose/core_plugin.rb +2 -1
  10. data/app/models/caboose/schema.rb +18 -3
  11. data/app/models/caboose/site.rb +10 -1
  12. data/app/models/caboose/theme.rb +2 -1
  13. data/app/models/caboose/theme_file.rb +1 -1
  14. data/app/models/caboose/user.rb +2 -1
  15. data/app/views/caboose/block_types/admin_edit.html.erb +11 -4
  16. data/app/views/caboose/block_types/admin_edit_btsm_css.html.erb +147 -0
  17. data/app/views/caboose/block_types/admin_edit_btsm_html.html.erb +119 -0
  18. data/app/views/caboose/block_types/admin_edit_render_function.html.erb +119 -0
  19. data/app/views/caboose/block_types/admin_edit_sass.html.erb +118 -0
  20. data/app/views/caboose/block_types/admin_error_log.html.erb +9 -0
  21. data/app/views/caboose/block_types/admin_index.html.erb +3 -1
  22. data/app/views/caboose/blocks/_render_function.html.erb +5 -1
  23. data/app/views/caboose/events/admin_edit.html.erb +1 -1
  24. data/app/views/caboose/pages/admin_edit_css.html.erb +117 -13
  25. data/app/views/caboose/pages/admin_edit_js.html.erb +114 -14
  26. data/app/views/caboose/sites/_admin_header.html.erb +6 -1
  27. data/app/views/caboose/sites/admin_edit_block_types.html.erb +35 -8
  28. data/app/views/caboose/sites/admin_edit_contact.html.erb +41 -0
  29. data/app/views/caboose/sites/admin_edit_css.html.erb +106 -20
  30. data/app/views/caboose/sites/admin_edit_js.html.erb +107 -20
  31. data/app/views/caboose/theme_files/admin_edit.html.erb +118 -0
  32. data/app/views/caboose/theme_files/admin_index.html.erb +44 -0
  33. data/app/views/caboose/themes/admin_edit.html.erb +6 -2
  34. data/app/views/caboose/themes/admin_sass.html.erb +240 -0
  35. data/lib/caboose/version.rb +1 -1
  36. metadata +12 -2
@@ -52,7 +52,16 @@ class Caboose::Site < ActiveRecord::Base
52
52
  :assets_url ,
53
53
  :theme_id ,
54
54
  :cl_logo_version ,
55
- :cl_favicon_version
55
+ :cl_favicon_version ,
56
+ :main_phone,
57
+ :alt_phone,
58
+ :address1,
59
+ :address2,
60
+ :city,
61
+ :state,
62
+ :zip,
63
+ :fax,
64
+ :contact_email
56
65
 
57
66
  before_save :validate_presence_of_store_config
58
67
 
@@ -79,7 +79,8 @@ class Caboose::Theme < ActiveRecord::Base
79
79
  :actual_banner_height,
80
80
  :dropdown_nav_padding,
81
81
 
82
- :digest
82
+ :digest,
83
+ :custom_sass
83
84
 
84
85
  def compile(for_site_id = 0)
85
86
  theme = self
@@ -1,6 +1,6 @@
1
1
  class Caboose::ThemeFile < ActiveRecord::Base
2
2
  self.table_name = "theme_files"
3
3
 
4
- attr_accessible :filename, :nice_name, :default_included
4
+ attr_accessible :filename, :nice_name, :default_included, :code
5
5
 
6
6
  end
@@ -50,7 +50,8 @@ class Caboose::User < ActiveRecord::Base
50
50
  self.email
51
51
  end
52
52
 
53
- def is_allowed(resource, action)
53
+ def is_allowed(resource, action)
54
+ return true if self.is_super_admin?
54
55
  elo = Caboose::Role.logged_out_role(self.site_id)
55
56
  elo_is_allowed = elo.is_allowed(resource, action)
56
57
  return true if elo_is_allowed
@@ -8,15 +8,19 @@ bt = @block_type
8
8
 
9
9
  <h1>Edit Block Type</h1>
10
10
 
11
+ <a href="/admin/block-types/<%= bt.id %>/render-function" class="caboose-btn">Edit Render Function</a>
12
+ <a href="/admin/block-types/<%= bt.id %>/sass" class="caboose-btn">Edit Custom SCSS</a>
13
+
14
+ <div id='message'></div>
11
15
  <p><div id='blocktype_<%= bt.id %>_name' ></div></p>
12
16
  <p><div id='blocktype_<%= bt.id %>_description' ></div></p>
13
17
 
14
18
  <h2>Children</h2>
15
19
  <div id='block_types'></div>
16
20
 
21
+
22
+
17
23
  <h2>Advanced</h2>
18
- <p><div id='blocktype_<%= bt.id %>_site_id' ></div></p>
19
- <!-- <p><div id='blocktype_<%= bt.id %>_parent_id' ></div></p> -->
20
24
  <p><div id='blocktype_<%= bt.id %>_block_type_category_id' ></div></p>
21
25
  <p><div id='blocktype_<%= bt.id %>_field_type' ></div></p>
22
26
  <p><div id='blocktype_<%= bt.id %>_default' ></div></p>
@@ -33,10 +37,13 @@ bt = @block_type
33
37
  <p><div id='blocktype_<%= bt.id %>_default_child_block_type_id' ></div></p>
34
38
  <p><div id='blocktype_<%= bt.id %>_default_constrain' ></div></p>
35
39
  <p><div id='blocktype_<%= bt.id %>_default_full_width' ></div></p>
36
- <p><div id='blocktype_<%= bt.id %>_render_function' ></div></p>
40
+ <p>
41
+
42
+ </p>
37
43
  <p><div id='blocktype_<%= bt.id %>_options_function' ></div></p>
38
44
 
39
- <div id='message'></div>
45
+
46
+
40
47
  <p>
41
48
  <input type='button' value='< Back' onclick="window.location='/admin/block-types<%= bt.parent_id && bt.parent_id > 0 ? "/#{bt.parent_id}" : '' %>';" />
42
49
  <input type='button' value='Edit Icon' onclick="caboose_modal_url('/admin/block-types/<%= @block_type.id %>/icon');" />
@@ -0,0 +1,147 @@
1
+ <h1>Override Block SCSS</h1>
2
+
3
+ <div class="editor-wrapper">
4
+
5
+ <div class="holder">
6
+ <div class="clearfix buttons">
7
+ <a href="/admin/sites/<%= @site.id %>/block-types" class="caboose-btn">Back</a>
8
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
9
+ <% if @site.theme %>
10
+ <a href="#" onclick="compile();return false;" class="caboose-btn blue">Compile Theme</a>
11
+ <% end %>
12
+ <span id="modified">Modified</span>
13
+ <div id="message"></div>
14
+ <p id="tips">
15
+ <span>Command+S = Save</span>
16
+ <span>Command+E = Compile</span>
17
+ </p>
18
+ </div>
19
+ <div id="editor"><%= @btsm.custom_css %></div>
20
+ </div>
21
+
22
+ </div>
23
+
24
+ <% content_for :caboose_css do %>
25
+ <style>
26
+ p#tips {
27
+ display: inline-block;
28
+ float: right;
29
+ font-size: 13px;
30
+ color: gray;
31
+ margin: 0;
32
+ padding-top: 15px;
33
+ padding-right: 2px;
34
+ }
35
+ p#tips span {
36
+ display: inline-block;
37
+ margin-left: 12px;
38
+ }
39
+ span#modified {
40
+ font-size: 13px;
41
+ color: gray;
42
+ margin: 0 10px;
43
+ opacity: 0;
44
+ transition: opacity 100ms ease;
45
+ }
46
+ .buttons {
47
+ margin-bottom: 10px;
48
+ }
49
+ .buttons .caboose-btn {
50
+ margin-right: 5px;
51
+ }
52
+ .editor-wrapper {
53
+
54
+ padding-right: 30px;
55
+ }
56
+
57
+ .holder {
58
+
59
+ }
60
+ #editor {
61
+ height: 800px;
62
+ width: 100%;
63
+ opacity: 0;
64
+ }
65
+ #editor.ace_editor {
66
+ opacity: 1;
67
+ }
68
+ #message {
69
+ display: inline-block;
70
+ }
71
+ #message p.note {
72
+ padding: 1px 15px 2px 15px;
73
+ font-size: 15px;
74
+ line-height: 30px;
75
+ border-radius: 5px;
76
+ }
77
+ #message p.note.loading {
78
+ padding-left: 40px;
79
+ }
80
+ </style>
81
+ <% end %>
82
+
83
+ <% content_for :caboose_js do %>
84
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
85
+ <script>
86
+ var editor = ace.edit("editor");
87
+ editor.setTheme("ace/theme/monokai");
88
+ editor.session.setMode("ace/mode/scss");
89
+ editor.session.setOptions({
90
+ tabSize: 2
91
+ });
92
+
93
+ editor.on("change", function() {
94
+ $("span#modified").css('opacity',1);
95
+ });
96
+
97
+ editor.commands.addCommand({
98
+ name: 'save',
99
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
100
+ exec: function(editor) { save(); }
101
+ });
102
+
103
+ editor.commands.addCommand({
104
+ name: 'compile',
105
+ bindKey: {win: "Ctrl-E", "mac": "Cmd-E"},
106
+ exec: function(editor) { compile(); }
107
+ });
108
+
109
+ function compile() {
110
+ $('#message').html("<p class='note loading'>Compiling theme...</p>").fadeIn();
111
+ $.ajax({
112
+ url: '/admin/themes/<%= @site.theme_id %>/compile',
113
+ type: 'put',
114
+ data: {
115
+ btsm_id: <%= @btsm.id %>,
116
+ custom_css: editor.getValue()
117
+ },
118
+ success: function(resp) {
119
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
120
+ if (resp.success && resp.message) {
121
+ $("span#modified").css('opacity',0);
122
+ $('#message').html("<p class='note success'>" + resp.message + "</p>").fadeIn().delay(2000).fadeOut();
123
+ }
124
+ }
125
+ });
126
+ }
127
+
128
+ function save() {
129
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
130
+ $.ajax({
131
+ url: '/admin/block-type-site-memberships/<%= @btsm.id %>/css',
132
+ type: 'put',
133
+ data: {
134
+ code: editor.getValue()
135
+ },
136
+ success: function(resp) {
137
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
138
+ if (resp.success && resp.message) {
139
+ $("span#modified").css('opacity',0);
140
+ $('#message').html("<p class='note success'>" + resp.message + "</p>").fadeIn().delay(2000).fadeOut();
141
+ }
142
+ }
143
+ });
144
+ }
145
+
146
+ </script>
147
+ <% end %>
@@ -0,0 +1,119 @@
1
+ <h1>Override Block Render Function</h1>
2
+
3
+ <div class="editor-wrapper">
4
+
5
+ <div class="holder">
6
+ <div class="clearfix buttons">
7
+ <a href="/admin/sites/<%= @site.id %>/block-types" class="caboose-btn">Back</a>
8
+ <a href="/admin/block-types/<%= @btsm.block_type_id %>/errors" class="caboose-btn">Error Log</a>
9
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
10
+ <span id="modified">Modified</span>
11
+ <div id="message"></div>
12
+ <p id="tips">
13
+ <span>Command+S = Save</span>
14
+ </p>
15
+ </div>
16
+ <div id="editor"><%= @btsm.custom_html %></div>
17
+ </div>
18
+
19
+ </div>
20
+
21
+ <% content_for :caboose_css do %>
22
+ <style>
23
+ p#tips {
24
+ display: inline-block;
25
+ float: right;
26
+ font-size: 13px;
27
+ color: gray;
28
+ margin: 0;
29
+ padding-top: 15px;
30
+ padding-right: 2px;
31
+ }
32
+ p#tips span {
33
+ display: inline-block;
34
+ margin-left: 12px;
35
+ }
36
+ span#modified {
37
+ font-size: 13px;
38
+ color: gray;
39
+ margin: 0 10px;
40
+ opacity: 0;
41
+ transition: opacity 100ms ease;
42
+ }
43
+ .buttons {
44
+ margin-bottom: 10px;
45
+ }
46
+ .buttons .caboose-btn {
47
+ margin-right: 5px;
48
+ }
49
+ .editor-wrapper {
50
+
51
+ padding-right: 30px;
52
+ }
53
+
54
+ .holder {
55
+
56
+ }
57
+ #editor {
58
+ height: 800px;
59
+ width: 100%;
60
+ opacity: 0;
61
+ }
62
+ #editor.ace_editor {
63
+ opacity: 1;
64
+ }
65
+ #message {
66
+ display: inline-block;
67
+ }
68
+ #message p.note {
69
+ padding: 1px 15px 2px 15px;
70
+ font-size: 15px;
71
+ line-height: 30px;
72
+ border-radius: 5px;
73
+ }
74
+ #message p.note.loading {
75
+ padding-left: 40px;
76
+ }
77
+ </style>
78
+ <% end %>
79
+
80
+ <% content_for :caboose_js do %>
81
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
82
+ <script>
83
+ var editor = ace.edit("editor");
84
+ editor.setTheme("ace/theme/monokai");
85
+ editor.session.setMode("ace/mode/html_ruby");
86
+ editor.session.setOptions({
87
+ tabSize: 2
88
+ });
89
+
90
+ editor.on("change", function() {
91
+ $("span#modified").css('opacity',1);
92
+ });
93
+
94
+ editor.commands.addCommand({
95
+ name: 'save',
96
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
97
+ exec: function(editor) { save(); }
98
+ });
99
+
100
+ function save() {
101
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
102
+ $.ajax({
103
+ url: '/admin/block-type-site-memberships/<%= @btsm.id %>/html',
104
+ type: 'put',
105
+ data: {
106
+ code: editor.getValue()
107
+ },
108
+ success: function(resp) {
109
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
110
+ if (resp.success && resp.message) {
111
+ $("span#modified").css('opacity',0);
112
+ $('#message').html("<p class='note success'>" + resp.message + "</p>").fadeIn().delay(2000).fadeOut();
113
+ }
114
+ }
115
+ });
116
+ }
117
+
118
+ </script>
119
+ <% end %>
@@ -0,0 +1,119 @@
1
+ <h1>Edit Render Function</h1>
2
+
3
+ <div class="editor-wrapper">
4
+
5
+ <div class="holder">
6
+ <div class="clearfix buttons">
7
+ <a href="/admin/block-types/<%= @block_type.id %>" class="caboose-btn">Back</a>
8
+ <a href="/admin/block-types/<%= @block_type.id %>/errors" class="caboose-btn">Error Log</a>
9
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
10
+ <span id="modified">Modified</span>
11
+ <div id="message"></div>
12
+ <p id="tips">
13
+ <span>Command+S = Save</span>
14
+ </p>
15
+ </div>
16
+ <div id="editor"><%= @block_type.render_function %></div>
17
+ </div>
18
+
19
+ </div>
20
+
21
+ <% content_for :caboose_css do %>
22
+ <style>
23
+ p#tips {
24
+ display: inline-block;
25
+ float: right;
26
+ font-size: 13px;
27
+ color: gray;
28
+ margin: 0;
29
+ padding-top: 15px;
30
+ padding-right: 2px;
31
+ }
32
+ p#tips span {
33
+ display: inline-block;
34
+ margin-left: 12px;
35
+ }
36
+ span#modified {
37
+ font-size: 13px;
38
+ color: gray;
39
+ margin: 0 10px;
40
+ opacity: 0;
41
+ transition: opacity 100ms ease;
42
+ }
43
+ .buttons {
44
+ margin-bottom: 10px;
45
+ }
46
+ .buttons .caboose-btn {
47
+ margin-right: 5px;
48
+ }
49
+ .editor-wrapper {
50
+
51
+ padding-right: 30px;
52
+ }
53
+
54
+ .holder {
55
+
56
+ }
57
+ #editor {
58
+ height: 800px;
59
+ width: 100%;
60
+ opacity: 0;
61
+ }
62
+ #editor.ace_editor {
63
+ opacity: 1;
64
+ }
65
+ #message {
66
+ display: inline-block;
67
+ }
68
+ #message p.note {
69
+ padding: 1px 15px 2px 15px;
70
+ font-size: 15px;
71
+ line-height: 30px;
72
+ border-radius: 5px;
73
+ }
74
+ #message p.note.loading {
75
+ padding-left: 40px;
76
+ }
77
+ </style>
78
+ <% end %>
79
+
80
+ <% content_for :caboose_js do %>
81
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
82
+ <script>
83
+ var editor = ace.edit("editor");
84
+ editor.setTheme("ace/theme/monokai");
85
+ editor.session.setMode("ace/mode/html_ruby");
86
+ editor.session.setOptions({
87
+ tabSize: 2
88
+ });
89
+
90
+ editor.on("change", function() {
91
+ $("span#modified").css('opacity',1);
92
+ });
93
+
94
+ editor.commands.addCommand({
95
+ name: 'save',
96
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
97
+ exec: function(editor) { save(); }
98
+ });
99
+
100
+ function save() {
101
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
102
+ $.ajax({
103
+ url: '/admin/block-types/<%= @block_type.id %>/render-function',
104
+ type: 'put',
105
+ data: {
106
+ code: editor.getValue()
107
+ },
108
+ success: function(resp) {
109
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
110
+ if (resp.success && resp.message) {
111
+ $("span#modified").css('opacity',0);
112
+ $('#message').html("<p class='note success'>" + resp.message + "</p>").fadeIn().delay(2000).fadeOut();
113
+ }
114
+ }
115
+ });
116
+ }
117
+
118
+ </script>
119
+ <% end %>