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
@@ -25,6 +25,7 @@
25
25
  <%
26
26
  tabs = {
27
27
  'General' => "/admin/sites/#{@site.id}",
28
+ 'Contact Info' => "/admin/sites/#{@site.id}/contact",
28
29
  'Block Types' => "/admin/sites/#{@site.id}/block-types",
29
30
  'Custom CSS' => "/admin/sites/#{@site.id}/css",
30
31
  'Custom JS' => "/admin/sites/#{@site.id}/js",
@@ -36,6 +37,10 @@ tabs = {
36
37
  <% tabs.each do |text, href| %>
37
38
  <li<%= raw request.fullpath == href ? " class='selected'" : '' %>><a href='<%= href %>'><%= raw text %></a></li>
38
39
  <% end %>
39
- <li class='back'><input type='button' value='< Back' onclick="window.location='/admin/sites';" /></li>
40
+ <% if @site.is_master %>
41
+ <li class="back"><input type="button" onclick="window.location='/admin/sites';" value="< Back" />
42
+ <% else %>
43
+ <li class="back"><input type="button" onclick="window.location='/admin';" value="< Back" />
44
+ <% end %>
40
45
  </ul>
41
46
  <div id='content2'>
@@ -3,16 +3,25 @@ s = @site
3
3
  %>
4
4
  <%= render :partial => 'caboose/sites/admin_header' %>
5
5
 
6
- <h2>Block Types</h2>
6
+ <h5 style="margin:0 0 10px 0;font-size:18px;">Block Types</h5>
7
7
  <div id='block_types'>
8
8
  <table class='data'>
9
- <tr><th>&nbsp;</th><th>Name</th><th>Description</th></tr>
9
+ <tr><th>&nbsp;</th><th>Name</th><th>Description</th><th></th></tr>
10
10
  <% bt_ids = @site.block_type_site_memberships.collect{ |bt| bt.block_type_id } %>
11
11
  <% Caboose::BlockType.where("parent_id is null").reorder('name').all.each do |bt| %>
12
- <tr>
12
+ <tr id="bt_<%= bt.id %>">
13
13
  <td align='center'><input type='checkbox' name='block_type_id_<%= bt.id %>' <%= bt_ids.include?(bt.id) ? "checked='true'" : '' %> onclick="toggle_block_type_site_membership(<%= @site.id %>, <%= bt.id %>, $(this).prop('checked'));" /></td>
14
14
  <td><%= bt.name %></td>
15
15
  <td><%= bt.description %></td>
16
+ <td>
17
+ <% if bt_ids.include?(bt.id) %>
18
+ <% btsm = @site.block_type_site_memberships.where(:block_type_id => bt.id).first %>
19
+ <a style="margin-right:5px;" href="/admin/block-type-site-memberships/<%= btsm.id %>/html" class="caboose-btn">Custom Render Function</a>
20
+ <% if @site.theme %>
21
+ <a href="/admin/block-type-site-memberships/<%= btsm.id %>/css" class="caboose-btn">Custom SCSS</a>
22
+ <% end %>
23
+ <% end %>
24
+ </td>
16
25
  </tr>
17
26
  <% end %>
18
27
  </table><br/>
@@ -22,13 +31,18 @@ s = @site
22
31
 
23
32
  <%= render :partial => 'caboose/sites/admin_footer' %>
24
33
 
34
+ <% content_for :caboose_css do %>
35
+ <style>
36
+ td .caboose-btn {
37
+ font-size: 12px;
38
+ padding: 0 8px;
39
+ }
40
+ </style>
41
+ <% end %>
42
+
25
43
  <% content_for :caboose_js do %>
26
44
  <script type="text/javascript">
27
45
 
28
- $(document).ready(function() {
29
-
30
- });
31
-
32
46
  function toggle_block_type_site_membership(site_id, block_type_id, checked)
33
47
  {
34
48
  $.ajax({
@@ -37,7 +51,20 @@ function toggle_block_type_site_membership(site_id, block_type_id, checked)
37
51
  data: {
38
52
  site_id: [site_id, checked ? 1 : 0]
39
53
  },
40
- succes: function(resp) {}
54
+ success: function(resp) {
55
+ if ( checked && resp.btsm_id ) {
56
+ var btn1 = '<a style="margin-right:5px;" href="/admin/block-type-site-memberships/' + resp.btsm_id + '/html" class="caboose-btn">Custom Render Function</a>';
57
+ <% if @site.theme %>
58
+ var btn2 = '<a href="/admin/block-type-site-memberships/' + resp.btsm_id + '/css" class="caboose-btn">Custom SCSS</a>';
59
+ <% else %>
60
+ var btn2 = '';
61
+ <% end %>
62
+ $("#bt_" + block_type_id + " td:nth-of-type(4)").html(btn1 + btn2);
63
+ }
64
+ else {
65
+ $("#bt_" + block_type_id + " td:nth-of-type(4)").html('');
66
+ }
67
+ }
41
68
  });
42
69
  }
43
70
 
@@ -0,0 +1,41 @@
1
+ <%= render :partial => 'caboose/sites/admin_header' %>
2
+
3
+ <h5 style="margin:0;font-size:18px;">Contact Info</h5>
4
+
5
+ <p><div id='site_<%= @site.id %>_main_phone'></div></p>
6
+ <p><div id='site_<%= @site.id %>_alt_phone'></div></p>
7
+ <p><div id='site_<%= @site.id %>_address1'></div></p>
8
+ <p><div id='site_<%= @site.id %>_address2'></div></p>
9
+ <p><div id='site_<%= @site.id %>_city'></div></p>
10
+ <p><div id='site_<%= @site.id %>_state'></div></p>
11
+ <p><div id='site_<%= @site.id %>_zip'></div></p>
12
+ <p><div id='site_<%= @site.id %>_fax'></div></p>
13
+ <p><div id='site_<%= @site.id %>_contact_email'></div></p>
14
+
15
+ <%= render :partial => 'caboose/sites/admin_footer' %>
16
+
17
+
18
+ <% content_for :caboose_js do %>
19
+ <script type="text/javascript">
20
+
21
+ $(document).ready(function() {
22
+ new ModelBinder({
23
+ name: 'Site',
24
+ id: <%= @site.id %>,
25
+ update_url: '/admin/sites/<%= @site.id %>',
26
+ authenticity_token: '<%= form_authenticity_token %>',
27
+ attributes: [
28
+ { name: 'main_phone', nice_name: 'Main Phone', type: 'text', value: <%== Caboose.json(@site.main_phone) %>, width: 400 },
29
+ { name: 'alt_phone', nice_name: 'Alternate Phone', type: 'text', value: <%== Caboose.json(@site.alt_phone) %>, width: 400 },
30
+ { name: 'address1', nice_name: 'Address', type: 'text', value: <%== Caboose.json(@site.address1) %>, width: 400 },
31
+ { name: 'address2', nice_name: 'Address 2', type: 'text', value: <%== Caboose.json(@site.address2) %>, width: 400 },
32
+ { name: 'city', nice_name: 'City', type: 'text', value: <%== Caboose.json(@site.city) %>, width: 400 },
33
+ { name: 'state', nice_name: 'State', type: 'text', value: <%== Caboose.json(@site.state) %>, width: 400 },
34
+ { name: 'zip', nice_name: 'ZIP', type: 'text', value: <%== Caboose.json(@site.zip) %>, width: 400 },
35
+ { name: 'fax', nice_name: 'Fax', type: 'text', value: <%== Caboose.json(@site.fax) %>, width: 400 },
36
+ { name: 'contact_email', nice_name: 'Email', type: 'text', value: <%== Caboose.json(@site.contact_email) %>, width: 400 }
37
+ ]
38
+ });
39
+ });
40
+ </script>
41
+ <% end %>
@@ -1,35 +1,121 @@
1
1
 
2
2
  <%= render :partial => 'caboose/sites/admin_header' %>
3
3
 
4
- <p><div id='site_<%= @site.id %>_custom_css' ></div></p>
4
+ <div class="editor-wrapper">
5
5
 
6
- <%= render :partial => 'caboose/sites/admin_footer' %>
6
+ <div class="holder">
7
+ <div class="clearfix buttons">
8
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
9
+ <span id="modified">Modified</span>
10
+ <div id="message"></div>
11
+ <p id="tips">
12
+ <span>Command+S = Save</span>
13
+ </p>
14
+ </div>
15
+ <div id="editor"><%= @site.custom_css %></div>
16
+ </div>
17
+
18
+ </div>
7
19
 
8
20
  <% content_for :caboose_css do %>
9
21
  <style>
10
- textarea {
11
- font-family: monospace;
12
- font-size: 13px;
13
- line-height: 20px;
14
- padding: 30px 9px 9px 9px !important;
22
+ p#tips {
23
+ display: inline-block;
24
+ float: right;
25
+ font-size: 13px;
26
+ color: gray;
27
+ margin: 0;
28
+ padding-top: 15px;
29
+ padding-right: 2px;
30
+ }
31
+ p#tips span {
32
+ display: inline-block;
33
+ margin-left: 12px;
34
+ }
35
+ span#modified {
36
+ font-size: 13px;
37
+ color: gray;
38
+ margin: 0 10px;
39
+ opacity: 0;
40
+ transition: opacity 100ms ease;
41
+ }
42
+ .buttons {
43
+ margin-bottom: 10px;
44
+ }
45
+ .buttons .caboose-btn {
46
+ margin-right: 5px;
47
+ }
48
+ .editor-wrapper {
49
+
50
+ padding-right: 30px;
51
+ }
52
+
53
+ .holder {
54
+
55
+ }
56
+ #editor {
57
+ height: 800px;
58
+ width: 100%;
59
+ opacity: 0;
60
+ }
61
+ #editor.ace_editor {
62
+ opacity: 1;
63
+ }
64
+ #message {
65
+ display: inline-block;
66
+ }
67
+ #message p.note {
68
+ padding: 1px 15px 2px 15px;
69
+ font-size: 15px;
70
+ line-height: 30px;
71
+ border-radius: 5px;
72
+ }
73
+ #message p.note.loading {
74
+ padding-left: 40px;
15
75
  }
16
76
  </style>
17
77
  <% end %>
18
78
 
19
79
  <% content_for :caboose_js do %>
20
- <script type="text/javascript">
21
-
22
- $(document).ready(function() {
23
- new ModelBinder({
24
- name: 'Site',
25
- id: <%= @site.id %>,
26
- update_url: '/admin/sites/<%= @site.id %>',
27
- authenticity_token: '<%= form_authenticity_token %>',
28
- attributes: [
29
- { name: 'custom_css', nice_name: 'Custom CSS', type: 'textarea' , value: <%= raw Caboose.json(@site.custom_css) %>, width: 600, height: 400 }
30
- ]
31
- });
32
- });
80
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
81
+ <script>
82
+ var editor = ace.edit("editor");
83
+ editor.setTheme("ace/theme/monokai");
84
+ editor.session.setMode("ace/mode/css");
85
+ editor.session.setOptions({
86
+ tabSize: 2
87
+ });
88
+
89
+ editor.on("change", function() {
90
+ $("span#modified").css('opacity',1);
91
+ });
92
+
93
+ editor.commands.addCommand({
94
+ name: 'save',
95
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
96
+ exec: function(editor) { save(); }
97
+ });
98
+
99
+ function save() {
100
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
101
+ $.ajax({
102
+ url: '/admin/sites/<%= @site.id %>',
103
+ type: 'put',
104
+ data: {
105
+ custom_css: editor.getValue()
106
+ },
107
+ success: function(resp) {
108
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
109
+ if (resp.success) {
110
+ $("span#modified").css('opacity',0);
111
+ $('#message').html("<p class='note success'>CSS saved!</p>").fadeIn().delay(2000).fadeOut();
112
+ }
113
+ }
114
+ });
115
+ }
33
116
 
34
117
  </script>
35
118
  <% end %>
119
+
120
+
121
+ <%= render :partial => 'caboose/sites/admin_footer' %>
@@ -1,35 +1,122 @@
1
1
 
2
2
  <%= render :partial => 'caboose/sites/admin_header' %>
3
3
 
4
- <p><div id='site_<%= @site.id %>_custom_js' ></div></p>
4
+ <div class="editor-wrapper">
5
5
 
6
- <%= render :partial => 'caboose/sites/admin_footer' %>
6
+ <div class="holder">
7
+ <div class="clearfix buttons">
8
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
9
+ <span id="modified">Modified</span>
10
+ <div id="message"></div>
11
+ <p id="tips">
12
+ <span>Command+S = Save</span>
13
+ </p>
14
+ </div>
15
+ <div id="editor"><%= @site.custom_js %></div>
16
+ </div>
17
+
18
+ </div>
7
19
 
8
20
  <% content_for :caboose_css do %>
9
21
  <style>
10
- textarea {
11
- font-family: monospace;
12
- font-size: 13px;
13
- line-height: 20px;
14
- padding: 30px 9px 9px 9px !important;
22
+ p#tips {
23
+ display: inline-block;
24
+ float: right;
25
+ font-size: 13px;
26
+ color: gray;
27
+ margin: 0;
28
+ padding-top: 15px;
29
+ padding-right: 2px;
30
+ }
31
+ p#tips span {
32
+ display: inline-block;
33
+ margin-left: 12px;
34
+ }
35
+ span#modified {
36
+ font-size: 13px;
37
+ color: gray;
38
+ margin: 0 10px;
39
+ opacity: 0;
40
+ transition: opacity 100ms ease;
41
+ }
42
+ .buttons {
43
+ margin-bottom: 10px;
44
+ }
45
+ .buttons .caboose-btn {
46
+ margin-right: 5px;
47
+ }
48
+ .editor-wrapper {
49
+
50
+ padding-right: 30px;
51
+ }
52
+
53
+ .holder {
54
+
55
+ }
56
+ #editor {
57
+ height: 800px;
58
+ width: 100%;
59
+ opacity: 0;
60
+ }
61
+ #editor.ace_editor {
62
+ opacity: 1;
63
+ }
64
+ #message {
65
+ display: inline-block;
66
+ }
67
+ #message p.note {
68
+ padding: 1px 15px 2px 15px;
69
+ font-size: 15px;
70
+ line-height: 30px;
71
+ border-radius: 5px;
72
+ }
73
+ #message p.note.loading {
74
+ padding-left: 40px;
15
75
  }
16
76
  </style>
17
77
  <% end %>
18
78
 
19
79
  <% content_for :caboose_js do %>
20
- <script type="text/javascript">
21
-
22
- $(document).ready(function() {
23
- new ModelBinder({
24
- name: 'Site',
25
- id: <%= @site.id %>,
26
- update_url: '/admin/sites/<%= @site.id %>',
27
- authenticity_token: '<%= form_authenticity_token %>',
28
- attributes: [
29
- { name: 'custom_js', nice_name: 'Custom Javascript', type: 'textarea' , value: <%= raw Caboose.json(@site.custom_js) %>, width: 600, height: 400 }
30
- ]
31
- });
32
- });
80
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
81
+ <script>
82
+ var editor = ace.edit("editor");
83
+ editor.setTheme("ace/theme/monokai");
84
+ editor.session.setMode("ace/mode/javascript");
85
+ editor.session.setOptions({
86
+ tabSize: 2
87
+ });
88
+
89
+ editor.on("change", function() {
90
+ $("span#modified").css('opacity',1);
91
+ });
92
+
93
+ editor.commands.addCommand({
94
+ name: 'save',
95
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
96
+ exec: function(editor) { save(); }
97
+ });
98
+
99
+ function save() {
100
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
101
+ $.ajax({
102
+ url: '/admin/sites/<%= @site.id %>',
103
+ type: 'put',
104
+ data: {
105
+ custom_js: editor.getValue()
106
+ },
107
+ success: function(resp) {
108
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
109
+ if (resp.success) {
110
+ $("span#modified").css('opacity',0);
111
+ $('#message').html("<p class='note success'>JS saved!</p>").fadeIn().delay(2000).fadeOut();
112
+ }
113
+ }
114
+ });
115
+ }
33
116
 
34
117
  </script>
35
118
  <% end %>
119
+
120
+
121
+ <%= render :partial => 'caboose/sites/admin_footer' %>
122
+
@@ -0,0 +1,118 @@
1
+ <h1>Edit SCSS</h1>
2
+
3
+ <div class="editor-wrapper">
4
+
5
+ <div class="holder">
6
+ <div class="clearfix buttons">
7
+ <a href="/admin/theme-files" class="caboose-btn">Back</a>
8
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
9
+ <span id="modified">Modified</span>
10
+ <div id="message"></div>
11
+ <p id="tips">
12
+ <span>Command+S = Save</span>
13
+ </p>
14
+ </div>
15
+ <div id="editor"><%= @themefile.code %></div>
16
+ </div>
17
+
18
+ </div>
19
+
20
+ <% content_for :caboose_css do %>
21
+ <style>
22
+ p#tips {
23
+ display: inline-block;
24
+ float: right;
25
+ font-size: 13px;
26
+ color: gray;
27
+ margin: 0;
28
+ padding-top: 15px;
29
+ padding-right: 2px;
30
+ }
31
+ p#tips span {
32
+ display: inline-block;
33
+ margin-left: 12px;
34
+ }
35
+ span#modified {
36
+ font-size: 13px;
37
+ color: gray;
38
+ margin: 0 10px;
39
+ opacity: 0;
40
+ transition: opacity 100ms ease;
41
+ }
42
+ .buttons {
43
+ margin-bottom: 10px;
44
+ }
45
+ .buttons .caboose-btn {
46
+ margin-right: 5px;
47
+ }
48
+ .editor-wrapper {
49
+
50
+ padding-right: 30px;
51
+ }
52
+
53
+ .holder {
54
+
55
+ }
56
+ #editor {
57
+ height: 800px;
58
+ width: 100%;
59
+ opacity: 0;
60
+ }
61
+ #editor.ace_editor {
62
+ opacity: 1;
63
+ }
64
+ #message {
65
+ display: inline-block;
66
+ }
67
+ #message p.note {
68
+ padding: 1px 15px 2px 15px;
69
+ font-size: 15px;
70
+ line-height: 30px;
71
+ border-radius: 5px;
72
+ }
73
+ #message p.note.loading {
74
+ padding-left: 40px;
75
+ }
76
+ </style>
77
+ <% end %>
78
+
79
+ <% content_for :caboose_js do %>
80
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
81
+ <script>
82
+ var editor = ace.edit("editor");
83
+ editor.setTheme("ace/theme/monokai");
84
+ editor.session.setMode("ace/mode/scss");
85
+ editor.session.setOptions({
86
+ tabSize: 2
87
+ });
88
+
89
+ editor.on("change", function() {
90
+ $("span#modified").css('opacity',1);
91
+ });
92
+
93
+ editor.commands.addCommand({
94
+ name: 'save',
95
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
96
+ exec: function(editor) { save(); }
97
+ });
98
+
99
+ function save() {
100
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
101
+ $.ajax({
102
+ url: '/admin/theme-files/<%= @themefile.id %>/sass',
103
+ type: 'put',
104
+ data: {
105
+ code: editor.getValue()
106
+ },
107
+ success: function(resp) {
108
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
109
+ if (resp.success && resp.message) {
110
+ $("span#modified").css('opacity',0);
111
+ $('#message').html("<p class='note success'>" + resp.message + "</p>").fadeIn().delay(2000).fadeOut();
112
+ }
113
+ }
114
+ });
115
+ }
116
+
117
+ </script>
118
+ <% end %>