caboose-cms 0.2.23 → 0.2.24

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.
@@ -8,7 +8,7 @@ module Caboose
8
8
 
9
9
  # GET /admin/roles
10
10
  def index
11
- return if !user_is_allowed('roles', 'view')
11
+ return unless user_is_allowed('roles', 'view')
12
12
  top_roles = Role.tree
13
13
  arr = []
14
14
  top_roles.each { |r| arr += add_role_options(r, 0) }
@@ -17,19 +17,19 @@ module Caboose
17
17
 
18
18
  # GET /admin/roles/new
19
19
  def new
20
- return if !user_is_allowed('roles', 'add')
20
+ return unless user_is_allowed('roles', 'add')
21
21
  @role = Role.new
22
22
  end
23
23
 
24
24
  # GET /admin/roles/1/edit
25
25
  def edit
26
- return if !user_is_allowed('roles', 'edit')
26
+ return unless user_is_allowed('roles', 'edit')
27
27
  @role = Role.find(params[:id])
28
28
  end
29
29
 
30
30
  # POST /admin/roles
31
31
  def create
32
- return if !user_is_allowed('roles', 'add')
32
+ return unless user_is_allowed('roles', 'add')
33
33
 
34
34
  resp = StdClass.new({
35
35
  'error' => nil,
@@ -47,7 +47,7 @@ module Caboose
47
47
 
48
48
  # PUT /admin/roles/1
49
49
  def update
50
- return if !user_is_allowed('roles', 'edit')
50
+ return unless user_is_allowed('roles', 'edit')
51
51
 
52
52
  resp = StdClass.new
53
53
  role = Role.find(params[:id])
@@ -89,7 +89,7 @@ module Caboose
89
89
 
90
90
  # DELETE /admin/roles/1
91
91
  def destroy
92
- return if !user_is_allowed('roles', 'delete')
92
+ return unless user_is_allowed('roles', 'delete')
93
93
  @role = Role.find(params[:id])
94
94
  @role.destroy
95
95
  render json: { 'redirect' => '/admin/roles' }
@@ -97,7 +97,7 @@ module Caboose
97
97
 
98
98
  # GET /admin/roles/options
99
99
  def options
100
- return if !user_is_allowed('roles', 'view')
100
+ return unless user_is_allowed('roles', 'view')
101
101
  @top_roles = Role.tree
102
102
  arr = [{
103
103
  "value" => -1,
@@ -113,7 +113,7 @@ module Caboose
113
113
  "text" => (" - " * level) + role.name
114
114
  }]
115
115
  role.children.each do |kid|
116
- arr += add_role_options(kid, level+1)
116
+ arr += add_role_options(kid, level + 1)
117
117
  end
118
118
  return arr
119
119
  end
@@ -16,7 +16,8 @@ class Caboose::Page < ActiveRecord::Base
16
16
  :hide,
17
17
  :content_format,
18
18
  :custom_css,
19
- :custom_js,
19
+ :custom_js,
20
+ :linked_resources,
20
21
  :layout,
21
22
  :seo_title, # 70 chars
22
23
  :meta_description, # 156 chars
@@ -1,12 +1,56 @@
1
- <% content_for :page_title do %><%= raw "<span id='editmode_title_container'>#{@page.title}</span>" %><% end %>
2
- <% content_for :page_content do %><%= raw "<div id='editmode_content_container'>#{@page.content}</div>" %><% end %>
1
+ <h1 id='editmode_title_container' ><%= @page.title %></h1>
2
+ <div id='editmode_content_container' ><%= @page.content == nil || @page.content.length == 0 ? 'No content.' : (raw @page.content) %></div>
3
+
4
+ <% content_for :caboose_css do %>
5
+ <% @resources[:css].each do |r| %>
6
+ <!--link type='text/css' rel='stylesheet' href="<%= r %>" /-->
7
+ <%= stylesheet_link_tag r %>
8
+ <% end %>
9
+
10
+ <style><%= raw @page.custom_css %></style>
11
+ <% end %>
12
+
3
13
  <% content_for :caboose_js do %>
4
- <script type='text/javascript'>
5
14
 
6
- $(document).ready(function() {
7
- $('#editmode_title_container' ).click(function() { $.colorbox({ href: '/pages/<%= @page.id %>/edit-title' , iframe: true, initialWidth: 500, initialHeight: 80, innerWidth: 500, innerHeight: 80, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 }); });
8
- $('#editmode_content_container').click(function() { $.colorbox({ href: '/pages/<%= @page.id %>/edit-content' , iframe: true, initialWidth: 600, initialHeight: 400, innerWidth: 600, innerHeight: 400, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 }); });
9
- });
15
+ <% @resources[:js].each do |r| %>
16
+ <!--script type='text/javascript' src="<%= r %>" ></script-->
17
+ <%= javascript_include_tag r %>
18
+ <% end %>
19
+
20
+ <script type='text/javascript'><%= raw @page.custom_js %></script>
10
21
 
11
- </script>
22
+ <script type='text/javascript'>
23
+ $(document).ready(function() {
24
+ $('#editmode_title_container').click(function() {
25
+ $.colorbox({
26
+ href: '/pages/<%= @page.id %>/edit-title',
27
+ iframe: true,
28
+ initialWidth: 500,
29
+ initialHeight: 80,
30
+ innerWidth: 500,
31
+ innerHeight: 80,
32
+ scrolling: false,
33
+ transition: 'fade',
34
+ closeButton: false,
35
+ onComplete: fix_colorbox,
36
+ opacity: 0.50
37
+ });
38
+ });
39
+ $('#editmode_content_container').click(function() {
40
+ $.colorbox({
41
+ href: '/pages/<%= @page.id %>/edit-content',
42
+ iframe: true,
43
+ initialWidth: 600,
44
+ initialHeight: 400,
45
+ innerWidth: 600,
46
+ innerHeight: 400,
47
+ scrolling: false,
48
+ transition: 'fade',
49
+ closeButton: false,
50
+ onComplete: fix_colorbox,
51
+ opacity: 0.50
52
+ });
53
+ });
54
+ });
55
+ </script>
12
56
  <% end %>
@@ -1,48 +1,60 @@
1
1
 
2
- <p><textarea id='page_<%= @page.id %>_content' placeholder='Content' style='width: 600px; height: 400px;' class='tinymce'><%= raw @page.content %></textarea></p>
2
+ <textarea id='page_<%= @page.id %>_content' placeholder='Content' style='width:795px; height:545px;' class='tinymce'><%= raw @page.content %></textarea>
3
+ <br />
3
4
  <div id='message'></div>
4
5
  <div id='controls'>
5
6
  <input type='button' value='Close' onclick="modal.close();" />
6
7
  <input type='button' value='Update' onclick="updateContent();" />
7
8
  </div>
8
9
 
9
- <% content_for :caboose_css do %>
10
+ <% content_for :caboose_js do %>
10
11
 
11
- <% end %>
12
+ <%= javascript_include_tag "caboose/model/all" %>
13
+ <%= tinymce_assets %>
12
14
 
13
- <% content_for :caboose_js do %>
14
- <%= javascript_include_tag "caboose/model/all" %>
15
- <%= javascript_include_tag "tinymce/preinit.js" %>
16
- <%= javascript_include_tag "tinymce/tinymce_jquery.js" %>
17
- <%= javascript_include_tag "tinymce/jquery.tinymce.js" %>
18
- <%= javascript_include_tag "tinymce-jquery.js" %>
19
- <script type="text/javascript">
20
-
21
- var modal = false;
22
- $(document).ready(function() {
23
- modal = new CabooseModal(600, 475);
24
- });
25
-
26
- function updateContent()
27
- {
28
- tinymce.triggerSave();
29
- $.ajax({
30
- url: '/pages/<%= @page.id %>',
31
- type: 'put',
32
- data: {
33
- content: $('#page_<%= @page.id %>_content').val()
34
- },
35
- success: function(resp) {
36
- if (resp.success)
37
- {
38
- parent.$('#editmode_content_container').html($('#page_<%= @page.id %>_content').val());
39
- modal.close();
40
- }
41
- if (resp.error)
42
- modal.autosize("<p class='note success'>" + resp.error + "</p>");
43
- }
15
+ <script type="text/javascript">
16
+
17
+ var modal = false;
18
+ $(document).ready(function() {
19
+ modal = new CabooseModal(800, 700);
44
20
  });
45
- }
46
- </script>
47
- <%= tinymce :caboose %>
21
+
22
+ function updateContent()
23
+ {
24
+ tinymce.triggerSave();
25
+
26
+ function log(msg) {
27
+ setTimeout(function() {
28
+ throw new Error(msg);
29
+ }, 0);
30
+ }
31
+ // log($('#page_<%= @page.id %>_content').val());
32
+
33
+ $.ajax({
34
+ url: '/pages/<%= @page.id %>',
35
+ type: 'put',
36
+ data: {
37
+ authenticity_token: "<%= form_authenticity_token %>",
38
+ content: $('#page_<%= @page.id %>_content').val()
39
+ },
40
+ success: function(resp) {
41
+ if (resp.success)
42
+ {
43
+ contentVal = $('#page_<%= @page.id %>_content').val();
44
+ parent.$('#editmode_content_container').html(contentVal == null || contentVal.length == 0 ? 'No content.' : contentVal);
45
+ modal.close();
46
+ }
47
+ if (resp.error)
48
+ modal.autosize("<p class='note success'>" + resp.error + "</p>");
49
+ }
50
+ });
51
+ }
52
+
53
+ </script>
54
+ <%= tinymce :caboose,
55
+ width:'795px',
56
+ height:'545px'
57
+ # theme_advanced_source_editor_width: '100px',
58
+ # theme_advanced_source_editor_height: '100px'
59
+ %>
48
60
  <% end %>
@@ -1,36 +1,51 @@
1
1
 
2
2
  <h1>Page Settings</h1>
3
3
  <div class='top_right_controls'>
4
- <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
- <input type='button' value='CSS' disabled='true' onclick="window.location='/pages/<%= @page.id %>/edit-css';" />
6
- <input type='button' value='JS' onclick="window.location='/pages/<%= @page.id %>/edit-js';" />
7
- <input type='button' value='SEO' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" />
4
+ <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
+ <input type='button' value='CSS' onclick="window.location='/pages/<%= @page.id %>/edit-css';" disabled='true' />
6
+ <input type='button' value='JS' onclick="window.location='/pages/<%= @page.id %>/edit-js';" />
7
+ <input type='button' value='SEO' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" />
8
+ <input type='button' value='Resources' onclick="window.location='/pages/<%= @page.id %>/edit-resources';" />
8
9
  </div>
9
- <p><div id='page_<%= @page.id %>_custom_css'></div></p>
10
-
10
+
11
+ <textarea id='page_<%= @page.id %>_custom_css' placeholder='Custom CSS' style='width:795px; height:595px;'><%= raw @page.custom_css %></textarea>
12
+ <br />
13
+ <div id='message'></div>
14
+ <div id='controls'>
15
+ <input type='button' value='Close' onclick="modal.close();" />
16
+ <input type='button' value='Update' onclick="updateCustomCSS();" />
17
+ </div>
18
+
11
19
  <% content_for :caboose_js do %>
12
- <%= javascript_include_tag "caboose/model/all" %>
13
- <script type="text/javascript">
14
20
 
15
- var modal = false;
16
- $(document).ready(function() {
17
- m = new ModelBinder({
18
- name: 'Page',
19
- id: <%= @page.id %>,
20
- update_url: '/pages/<%= @page.id %>',
21
- attributes: [
22
- {
23
- name: 'custom_css',
24
- nice_name: 'Custom CSS',
25
- type: 'textarea',
26
- width: 580,
27
- height: 400,
28
- value: <%= raw Caboose.json(@page.custom_css) %>
29
- }
30
- ]
31
- });
32
- modal = new CabooseModal(600, 460);
33
- });
21
+ <%= javascript_include_tag "caboose/model/all" %>
22
+ <script type="text/javascript">
23
+
24
+ var modal = false;
25
+ $(document).ready(function() {
26
+ modal = new CabooseModal(800, 700);
27
+ });
28
+
29
+ function updateCustomCSS()
30
+ {
31
+ $.ajax({
32
+ url: '/pages/<%= @page.id %>',
33
+ type: 'put',
34
+ data: {
35
+ authenticity_token: "<%= form_authenticity_token %>",
36
+ custom_css: $('#page_<%= @page.id %>_custom_css').val()
37
+ },
38
+ success: function(resp) {
39
+ if (resp.success) {
40
+ contentVal = $('#page_<%= @page.id %>_custom_css').val();
41
+ // parent.$('#editmode_content_container').html(contentVal == null || contentVal.length == 0 ? 'No content.' : contentVal);
42
+ modal.close();
43
+ }
44
+ if (resp.error)
45
+ modal.autosize("<p class='note success'>" + resp.error + "</p>");
46
+ }
47
+ });
48
+ }
34
49
 
35
- </script>
50
+ </script>
36
51
  <% end %>
@@ -1,36 +1,51 @@
1
1
 
2
2
  <h1>Page Settings</h1>
3
3
  <div class='top_right_controls'>
4
- <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
- <input type='button' value='CSS' onclick="window.location='/pages/<%= @page.id %>/edit-css';" />
6
- <input type='button' value='JS' disabled='true' onclick="window.location='/pages/<%= @page.id %>/edit-js';" />
7
- <input type='button' value='SEO' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" />
4
+ <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
+ <input type='button' value='CSS' onclick="window.location='/pages/<%= @page.id %>/edit-css';" />
6
+ <input type='button' value='JS' onclick="window.location='/pages/<%= @page.id %>/edit-js';" disabled='true' />
7
+ <input type='button' value='SEO' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" />
8
+ <input type='button' value='Resources' onclick="window.location='/pages/<%= @page.id %>/edit-resources';" />
9
+ </div>
10
+
11
+ <textarea id='page_<%= @page.id %>_custom_js' placeholder='Custom Javascript' style='width:795px; height:595px;'><%= raw @page.custom_js %></textarea>
12
+ <br />
13
+ <div id='message'></div>
14
+ <div id='controls'>
15
+ <input type='button' value='Close' onclick="modal.close();" />
16
+ <input type='button' value='Update' onclick="updateCustomJs();" />
8
17
  </div>
9
- <p><div id='page_<%= @page.id %>_custom_js'></div></p>
10
18
 
11
19
  <% content_for :caboose_js do %>
12
- <%= javascript_include_tag "caboose/model/all" %>
13
- <script type="text/javascript">
14
20
 
15
- var modal = false;
16
- $(document).ready(function() {
17
- m = new ModelBinder({
18
- name: 'Page',
19
- id: <%= @page.id %>,
20
- update_url: '/pages/<%= @page.id %>',
21
- attributes: [
22
- {
23
- name: 'custom_js',
24
- nice_name: 'Custom Javascript',
25
- type: 'textarea',
26
- width: 580,
27
- height: 400,
28
- value: <%= raw Caboose.json(@page.custom_js) %>
29
- }
30
- ]
31
- });
32
- modal = new CabooseModal(600, 460);
33
- });
21
+ <%= javascript_include_tag "caboose/model/all" %>
22
+ <script type="text/javascript">
23
+
24
+ var modal = false;
25
+ $(document).ready(function() {
26
+ modal = new CabooseModal(800, 700);
27
+ });
28
+
29
+ function updateCustomJs()
30
+ {
31
+ $.ajax({
32
+ url: '/pages/<%= @page.id %>',
33
+ type: 'put',
34
+ data: {
35
+ authenticity_token: "<%= form_authenticity_token %>",
36
+ custom_js: $('#page_<%= @page.id %>_custom_js').val()
37
+ },
38
+ success: function(resp) {
39
+ if (resp.success) {
40
+ contentVal = $('#page_<%= @page.id %>_custom_js').val();
41
+ // parent.$('#editmode_content_container').html(contentVal == null || contentVal.length == 0 ? 'No content.' : contentVal);
42
+ modal.close();
43
+ }
44
+ if (resp.error)
45
+ modal.autosize("<p class='note success'>" + resp.error + "</p>");
46
+ }
47
+ });
48
+ }
34
49
 
35
- </script>
50
+ </script>
36
51
  <% end %>
@@ -0,0 +1,41 @@
1
+
2
+ <h1>Page Settings</h1>
3
+ <div class='top_right_controls'>
4
+ <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
+ <input type='button' value='CSS' onclick="window.location='/pages/<%= @page.id %>/edit-css';" />
6
+ <input type='button' value='JS' onclick="window.location='/pages/<%= @page.id %>/edit-js';" />
7
+ <input type='button' value='SEO' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" />
8
+ <input type='button' value='Resources' onclick="window.location='/pages/<%= @page.id %>/edit-resources';" disabled='true' />
9
+ </div>
10
+ <p><div id='page_<%= @page.id %>_linked_resources'></div></p>
11
+ <p>Here you can provide paths to resources to be included in your page, such as css and javascript files.</p>
12
+ <br />
13
+ <p>Paths should be given on separate lines</p>
14
+
15
+ <% content_for :caboose_js do %>
16
+ <%= javascript_include_tag "caboose/model/all" %>
17
+ <script type="text/javascript">
18
+
19
+ var modal = false;
20
+ $(document).ready(function() {
21
+ m = new ModelBinder({
22
+ name: 'Page',
23
+ id: <%= @page.id %>,
24
+ update_url: '/pages/<%= @page.id %>',
25
+ authenticity_token: '<%= form_authenticity_token %>',
26
+ attributes: [
27
+ {
28
+ name: 'linked_resources',
29
+ nice_name: 'Linked Resources',
30
+ type: 'textarea',
31
+ width: 580,
32
+ height: 400,
33
+ value: <%= raw Caboose.json(@page.linked_resources) %>
34
+ }
35
+ ]
36
+ });
37
+ modal = new CabooseModal(600, 460);
38
+ });
39
+
40
+ </script>
41
+ <% end %>
@@ -1,10 +1,11 @@
1
1
 
2
2
  <h1>Page Settings</h1>
3
3
  <div class='top_right_controls'>
4
- <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
- <input type='button' value='CSS' onclick="window.location='/pages/<%= @page.id %>/edit-css';" />
6
- <input type='button' value='JS' onclick="window.location='/pages/<%= @page.id %>/edit-js';" />
7
- <input type='button' value='SEO' disabled='true' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" />
4
+ <input type='button' value='General' onclick="window.location='/pages/<%= @page.id %>/edit-settings';" />
5
+ <input type='button' value='CSS' onclick="window.location='/pages/<%= @page.id %>/edit-css';" />
6
+ <input type='button' value='JS' onclick="window.location='/pages/<%= @page.id %>/edit-js';" />
7
+ <input type='button' value='SEO' onclick="window.location='/pages/<%= @page.id %>/edit-seo';" disabled='true' />
8
+ <input type='button' value='Resources' onclick="window.location='/pages/<%= @page.id %>/edit-resources';" />
8
9
  </div>
9
10
  <p><div id='page_<%= @page.id %>_seo_title'></div></p>
10
11
  <p><div id='page_<%= @page.id %>_meta_description'></div></p>
@@ -23,6 +24,7 @@ $(document).ready(function() {
23
24
  name: 'Page',
24
25
  id: <%= @page.id %>,
25
26
  update_url: '/pages/<%= @page.id %>',
27
+ authenticity_token: '<%= form_authenticity_token %>',
26
28
  attributes: [
27
29
  { name: 'seo_title' , nice_name: 'SEO Title' , type: 'text' , value: <%= raw Caboose.json(@page.seo_title) %>, width: 580 },
28
30
  { name: 'meta_robots' , nice_name: 'Meta Robots' , type: 'text' , value: <%= raw Caboose.json(@page.meta_robots) %>, width: 580 },