caboose-cms 0.2.5 → 0.2.6

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 (39) hide show
  1. data/app/assets/javascripts/caboose/modal.js +4 -0
  2. data/app/assets/javascripts/caboose/modal_integration.js +10 -0
  3. data/app/assets/javascripts/caboose/model/all.js +9 -0
  4. data/app/assets/javascripts/caboose/model/attribute.js +63 -0
  5. data/app/assets/javascripts/caboose/model/bound_checkbox.js +90 -0
  6. data/app/assets/javascripts/caboose/model/bound_checkbox_multiple.js +106 -0
  7. data/app/assets/javascripts/caboose/model/bound_control.js +68 -0
  8. data/app/assets/javascripts/caboose/model/bound_select.js +108 -0
  9. data/app/assets/javascripts/caboose/model/bound_text.js +87 -0
  10. data/app/assets/javascripts/caboose/model/bound_textarea.js +134 -0
  11. data/app/assets/javascripts/caboose/model/class.js +64 -0
  12. data/app/assets/javascripts/caboose/model/model.js +37 -0
  13. data/app/assets/javascripts/caboose/model/model_binder.js +61 -0
  14. data/app/assets/javascripts/caboose/shortcut.js +11 -0
  15. data/app/assets/javascripts/caboose/station.js +7 -5
  16. data/app/assets/stylesheets/caboose/modal.css +106 -1
  17. data/app/controllers/caboose/admin_controller.rb +1 -9
  18. data/app/controllers/caboose/pages_controller.rb +43 -14
  19. data/app/controllers/caboose/station_controller.rb +3 -0
  20. data/app/models/caboose/page_plugin.rb +1 -1
  21. data/app/models/caboose/user_plugin.rb +1 -1
  22. data/app/views/caboose/admin/index.html.erb +0 -4
  23. data/app/views/caboose/pages/edit.html.erb +6 -19
  24. data/app/views/caboose/pages/edit_content.html.erb +48 -0
  25. data/app/views/caboose/pages/edit_css.html.erb +36 -0
  26. data/app/views/caboose/pages/edit_js.html.erb +36 -0
  27. data/app/views/caboose/pages/edit_seo.html.erb +39 -0
  28. data/app/views/caboose/pages/edit_settings.html.erb +35 -24
  29. data/app/views/caboose/pages/edit_title.html.erb +29 -0
  30. data/app/views/caboose/pages/show.html.erb +2 -2
  31. data/app/views/caboose/station/index.html.erb +5 -2
  32. data/app/views/caboose/users/edit.html.erb +1 -1
  33. data/app/views/layouts/caboose/_admin_top_nav.html.erb +1 -3
  34. data/app/views/layouts/caboose/_top_nav.html.erb +1 -1
  35. data/app/views/layouts/caboose/application.html.erb +2 -2
  36. data/config/routes.rb +6 -1
  37. data/lib/caboose/version.rb +1 -1
  38. metadata +19 -3
  39. data/app/assets/javascripts/caboose/bound_input.js +0 -198
@@ -1,2 +1,2 @@
1
- <% content_for :page_title do %><%= @page.title %><% end %>
2
- <% content_for :page_content do %><%= @page.content %><% end %>
1
+ <% content_for :page_title do %><%= raw @page.title %><% end %>
2
+ <% content_for :page_content do %><%= raw @page.content %><% end %>
@@ -2,6 +2,9 @@
2
2
  @nav = Caboose.plugin_hook('admin_nav', [], @user, @page)
3
3
  return_url = session[:caboose_station_return_url].nil? ? '/' : session[:caboose_station_return_url]
4
4
  return_url = '/' if return_url.starts_with?('/admin/') || return_url == '/admin'
5
+
6
+ width = 200
7
+ @nav.each {|item| width = 400 if item['id'] == @tab } if @tab
5
8
  %>
6
9
 
7
10
  <%= content_for :caboose_js do %>
@@ -10,8 +13,8 @@ return_url = '/' if return_url.starts_with?('/admin/') || return_url == '/admin'
10
13
  var modal = false;
11
14
  var station = false;
12
15
  $(document).ready(function() {
13
- modal = new CabooseModal(200);
14
- station = new CabooseStation(modal);
16
+ modal = new CabooseModal(<%= width %>);
17
+ station = new CabooseStation(modal<%= raw @tab ? ", '#{@tab}'" : '' %>);
15
18
  });
16
19
  </script>
17
20
  <% end %>
@@ -31,7 +31,7 @@ pic = "http://gravatar.com/avatar/#{gravatar_id}.png?s=150" #&d=/assets/caboose/
31
31
  <% end %>
32
32
 
33
33
  <% content_for :caboose_js do %>
34
- <%= javascript_include_tag "caboose/bound_input.js" %>
34
+ <%= javascript_include_tag "caboose/model_binder.js" %>
35
35
  <script type="text/javascript">
36
36
 
37
37
  var model = false;
@@ -6,9 +6,7 @@
6
6
  <li><a href='/login?return_url=#{request.fullpath}' id='caboose_login'><span>Login</span></a></li>
7
7
  <% else %>
8
8
  <li class='back' ><a href='/'><span><< Back to Site</span></a></li>
9
- <li class='cpanel' ><a href='/station' id='caboose_station'><span>Control Panel</span></a></li>
10
- <li class='account' ><a href='/admin/users/<%= @user.id %>/edit'><span>Account</span></a></li>
11
- <li class='logout' ><a href='/logout'><span>Logout</span></a></li>
9
+ <li class='cpanel' ><a href='/station' id='caboose_station'><span>Dashboard</span></a></li>
12
10
  <% end %>
13
11
  </ul>
14
12
  </div>
@@ -5,7 +5,7 @@
5
5
  <% if (@user.nil? || @user == Caboose::User.logged_out_user) %>
6
6
  <li><a href='/login?return_url=#{request.fullpath}' id='caboose_login'><span>Login</span></a></li>
7
7
  <% else %>
8
- <li class='cpanel' ><a href='/station' id='caboose_station'><span>Control Panel</span></a></li>
8
+ <li class='cpanel' ><a href='/station?page_id=<%= @page.id %>' id='caboose_station'><span>Control Panel</span></a></li>
9
9
  <li class='account' ><a href='/admin/users/<%= @user.id %>/edit'><span>Account</span></a></li>
10
10
  <li class='logout' ><a href='/logout'><span>Logout</span></a></li>
11
11
  <% end %>
@@ -9,9 +9,9 @@
9
9
  <%= yield :caboose_css %>
10
10
  <% end %>
11
11
 
12
- <% if (File.exists?("#{Rails.root}/app/views/layouts/layout_#{@page.id}.html.erb")) %>
12
+ <% if (File.exists?("#{Rails.root}/app/views/layouts/layout_#{@page.id}.html.erb") || File.exists?("#{Rails.root}/app/views/layouts/layout_#{@page.id}.html.haml")) %>
13
13
  <%= render :file => "layouts/layout_#{@page.id}" %>
14
- <% elsif (!@page.layout.nil? && @page.layout.length > 0 && File.exists?("#{Rails.root}/app/views/layouts/layout_#{@page.layout}.html.erb")) %>
14
+ <% elsif (!@page.layout.nil? && @page.layout.length > 0 && (File.exists?("#{Rails.root}/app/views/layouts/layout_#{@page.layout}.html.erb") || File.exists?("#{Rails.root}/app/views/layouts/layout_#{@page.layout}.html.haml"))) %>
15
15
  <%= render :file => "layouts/layout_#{@page.layout}" %>
16
16
  <% else %>
17
17
  <%= render :file => "layouts/layout_default" %>
data/config/routes.rb CHANGED
@@ -47,10 +47,15 @@ Caboose::Engine.routes.draw do
47
47
  get "pages" => "pages#index"
48
48
  get "pages/sitemap-options" => "pages#sitemap_options"
49
49
  get "pages/robots-options" => "pages#robots_options"
50
- get "pages/content-format-options" => "pages#content_format_options"
50
+ get "pages/format-options" => "pages#content_format_options"
51
51
  get "pages/new" => "pages#new"
52
52
  get "pages/:id/redirect" => "pages#redirect"
53
53
  get "pages/:id/edit-settings" => "pages#edit_settings"
54
+ get "pages/:id/edit-css" => "pages#edit_css"
55
+ get "pages/:id/edit-js" => "pages#edit_js"
56
+ get "pages/:id/edit-seo" => "pages#edit_seo"
57
+ get "pages/:id/edit-content" => "pages#edit_content"
58
+ get "pages/:id/edit-title" => "pages#edit_title"
54
59
  get "pages/:id/edit" => "pages#edit"
55
60
  get "pages/:id" => "pages#show"
56
61
  put "pages/:id" => "pages#update"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -172,11 +172,22 @@ files:
172
172
  - app/assets/images/caboose/loading_white_on_black.gif
173
173
  - app/assets/javascripts/caboose/admin.js
174
174
  - app/assets/javascripts/caboose/application.js
175
- - app/assets/javascripts/caboose/bound_input.js
176
175
  - app/assets/javascripts/caboose/modal.js
177
176
  - app/assets/javascripts/caboose/modal_integration.js
177
+ - app/assets/javascripts/caboose/model/all.js
178
+ - app/assets/javascripts/caboose/model/attribute.js
179
+ - app/assets/javascripts/caboose/model/bound_checkbox.js
180
+ - app/assets/javascripts/caboose/model/bound_checkbox_multiple.js
181
+ - app/assets/javascripts/caboose/model/bound_control.js
182
+ - app/assets/javascripts/caboose/model/bound_select.js
183
+ - app/assets/javascripts/caboose/model/bound_text.js
184
+ - app/assets/javascripts/caboose/model/bound_textarea.js
185
+ - app/assets/javascripts/caboose/model/class.js
186
+ - app/assets/javascripts/caboose/model/model.js
187
+ - app/assets/javascripts/caboose/model/model_binder.js
178
188
  - app/assets/javascripts/caboose/model.form.page.js
179
189
  - app/assets/javascripts/caboose/model.form.user.js
190
+ - app/assets/javascripts/caboose/shortcut.js
180
191
  - app/assets/javascripts/caboose/station.js
181
192
  - app/assets/stylesheets/caboose/admin.css
182
193
  - app/assets/stylesheets/caboose/application.css
@@ -228,7 +239,12 @@ files:
228
239
  - app/views/caboose/extras/error404.html.erb
229
240
  - app/views/caboose/login/index.html.erb
230
241
  - app/views/caboose/pages/edit.html.erb
242
+ - app/views/caboose/pages/edit_content.html.erb
243
+ - app/views/caboose/pages/edit_css.html.erb
244
+ - app/views/caboose/pages/edit_js.html.erb
245
+ - app/views/caboose/pages/edit_seo.html.erb
231
246
  - app/views/caboose/pages/edit_settings.html.erb
247
+ - app/views/caboose/pages/edit_title.html.erb
232
248
  - app/views/caboose/pages/index.html.erb
233
249
  - app/views/caboose/pages/new.html.erb
234
250
  - app/views/caboose/pages/show.html.erb
@@ -1,198 +0,0 @@
1
-
2
- var Model = function(params) {
3
- for (var thing in params)
4
- this[thing] = params[thing];
5
- };
6
-
7
- Model.prototype = {
8
- name: false,
9
- id: false,
10
- attributes: [],
11
- attributes_clean: [],
12
- update_url: false,
13
-
14
- save: function(attrib, after) {
15
- var this2 = this;
16
- $.ajax({
17
- url: this.update_url,
18
- type: 'put',
19
- data: attrib + '=' + this.attributes[attrib],
20
- success: function(resp) {
21
- if (resp.success)
22
- {
23
- this2.attributes_clean[attrib] = this2.attributes[attrib];
24
- if (resp.attributes && resp.attributes[attrib])
25
- {
26
- this2.attributes[attrib] = resp.attributes[attrib];
27
- this2.attributes_clean[attrib] = resp.attributes[attrib];
28
- }
29
- }
30
- after(resp);
31
- },
32
- error: function() {
33
- after(false);
34
- }
35
- });
36
- }
37
- };
38
-
39
- /******************************************************************************/
40
-
41
- var BoundControl = function(model, attribute, el) {
42
- this.init(model, attribute, el);
43
- };
44
-
45
- BoundControl.prototype = {
46
- el: false,
47
- check: false,
48
- message: false,
49
- model: false,
50
- attribute: false,
51
- binder: false,
52
-
53
- init: function(model, attribute, el) {
54
- this.model = model;
55
- this.attribute = attribute;
56
- this.el = el ? el : model.name.toLowerCase() + '_' + model.id + '_' + attribute;
57
- this.check = this.el + '_check';
58
- this.message = this.el + '_message';
59
-
60
- $('#'+this.el).wrap($('<div/>')
61
- .attr('id', this.el + '_container')
62
- .css('position', 'relative')
63
- );
64
-
65
- var this2 = this;
66
- $('#'+this.el).on('focus', function() { this2.edit(); });
67
- //$('#'+this.el).keydown(function() {
68
- // if (this2.model.attributes[attribute] != this2.model.attributes_clean[attribute])
69
- // this2.edit();
70
- //});
71
- },
72
-
73
- view: function() {
74
- if ($('#'+this.check).length) $('#'+this.check).remove();
75
- if ($('#'+this.message).length) $('#'+this.message).remove();
76
- $('#'+this.el).val(this.model.attributes[this.attribute]);
77
- },
78
-
79
- edit: function() {
80
- this.binder.cancel_active();
81
- this.binder.active_control = this;
82
-
83
- var w = $('#'+this.el).outerWidth();
84
- var h = $('#'+this.el).outerHeight();
85
- var this2 = this;
86
- $('#'+this.el+'_container').prepend($('<div/>')
87
- .attr('id', this.el + '_check')
88
- .addClass('bound_input_check')
89
- .css('position', 'absolute')
90
- .css('top', 0)
91
- .css('left', w-2)
92
- .css('width', h+2)
93
- .css('overflow', 'hidden')
94
- .append($('<a/>')
95
- .html('&#10003;')
96
- .css('width', h)
97
- .css('margin-left', -h)
98
- .attr('href', '#')
99
- .click(function(event) {
100
- event.preventDefault();
101
- this2.save();
102
- })
103
- )
104
- );
105
- $('#'+this.el+'_check a').animate({ 'margin-left': 0 }, 300);
106
- },
107
-
108
- save: function() {
109
- $('#'+this.el+'_check a').addClass('loading');
110
- this.model.attributes[this.attribute] = $('#'+this.el).val();
111
-
112
- var this2 = this;
113
- this.model.save(this.attribute, function(resp) {
114
- $('#'+this2.el+'_check a').removeClass('loading');
115
- if (resp.error) this2.error(resp.error);
116
- else
117
- {
118
- this2.binder.active_control = this2;
119
- //this2.view();
120
- //if ($('#'+this.check).length) $('#'+this.check).remove();
121
- //if ($('#'+this.message).length) $('#'+this.message).remove();
122
- //$('#'+this.el).val(this.model.attributes[this.attribute]);
123
- //$('#'+this2.el).focus();
124
- }
125
- });
126
- },
127
-
128
- cancel: function() {
129
- this.model.attributes[this.attribute] = this.model.attributes_clean[this.attribute];
130
- $('#'+this.el).val(this.model.attributes[this.attribute]);
131
-
132
- if ($('#'+this.el+'_check a').length)
133
- {
134
- var this2 = this;
135
- var h = $('#'+this.el).outerHeight();
136
- $('#'+this.el+'_check a').animate({ 'margin-left': -h }, 300, function() {
137
- this2.view();
138
- });
139
- }
140
- else
141
- this.view();
142
- },
143
-
144
- error: function(str) {
145
- if (!$('#'+this.message).length)
146
- $('#'+this.el+'_container').prepend($('<div/>').attr('id', this.message));
147
- $('#'+this.message).html("<p class='note error'>" + str + "</p>");
148
- }
149
- };
150
-
151
- /******************************************************************************/
152
-
153
- var ModelBinder = function(params) { this.init(params); };
154
-
155
- ModelBinder.prototype = {
156
- model: false,
157
- controls: [],
158
- active_control: false,
159
-
160
- init: function(params) {
161
- this.model = new Model({
162
- name: params['name'],
163
- id: params['id'],
164
- update_url: params['update_url'],
165
- attributes: {},
166
- attributes_clean: {}
167
- });
168
-
169
- var this2 = this;
170
- $.each(params['attributes'], function(i, attrib) {
171
- var el = (this2.model.name + '_' + this2.model.id + '_' + attrib).toLowerCase();
172
- this2.model.attributes[attrib] = $('#'+el).val();
173
- this2.model.attributes_clean[attrib] = $('#'+el).val();
174
- var control = new BoundControl(this2.model, attrib);
175
- control.binder = this2;
176
- this2.controls.push();
177
- });
178
-
179
- $(document).keyup(function(e) {
180
- if (e.keyCode == 27) this2.cancel_active(); // Escape
181
- if (e.keyCode == 13) this2.save_active(); // Enter
182
- });
183
- },
184
-
185
- cancel_active: function() {
186
- if (!this.active_control)
187
- return;
188
- this.active_control.cancel();
189
- this.active_control = false;
190
- },
191
-
192
- save_active: function() {
193
- if (!this.active_control)
194
- return;
195
- this.active_control.save();
196
- this.active_control = false;
197
- },
198
- };