caboose-cms 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/app/assets/images/caboose/caboose_nav.png +0 -0
  2. data/app/assets/javascripts/caboose/admin.js +37 -0
  3. data/app/assets/javascripts/caboose/application.js +2 -1
  4. data/app/assets/javascripts/caboose/model.form.page.js +30 -0
  5. data/app/assets/javascripts/caboose/station.js +223 -0
  6. data/app/assets/stylesheets/caboose/admin.css +57 -0
  7. data/app/assets/stylesheets/caboose/caboose.css +146 -16
  8. data/app/assets/stylesheets/caboose/tinymce.css +25 -0
  9. data/app/controllers/caboose/pages_controller.rb +43 -19
  10. data/app/controllers/caboose/permissions_controller.rb +91 -73
  11. data/app/controllers/caboose/roles_controller.rb +49 -37
  12. data/app/controllers/caboose/settings_controller.rb +100 -0
  13. data/app/controllers/caboose/station_controller.rb +13 -0
  14. data/app/controllers/caboose/users_controller.rb +51 -44
  15. data/app/models/caboose/caboose_plugin.rb +2 -6
  16. data/app/models/caboose/page.rb +3 -3
  17. data/app/models/caboose/page_bar_generator.rb +37 -28
  18. data/app/models/caboose/page_plugin.rb +43 -0
  19. data/app/models/caboose/permission_plugin.rb +27 -0
  20. data/app/models/caboose/role.rb +19 -1
  21. data/app/models/caboose/role_plugin.rb +27 -0
  22. data/app/models/caboose/setting.rb +5 -0
  23. data/app/models/caboose/settings_plugin.rb +27 -0
  24. data/app/models/caboose/user.rb +1 -2
  25. data/app/models/caboose/user_plugin.rb +28 -0
  26. data/app/views/caboose/pages/edit.html.erb +7 -27
  27. data/app/views/caboose/pages/edit_settings.html.erb +38 -0
  28. data/app/views/caboose/pages/sitemap.html.erb +12 -0
  29. data/app/views/caboose/permissions/edit.html.erb +21 -4
  30. data/app/views/caboose/permissions/index.html.erb +29 -21
  31. data/app/views/caboose/permissions/new.html.erb +22 -2
  32. data/app/views/caboose/roles/edit.html.erb +40 -27
  33. data/app/views/caboose/roles/index.html.erb +3 -5
  34. data/app/views/caboose/roles/new.html.erb +30 -11
  35. data/app/views/caboose/settings/edit.html.erb +23 -0
  36. data/app/views/caboose/settings/index.html.erb +33 -0
  37. data/app/views/caboose/settings/new.html.erb +25 -0
  38. data/app/views/caboose/users/edit.html.erb +11 -14
  39. data/app/views/caboose/users/index.html.erb +2 -4
  40. data/app/views/caboose/users/new.html.erb +2 -0
  41. data/app/views/caboose/users/update_pic.html.erb +1 -1
  42. data/app/views/layouts/caboose/_station.html.erb +43 -14
  43. data/app/views/layouts/caboose/{caboose.html.erb → admin.html.erb} +2 -2
  44. data/config/routes.rb +16 -5
  45. data/lib/caboose.rb +1 -1
  46. data/lib/caboose/engine.rb +15 -6
  47. data/lib/caboose/version.rb +1 -1
  48. data/lib/sample_files/tinymce.yml +22 -0
  49. data/lib/tasks/caboose.rake +21 -1
  50. metadata +40 -12
  51. data/app/assets/javascripts/caboose/caboose.js +0 -28
  52. data/app/assets/javascripts/caboose/permissions.js +0 -0
  53. data/app/assets/javascripts/caboose/roles.js +0 -35
  54. data/app/assets/javascripts/caboose/users.js +0 -38
  55. data/app/views/caboose/permissions/show.html.erb +0 -15
  56. data/app/views/caboose/roles/show.html.erb +0 -20
  57. data/app/views/caboose/users/update_resume.html.erb +0 -14
@@ -0,0 +1,37 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require jquery-ui
16
+ //= require tinymce-jquery
17
+ //= require class
18
+ //= require model
19
+ //= require attribute
20
+ //= require form
21
+ //= require form/embedded
22
+ //= require attribute/checkbox-multiple
23
+ //= require attribute/checkbox
24
+ //= require attribute/date-time
25
+ //= require attribute/file
26
+ //= require attribute/hidden
27
+ //= require attribute/image
28
+ //= require attribute/password
29
+ //= require attribute/radio
30
+ //= require attribute/rich-text
31
+ //= require attribute/select
32
+ //= require attribute/texarea
33
+ //= require attribute/textjs
34
+ //= require attribute/h1
35
+ //= require attribute/time
36
+ //= require attribute/video
37
+ //= require caboose/station
@@ -14,6 +14,7 @@
14
14
  //= require jquery
15
15
  //= require jquery_ujs
16
16
  //= require jquery-ui
17
+ //= require tinymce-jquery
17
18
  //= require class
18
19
  //= require model
19
20
  //= require attribute
@@ -33,5 +34,5 @@
33
34
  //= require attribute/textjs
34
35
  //= require attribute/time
35
36
  //= require attribute/video
36
- //= require caboose/caboose
37
+ //= require caboose/station
37
38
  //= require caboose_after
@@ -0,0 +1,30 @@
1
+
2
+ Model.Form.Page = Model.Form.extend({
3
+
4
+ class_name: 'Model.Form.Page',
5
+
6
+ // Returns the form for editing a model or false for an embedded form.
7
+ edit: function()
8
+ {
9
+ var m = this.model;
10
+
11
+ var this2 = this;
12
+ var div = $('<div/>');
13
+ $(m.attributes).each(function(i, a) {
14
+ if (a.type == 'hidden')
15
+ return;
16
+ div.append(
17
+ $('<div/>').attr('id', m.name + '_' + m.id + '_' + a.name + '_container')
18
+ );
19
+ });
20
+
21
+ div.append($('<div/>').attr('id', this.message))
22
+ .append($('<p/>')
23
+ .append($('<input/>').attr('type', 'button').val('Back').click(function() { caboose_station.close_url('/pages/'+m.id+'/redirect'); }))
24
+ .append(' ')
25
+ .append($('<input/>').attr('type', 'button').val('Delete ' + m.name).click(function() { m.ajax_delete(); }))
26
+ );
27
+ return div;
28
+ }
29
+
30
+ });
@@ -0,0 +1,223 @@
1
+
2
+ var CabooseStation = function() {};
3
+
4
+ CabooseStation = Class.extend({
5
+ conductor: false,
6
+ state: 'min', // left, right, or min
7
+ open_tabs: [], // Currently open tabs
8
+
9
+ init: function()
10
+ {
11
+ this.attach_dom();
12
+ //alert(this.open_tabs);
13
+
14
+ if ($('#caboose_station').hasClass('state_left'))
15
+ {
16
+ $('#caboose_station').css('left', 0);
17
+ $('#caboose_station').show();
18
+ this.state = 'left';
19
+ }
20
+ else if ($('#caboose_station').hasClass('state_right'))
21
+ {
22
+ $('#caboose_station').css('right', 0);
23
+ $('#caboose_station').show();
24
+ this.state = 'right';
25
+ }
26
+ else
27
+ {
28
+ $('#caboose_station').hide();
29
+ this.state = 'min';
30
+ }
31
+ },
32
+
33
+ attach_dom: function()
34
+ {
35
+ var this2 = this;
36
+ $('#caboose_station li ul.visible').each(function (i,ul) {
37
+ var id = $(this).parent().attr('id').replace('nav_item_', '');
38
+ this2.open_tabs[this2.open_tabs.length] = id;
39
+ });
40
+
41
+ $('#caboose_conductor').click(function() { this2.open(); });
42
+ $('#caboose_station ul.hidden').hide();
43
+ $('#caboose_station li a.top_level').click(function() {
44
+ ul = $(this).parent().children("ul.hidden:first");
45
+ var id = $(this).parent().attr('id').replace('nav_item_', '');
46
+ if (ul.length)
47
+ {
48
+ ul.slideDown(200).addClass('visible').removeClass('hidden');
49
+ this2.open_tabs[this2.open_tabs.length] = id;
50
+ }
51
+ else
52
+ {
53
+ ul = $(this).parent().children("ul:first");
54
+ ul.hide().addClass('hidden').removeClass('visible');
55
+
56
+ var index = this2.open_tabs.indexOf(id);
57
+ if (index > -1)
58
+ this2.open_tabs.splice(index, 1);
59
+ }
60
+ });
61
+ $('#caboose_station li ul a').each(function(i, a) {
62
+ var href = $(a).attr('href');
63
+ $(a).click(function(event) {
64
+ event.preventDefault();
65
+ this2.open_url(href);
66
+ })
67
+ });
68
+ $('#caboose_station a.close').click(function(event) {
69
+ event.preventDefault();
70
+
71
+ if (this2.state == 'left')
72
+ this2.close_url($(this).attr('href'));
73
+ else if (this2.state == 'right')
74
+ this2.min();
75
+ });
76
+ },
77
+
78
+ min: function()
79
+ {
80
+ if (this.state == 'min')
81
+ return;
82
+ if (this.state == 'right')
83
+ {
84
+ $('#caboose_station').hide('slide', { direction: 'right' }, 300);
85
+ }
86
+ else if (this.state == 'left')
87
+ {
88
+ var w = $(window).width();
89
+ $('#caboose_station').animate({ left: '+=' + w }, 300);
90
+ }
91
+ this.state = 'min';
92
+ },
93
+
94
+ left: function(func_after)
95
+ {
96
+ if (this.state == 'left')
97
+ return;
98
+ if (!func_after)
99
+ func_after = function() {};
100
+ if (this.state == 'right')
101
+ {
102
+ var w = $(window).width() - $('#caboose_station').width();
103
+ $('#caboose_station').animate({ left: '-=' + w }, 300, func_after);
104
+ }
105
+ else if (this.state == 'min')
106
+ {
107
+ var w = $(window).width();
108
+ $('#caboose_station').animate({ left: '+=' + w }, 300, func_after);
109
+ }
110
+ this.state = 'left';
111
+ },
112
+
113
+ right: function(func_after)
114
+ {
115
+ if (this.state == 'right')
116
+ return;
117
+ if (!func_after)
118
+ func_after = function() {};
119
+ if (this.state == 'left')
120
+ {
121
+ var w = $(window).width() - $('#caboose_station').width();
122
+ $('#caboose_station').animate({ left: '+=' + w }, 300, func_after);
123
+ }
124
+ else if (this.state == 'min')
125
+ {
126
+ $('#caboose_station').show('slide', { direction: 'right' }, 300, func_after);
127
+ }
128
+ this.state = 'right';
129
+ },
130
+
131
+ open: function()
132
+ {
133
+ if (this.state == 'min')
134
+ this.right();
135
+ else if (this.state == 'right')
136
+ this.left();
137
+ },
138
+
139
+ close: function()
140
+ {
141
+ if (this.state == 'min')
142
+ return;
143
+ if (this.state == 'left')
144
+ this.right();
145
+ else if (this.state == 'right');
146
+ this.min();
147
+ },
148
+
149
+ open_url: function(url)
150
+ {
151
+ // Send the station settings first
152
+ var this2 = this;
153
+ $.ajax({
154
+ url: '/admin/station',
155
+ type: 'put',
156
+ data: {
157
+ state: 'left',
158
+ open_tabs: this2.open_tabs,
159
+ return_url: window.location.pathname
160
+ },
161
+ success: function() {
162
+ if (this2.state == 'left')
163
+ {
164
+ window.location = url;
165
+ return;
166
+ }
167
+
168
+ var w = $(window).width() - $('#caboose_station').width();
169
+ var h = $(window).height();
170
+
171
+ $('#caboose_station').after(
172
+ $('<div/>')
173
+ .attr('id', 'caboose_white')
174
+ .css({
175
+ position: 'absolute',
176
+ right: -1,
177
+ top: 0,
178
+ width: 1,
179
+ height: h,
180
+ background: 'url(/assets/loading.gif) 40px 40px no-repeat #fff'
181
+ })
182
+ );
183
+ $('#caboose_station').removeClass('state_right').addClass('state_left');
184
+ $('#caboose_station').animate({ left: '-=' + w }, 300, function() {
185
+ //$.ajax({
186
+ // url: url,
187
+ // success: function(html) { window.location = url; }
188
+ //});
189
+ window.location = url;
190
+ });
191
+ $('#caboose_white').animate({ width: '+=' + w }, 300);
192
+ }
193
+ });
194
+ },
195
+
196
+ close_url: function(url)
197
+ {
198
+ // Send the station settings first
199
+ var this2 = this;
200
+ $.ajax({
201
+ url: '/admin/station',
202
+ type: 'put',
203
+ data: {
204
+ state: 'right',
205
+ open_tabs: this2.open_tabs,
206
+ return_url: false
207
+ },
208
+ success: function() {
209
+ var w = $(window).width() - $('#caboose_station').width();
210
+ $('#caboose_station').removeClass('state_left').addClass('state_right');
211
+ $('#content_wrapper').animate({ marginLeft: '+=' + w }, 300);
212
+ $('#caboose_station').animate({ left: '+=' + w }, 300, function() { window.location = url; })
213
+ }
214
+ });
215
+ }
216
+ });
217
+
218
+ /******************************************************************************/
219
+
220
+ var caboose_station = false;
221
+ $(document).ready(function() {
222
+ caboose_station = new CabooseStation();
223
+ });
@@ -0,0 +1,57 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require modeljs
12
+ *= require caboose/caboose
13
+ */
14
+
15
+ body {
16
+ margin: 0;
17
+ padding: 0;
18
+ }
19
+
20
+ #top_nav {
21
+ display: none;
22
+ }
23
+
24
+ #content_wrapper {
25
+ margin-left: 208px;
26
+ }
27
+
28
+ #content {
29
+ padding: 0 0 0 30px;
30
+ }
31
+
32
+ #content h1 {
33
+ margin: 0 0 20px -30px;
34
+ padding: 40px 0 0 30px;
35
+ height: 80px;
36
+ background: #e1e1e1;
37
+ border-bottom: #aaa 1px solid;
38
+ font-size: 36pt;
39
+ }
40
+
41
+ #content h1.model_attribute_h1 {
42
+ margin: inherit;
43
+ padding: inherit;
44
+ height: auto;
45
+ background: transparent;
46
+ border-bottom: none;
47
+ font-size: 36pt;
48
+ }
49
+
50
+ p.current_page_editing {
51
+ position: absolute;
52
+ top: 84px;
53
+ left: 212px;
54
+
55
+ margin: 0;
56
+ padding: 10px 10px 10px 30px;
57
+ }
@@ -13,8 +13,18 @@ body {
13
13
 
14
14
  .page_links a {
15
15
  display: inline-block;
16
- padding: 4px 8px;
17
- border: #efefef 1px solid;
16
+ margin: 0 2px;
17
+ padding: 5px 8px 3px 8px;
18
+
19
+ border: #505050 1px solid;
20
+ background: #e1e1e1;
21
+ color: #505050;
22
+ text-decoration: none;
23
+ }
24
+
25
+ .page_links a:hover {
26
+ background: #505050;
27
+ color: #fff;
18
28
  }
19
29
 
20
30
  .page_links .middle_links a {
@@ -23,43 +33,163 @@ body {
23
33
 
24
34
  .page_links span.current_page {
25
35
  display: inline-block;
26
- padding: 4px 8px;
27
- font-weight: bold;
36
+ padding: 5px 8px 3px 8px;
37
+
38
+ border: #941403 1px solid;
39
+ background: #941403;
40
+ color: #fff;
41
+ text-decoration: none;
28
42
  }
29
43
 
30
44
  #caboose_station {
45
+ display: none;
31
46
  position: absolute;
32
47
  top: 0;
33
48
  right: 0;
34
- width: 250px;
49
+ width: 208px;
35
50
  height: 100%;
36
- background: #333;
37
- border: #000 2px solid;
51
+ background: #e1e1e1;
52
+ border: #aaa 1px solid;
53
+ }
54
+
55
+ #caboose_station h2 {
56
+ height: 86px;
57
+ background-image: url('/assets/caboose/caboose_nav.png');
58
+ background-position: 0 -33px;
59
+ margin: 0;
60
+ padding: 0;
61
+ border-bottom: #aaa 1px solid;
62
+
63
+ /* Hide the text. */
64
+ text-indent: 100%;
65
+ white-space: nowrap;
66
+ overflow: hidden;
38
67
  }
39
68
 
40
- #caboose_station ul {
69
+ #caboose_station ul.account {
70
+ margin: 0;
71
+ padding: 0;
72
+ list-style: none;
73
+ height: 33px;
74
+ }
75
+
76
+ #caboose_station ul.account li {
77
+ margin: 0;
78
+ padding: 0;
79
+ list-style: none;
80
+ float: left;
81
+ border: 0;
82
+ background: #ccc;
83
+ }
84
+
85
+ #caboose_station ul.account li a {
86
+ display: block;
87
+ margin: 0;
88
+ padding: 0;
89
+ height: 33px;
90
+ background-image: url(/assets/caboose/caboose_nav.png);
91
+ background-repeat: no-repeat;
92
+ background-position: 0 0;
93
+
94
+ /* Hide the text. */
95
+ text-indent: 100%;
96
+ white-space: nowrap;
97
+ overflow: hidden;
98
+ }
99
+
100
+ #caboose_station ul.account li.my_account a { width: 103px; background-position: 0px 0px; border-right: #828181 1px solid; }
101
+ #caboose_station ul.account li.logout a { width: 103px; background-position: -106px 0px; border-left: #cecece 1px solid; }
102
+
103
+ #caboose_station ul.account li.my_account a:hover { background-position: -212px 0px; }
104
+ #caboose_station ul.account li.logout a:hover { background-position: -318px 0px; }
105
+
106
+ #caboose_station ul.account li a:hover {
107
+ color: #941403;
108
+ }
109
+
110
+ #caboose_station ul.admin {
41
111
  margin: 0;
42
112
  padding: 0;
43
113
  list-style: none;
44
114
  }
45
115
 
46
- #caboose_station ul li {
116
+ #caboose_station ul.admin li {
47
117
  margin: 0;
48
118
  padding: 0;
49
119
  list-style: none;
50
120
  }
51
121
 
52
- #caboose_station a {
122
+ #caboose_station ul.admin li ul {
123
+ margin: 0;
124
+ padding: 0;
125
+ list-style: none;
126
+ }
127
+
128
+ #caboose_station ul.admin a {
53
129
  display: block;
54
- color: #fff;
55
- text-decoration: none;
56
130
  margin: 1px 0 0 0;
57
131
  padding: 8px 10px;
58
- background: #444;
132
+ color: #505050;
133
+ text-decoration: none;
59
134
  }
60
135
 
61
- #caboose_station a:hover {
62
- background: #555;
136
+ #caboose_station ul.admin a:hover {
137
+ color: #941403;
138
+ }
139
+
140
+ #caboose_station ul.admin a.top_level {
141
+ background-image: url('/assets/caboose/caboose_nav.png');
142
+ background-repeat: no-repeat;
143
+ background-position: 0 0;
144
+ width: 208px;
145
+ height: 50px;
146
+ margin: 0;
147
+ padding: 0;
148
+ border-top: #f7f7f7 1px solid;
149
+ border-bottom: #aaa 1px solid;
150
+
151
+ /* Hide the text. */
152
+ text-indent: 100%;
153
+ white-space: nowrap;
154
+ overflow: hidden;
155
+ }
156
+
157
+ #caboose_station ul.admin li#nav_item_users a.top_level { background-position: 0px -119px; }
158
+ #caboose_station ul.admin li#nav_item_roles a.top_level { background-position: 0px -171px; }
159
+ #caboose_station ul.admin li#nav_item_permissions a.top_level { background-position: 0px -222px; }
160
+ #caboose_station ul.admin li#nav_item_pages a.top_level { background-position: 0px -275px; }
161
+ #caboose_station ul.admin li#nav_item_settings a.top_level { background-position: 0px -328px; }
162
+
163
+ #caboose_station ul.admin li#nav_item_users a.top_level:hover { background-position: -212px -119px; }
164
+ #caboose_station ul.admin li#nav_item_roles a.top_level:hover { background-position: -212px -171px; }
165
+ #caboose_station ul.admin li#nav_item_permissions a.top_level:hover { background-position: -212px -222px; }
166
+ #caboose_station ul.admin li#nav_item_pages a.top_level:hover { background-position: -212px -275px; }
167
+ #caboose_station ul.admin li#nav_item_settings a.top_level:hover { background-position: -212px -328px; }
168
+
169
+ #caboose_station ul.admin li#nav_item_users a.top_level:active { background-position: -424px -119px; }
170
+ #caboose_station ul.admin li#nav_item_roles a.top_level:active { background-position: -424px -171px; }
171
+ #caboose_station ul.admin li#nav_item_permissions a.top_level:active { background-position: -424px -222px; }
172
+ #caboose_station ul.admin li#nav_item_pages a.top_level:active { background-position: -424px -275px; }
173
+ #caboose_station ul.admin li#nav_item_settings a.top_level:active { background-position: -424px -328px; }
174
+
175
+ #caboose_station.state_left a.close,
176
+ #caboose_station.state_right a.close {
177
+ display: block;
178
+ background-image: url('/assets/caboose/caboose_nav.png');
179
+ background-repeat: no-repeat;
180
+ background-position: 0 0;
181
+ width: 208px;
182
+ height: 50px;
183
+
184
+ /* Hide the text. */
185
+ text-indent: 100%;
186
+ white-space: nowrap;
187
+ overflow: hidden;
63
188
  }
64
189
 
65
- #caboose_station
190
+ #caboose_station.state_left a.close { background-position: 0px -422px; } /* Back */
191
+ #caboose_station.state_right a.close { background-position: 0px -380px; } /* Close */
192
+ #caboose_station.state_left a.close:hover { background-position: -212px -422px; } /* Back */
193
+ #caboose_station.state_right a.close:hover { background-position: -212px -380px; } /* Close */
194
+ #caboose_station.state_left a.close:active { background-position: -424px -422px; } /* Back */
195
+ #caboose_station.state_right a.close:active { background-position: -424px -380px; } /* Close */