caboose-cms 0.1.35 → 0.1.78
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +112 -3
- data/app/assets/javascripts/caboose/application.js +2 -2
- data/app/assets/javascripts/caboose/station.js +37 -64
- data/app/assets/stylesheets/caboose/admin.css +2 -1
- data/app/assets/stylesheets/caboose/application.css +1 -2
- data/app/assets/stylesheets/caboose/caboose.css +26 -10
- data/app/views/layouts/caboose/_station.html.erb +3 -2
- data/bin/caboose +41 -27
- data/lib/caboose/caboose_helper.rb +8 -183
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +9 -1
- metadata +17 -7
- data/lib/sample_files/caboose.rb +0 -12
- data/lib/sample_files/caboose_after.css +0 -0
- data/lib/sample_files/caboose_after.js +0 -0
- data/lib/sample_files/caboose_before.css +0 -0
- data/lib/sample_files/caboose_before.js +0 -0
- data/lib/sample_files/caboose_station.html.erb +0 -19
data/README.md
CHANGED
@@ -1,4 +1,113 @@
|
|
1
|
-
Caboose
|
2
|
-
|
1
|
+
<h1>Caboose CMS</h1>
|
2
|
+
<p>Caboose is a simple yet flexible and powerful content management system that runs
|
3
|
+
on top of ruby on rails. It handles users, roles, permissions, and the login process.
|
4
|
+
In addition, it handles content pages and their URLs. It has a layout system that
|
5
|
+
allows a developer to easily customize the look and feel of each page.</p>
|
3
6
|
|
4
|
-
|
7
|
+
<ul>
|
8
|
+
<li><a href='#installation'>Installation</a></li>
|
9
|
+
<li><a href='#layouts'>Layouts</a></li>
|
10
|
+
<li><a href='#plugins'>Plugins</a></li>
|
11
|
+
</ul>
|
12
|
+
|
13
|
+
<a name='installation'></a><h2>Installation</h2>
|
14
|
+
<p>Install the caboose-cms gem:</p>
|
15
|
+
<pre>
|
16
|
+
$ gem install caboose-cms
|
17
|
+
</pre>
|
18
|
+
<p>Create a new rails app configured to use Caboose:</p>
|
19
|
+
<pre>
|
20
|
+
$ caboose new my_caboose_app
|
21
|
+
</pre>
|
22
|
+
<p>Now go create a local MySQL database called <code>my_caboose_app_development</code>. Then let Caboose install the database:</p>
|
23
|
+
<pre>
|
24
|
+
$ cd my_caboose_app
|
25
|
+
$ rake caboose:db
|
26
|
+
</pre>
|
27
|
+
<p>That's it! To test it out, start your rails server:</p>
|
28
|
+
<pre>
|
29
|
+
$ rails server
|
30
|
+
</pre>
|
31
|
+
<p>And go check out http://localhost:3000</p>
|
32
|
+
|
33
|
+
<a name='layouts'></a><h2>Layouts</h2>
|
34
|
+
<p>Caboose already handles the page editing process, but you need to be able to
|
35
|
+
control the layout for each of those pages. You do that with layouts. Caboose
|
36
|
+
has a simple layout system. You control which layout each page uses. There are three options:
|
37
|
+
<dl>
|
38
|
+
<dt>Default layout:</dt>
|
39
|
+
<dd><p>The layout that any page by default will use if any other layout options are not set. This layout resides in the <code>layout_default.html.erb</code> file.</p></dd>
|
40
|
+
<dt>Per page layout:</dt>
|
41
|
+
<dd>
|
42
|
+
<p>Just create a new layout called <code>layout_<page_id>.html.erb</code>.</p>
|
43
|
+
<p>Example: <code>layout_37.html.erb</code></p>
|
44
|
+
</dd>
|
45
|
+
<dt>Per type layout:</dt>
|
46
|
+
<dd>
|
47
|
+
<p>If you need multiple pages to use a common layout, just create a layout with a name.</p>
|
48
|
+
<p>Examples: <code>layout_about.html.erb</code>, <code>layout_listing.html.erb</code></p>
|
49
|
+
</dd>
|
50
|
+
</dl>
|
51
|
+
<p>For each layout, a few things must exist in the layout for it to work properly with Caboose.
|
52
|
+
You must include the following:</p>
|
53
|
+
<ul>
|
54
|
+
<li>
|
55
|
+
<p>CSS and CSRF in the head:</p>
|
56
|
+
<pre>
|
57
|
+
<%= yield :css %>
|
58
|
+
<%= csrf_meta_tags %>
|
59
|
+
</pre>
|
60
|
+
</li>
|
61
|
+
<li>
|
62
|
+
<p>The top nav login/control panel link:</p>
|
63
|
+
<pre>
|
64
|
+
<%= render :partial => 'layouts/caboose/top_nav' %>
|
65
|
+
</pre>
|
66
|
+
</li>
|
67
|
+
<li>
|
68
|
+
<p>The top nav login/control panel link:</p>
|
69
|
+
<pre>
|
70
|
+
<%= render :partial => 'layouts/caboose/top_nav' %>
|
71
|
+
</pre>
|
72
|
+
</li>
|
73
|
+
<li>
|
74
|
+
<p>The station and javascript in the footer:</p>
|
75
|
+
<pre>
|
76
|
+
<%= render :partial => 'layouts/caboose/station' %>
|
77
|
+
<%= yield :js %>
|
78
|
+
</pre>
|
79
|
+
</li>
|
80
|
+
</ul>
|
81
|
+
<p>You have access to the <code>@page</code> object in the layout. Here's a bare-bones example of all the elements:
|
82
|
+
|
83
|
+
<pre>
|
84
|
+
<!DOCTYPE html>
|
85
|
+
<html>
|
86
|
+
<head>
|
87
|
+
<title>My App</title>
|
88
|
+
<%= yield :css %>
|
89
|
+
<%= csrf_meta_tags %>
|
90
|
+
</head>
|
91
|
+
<body;>
|
92
|
+
<%= render :partial => 'layouts/caboose/top_nav' %>
|
93
|
+
|
94
|
+
<h1><%= raw @page.title %></h1>
|
95
|
+
<%= raw @page.content %>
|
96
|
+
|
97
|
+
<%= render :partial => 'layouts/caboose/station' %>
|
98
|
+
<%= yield :js %>
|
99
|
+
</body>
|
100
|
+
</html>
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
<a name='plugins'><h2>Plugins</h2>
|
104
|
+
<p>To add new functionality to the Caboose station, extend the Caboose::CaboosePlugin
|
105
|
+
object and override the methods you'd like to implement. The existing hooks
|
106
|
+
are the following:</p>
|
107
|
+
|
108
|
+
<dl>
|
109
|
+
<dt><code>String page_content(String str)</code></dt>
|
110
|
+
<dd>Manipulate the page content before it's shown on the screen.</dd>
|
111
|
+
<dt><code>Array admin_nav(Array arr)</code></dt>
|
112
|
+
<dd>Add items to the navigation that appears in the Caboose station.</dd>
|
113
|
+
</dl>
|
@@ -10,7 +10,6 @@
|
|
10
10
|
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
11
|
// GO AFTER THE REQUIRES BELOW.
|
12
12
|
//
|
13
|
-
//= require caboose_before
|
14
13
|
//= require jquery
|
15
14
|
//= require jquery_ujs
|
16
15
|
//= require jquery.ui.all
|
@@ -32,7 +31,8 @@
|
|
32
31
|
//= require attribute/select
|
33
32
|
//= require attribute/texarea
|
34
33
|
//= require attribute/textjs
|
34
|
+
//= require attribute/h1
|
35
35
|
//= require attribute/time
|
36
36
|
//= require attribute/video
|
37
37
|
//= require caboose/station
|
38
|
-
//= require
|
38
|
+
//= require application
|
@@ -5,27 +5,32 @@ CabooseStation = Class.extend({
|
|
5
5
|
conductor: false,
|
6
6
|
state: 'min', // left, right, or min
|
7
7
|
open_tabs: [], // Currently open tabs
|
8
|
+
wrapper_width: 0,
|
8
9
|
|
9
10
|
init: function()
|
10
11
|
{
|
12
|
+
this.wrapper_width = $('#caboose_station_wrapper').width();
|
11
13
|
this.attach_dom();
|
14
|
+
$('body').css('overflow', 'scroll-y');
|
12
15
|
//alert(this.open_tabs);
|
13
16
|
|
14
|
-
if ($('#
|
17
|
+
if ($('#caboose_station_wrapper').hasClass('state_left'))
|
15
18
|
{
|
16
|
-
$('#
|
17
|
-
$('#
|
19
|
+
$('#caboose_station_wrapper').css('left', 0);
|
20
|
+
$('#caboose_station_wrapper').show();
|
18
21
|
this.state = 'left';
|
19
22
|
}
|
20
|
-
else if ($('#
|
23
|
+
else if ($('#caboose_station_wrapper').hasClass('state_right'))
|
21
24
|
{
|
22
|
-
$('#
|
23
|
-
$('#
|
25
|
+
$('#caboose_station_wrapper').css('right', 0);
|
26
|
+
$('#caboose_station_wrapper').show();
|
24
27
|
this.state = 'right';
|
25
28
|
}
|
26
29
|
else
|
27
30
|
{
|
28
|
-
$('#
|
31
|
+
$('#caboose_station_wrapper').css('right', 0);
|
32
|
+
$('#caboose_station_wrapper').css('width', 0);
|
33
|
+
$('#caboose_station_wrapper').show();
|
29
34
|
this.state = 'min';
|
30
35
|
}
|
31
36
|
},
|
@@ -38,7 +43,7 @@ CabooseStation = Class.extend({
|
|
38
43
|
this2.open_tabs[this2.open_tabs.length] = id;
|
39
44
|
});
|
40
45
|
|
41
|
-
$('#caboose_conductor').click(function() { this2.
|
46
|
+
$('#caboose_conductor').click(function() { this2.right(); });
|
42
47
|
$('#caboose_station ul.hidden').hide();
|
43
48
|
$('#caboose_station li a.top_level').click(function() {
|
44
49
|
ul = $(this).parent().children("ul.hidden:first");
|
@@ -75,19 +80,16 @@ CabooseStation = Class.extend({
|
|
75
80
|
});
|
76
81
|
},
|
77
82
|
|
78
|
-
min: function()
|
83
|
+
min: function(func_after)
|
79
84
|
{
|
80
85
|
if (this.state == 'min')
|
81
86
|
return;
|
82
|
-
if (
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
{
|
88
|
-
var w = $(window).width();
|
89
|
-
$('#caboose_station').animate({ left: '+=' + w }, 300);
|
90
|
-
}
|
87
|
+
if (!func_after)
|
88
|
+
func_after = function() {};
|
89
|
+
|
90
|
+
// Assume you never go from left to min
|
91
|
+
$('#caboose_station_wrapper').removeClass('state_left state_right').addClass('state_min');
|
92
|
+
$('#caboose_station_wrapper').animate({ width: 0 }, 300);
|
91
93
|
this.state = 'min';
|
92
94
|
},
|
93
95
|
|
@@ -96,17 +98,11 @@ CabooseStation = Class.extend({
|
|
96
98
|
if (this.state == 'left')
|
97
99
|
return;
|
98
100
|
if (!func_after)
|
99
|
-
func_after = function() {};
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
}
|
105
|
-
else if (this.state == 'min')
|
106
|
-
{
|
107
|
-
var w = $(window).width();
|
108
|
-
$('#caboose_station').animate({ left: '+=' + w }, 300, func_after);
|
109
|
-
}
|
101
|
+
func_after = function() {};
|
102
|
+
|
103
|
+
// Assume you never go from min to left
|
104
|
+
$('#caboose_station_wrapper').removeClass('state_min state_right').addClass('state_left');
|
105
|
+
$('#caboose_station_wrapper').animate({ left: 0 }, 300, func_after);
|
110
106
|
this.state = 'left';
|
111
107
|
},
|
112
108
|
|
@@ -116,36 +112,19 @@ CabooseStation = Class.extend({
|
|
116
112
|
return;
|
117
113
|
if (!func_after)
|
118
114
|
func_after = function() {};
|
115
|
+
|
116
|
+
$('#caboose_station_wrapper').removeClass('state_min state_left').addClass('state_right');
|
119
117
|
if (this.state == 'left')
|
120
118
|
{
|
121
|
-
|
122
|
-
$('#caboose_station').animate({ left: '+=' + w }, 300, func_after);
|
119
|
+
$('#caboose_station_wrapper').animate({ right: 0 }, 300, func_after);
|
123
120
|
}
|
124
121
|
else if (this.state == 'min')
|
125
|
-
{
|
126
|
-
$('#
|
122
|
+
{
|
123
|
+
$('#caboose_station_wrapper').animate({ width: this.wrapper_width }, 300, func_after);
|
127
124
|
}
|
128
125
|
this.state = 'right';
|
129
126
|
},
|
130
127
|
|
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
128
|
open_url: function(url)
|
150
129
|
{
|
151
130
|
// Send the station settings first
|
@@ -168,26 +147,20 @@ CabooseStation = Class.extend({
|
|
168
147
|
var w = $(window).width() - $('#caboose_station').width();
|
169
148
|
var h = $(window).height();
|
170
149
|
|
171
|
-
$('#
|
150
|
+
$('#caboose_station_wrapper').after(
|
172
151
|
$('<div/>')
|
173
152
|
.attr('id', 'caboose_white')
|
174
153
|
.css({
|
175
154
|
position: 'absolute',
|
176
|
-
right:
|
155
|
+
right: 0,
|
177
156
|
top: 0,
|
178
|
-
width:
|
157
|
+
width: 0,
|
179
158
|
height: h,
|
180
159
|
background: 'url(/assets/loading.gif) 40px 40px no-repeat #fff'
|
181
160
|
})
|
182
161
|
);
|
183
|
-
$('#
|
184
|
-
$('#
|
185
|
-
//$.ajax({
|
186
|
-
// url: url,
|
187
|
-
// success: function(html) { window.location = url; }
|
188
|
-
//});
|
189
|
-
window.location = url;
|
190
|
-
});
|
162
|
+
$('#caboose_station_wrapper').removeClass('state_right').addClass('state_left');
|
163
|
+
$('#caboose_station_wrapper').animate({ left: 0 }, 300, function() { window.location = url; });
|
191
164
|
$('#caboose_white').animate({ width: '+=' + w }, 300);
|
192
165
|
}
|
193
166
|
});
|
@@ -207,9 +180,9 @@ CabooseStation = Class.extend({
|
|
207
180
|
},
|
208
181
|
success: function() {
|
209
182
|
var w = $(window).width() - $('#caboose_station').width();
|
210
|
-
$('#
|
183
|
+
$('#caboose_station_wrapper').removeClass('state_left').addClass('state_right');
|
211
184
|
$('#content_wrapper').animate({ marginLeft: '+=' + w }, 300);
|
212
|
-
$('#
|
185
|
+
$('#caboose_station_wrapper').animate({ left: w }, 300, function() { window.location = url; })
|
213
186
|
}
|
214
187
|
});
|
215
188
|
}
|
@@ -22,6 +22,7 @@ body {
|
|
22
22
|
}
|
23
23
|
|
24
24
|
#content_wrapper {
|
25
|
+
position: relative;
|
25
26
|
margin-left: 208px;
|
26
27
|
}
|
27
28
|
|
@@ -50,7 +51,7 @@ body {
|
|
50
51
|
p.current_page_editing {
|
51
52
|
position: absolute;
|
52
53
|
top: 84px;
|
53
|
-
left:
|
54
|
+
left: 4px;
|
54
55
|
|
55
56
|
margin: 0;
|
56
57
|
padding: 10px 10px 10px 30px;
|
@@ -8,8 +8,7 @@
|
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
9
|
* compiled file, but it's generally better to create a new file per style scope.
|
10
10
|
*
|
11
|
-
*= require caboose_before
|
12
11
|
*= require modeljs
|
13
12
|
*= require caboose/caboose
|
14
|
-
*= require
|
13
|
+
*= require application
|
15
14
|
*/
|
@@ -4,7 +4,8 @@ body {
|
|
4
4
|
}
|
5
5
|
|
6
6
|
#wrapper {
|
7
|
-
width: 960px;
|
7
|
+
width: 960px;
|
8
|
+
position: relative;
|
8
9
|
}
|
9
10
|
|
10
11
|
.page_links {
|
@@ -41,11 +42,22 @@ body {
|
|
41
42
|
text-decoration: none;
|
42
43
|
}
|
43
44
|
|
44
|
-
#
|
45
|
+
#caboose_white {
|
46
|
+
z-index: 99;
|
47
|
+
}
|
48
|
+
|
49
|
+
#caboose_station_wrapper {
|
45
50
|
display: none;
|
46
51
|
position: absolute;
|
47
52
|
top: 0;
|
48
53
|
right: 0;
|
54
|
+
z-index: 100;
|
55
|
+
width: 210px;
|
56
|
+
height: 100%;
|
57
|
+
overflow: hidden;
|
58
|
+
}
|
59
|
+
|
60
|
+
#caboose_station {
|
49
61
|
width: 208px;
|
50
62
|
height: 100%;
|
51
63
|
background: #e1e1e1;
|
@@ -172,8 +184,9 @@ body {
|
|
172
184
|
#caboose_station ul.admin li#nav_item_pages a.top_level:active { background-position: -424px -275px; }
|
173
185
|
#caboose_station ul.admin li#nav_item_settings a.top_level:active { background-position: -424px -328px; }
|
174
186
|
|
175
|
-
#
|
176
|
-
#
|
187
|
+
#caboose_station_wrapper.state_min a.close,
|
188
|
+
#caboose_station_wrapper.state_left a.close,
|
189
|
+
#caboose_station_wrapper.state_right a.close {
|
177
190
|
display: block;
|
178
191
|
background-image: url('/assets/caboose/caboose_nav.png');
|
179
192
|
background-repeat: no-repeat;
|
@@ -187,9 +200,12 @@ body {
|
|
187
200
|
overflow: hidden;
|
188
201
|
}
|
189
202
|
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
203
|
+
#caboose_station_wrapper.state_left a.close { background-position: 0px -422px; }
|
204
|
+
#caboose_station_wrapper.state_right a.close { background-position: 0px -380px; }
|
205
|
+
#caboose_station_wrapper.state_min a.close { background-position: 0px -380px; }
|
206
|
+
#caboose_station_wrapper.state_left a.close:hover { background-position: -212px -422px; }
|
207
|
+
#caboose_station_wrapper.state_right a.close:hover { background-position: -212px -380px; }
|
208
|
+
#caboose_station_wrapper.state_min a.close:hover { background-position: -212px -380px; }
|
209
|
+
#caboose_station_wrapper.state_left a.close:active { background-position: -424px -422px; }
|
210
|
+
#caboose_station_wrapper.state_right a.close:active { background-position: -424px -380px; }
|
211
|
+
#caboose_station_wrapper.state_min a.close:active { background-position: -424px -380px; }
|
@@ -15,7 +15,8 @@ elsif (initial_state == 'right')
|
|
15
15
|
end
|
16
16
|
|
17
17
|
%>
|
18
|
-
<div id='
|
18
|
+
<div id='caboose_station_wrapper' class='state_<%= initial_state %>'<%= raw style %>>
|
19
|
+
<div id='caboose_station'>
|
19
20
|
|
20
21
|
<% if (@user.nil? || @user.id == Caboose::User::LOGGED_OUT_USER_ID) %>
|
21
22
|
<h2>Caboose Station</h2>
|
@@ -48,5 +49,5 @@ end
|
|
48
49
|
</ul>
|
49
50
|
<a href='<%= return_url %>' class='close'>Close</a>
|
50
51
|
<% end %>
|
51
|
-
|
52
52
|
</div>
|
53
|
+
</div>
|
data/bin/caboose
CHANGED
@@ -5,49 +5,63 @@ require 'caboose'
|
|
5
5
|
require 'caboose/engine'
|
6
6
|
require 'caboose/version'
|
7
7
|
require 'caboose/caboose_helper'
|
8
|
+
require 'trollop'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
case action
|
10
|
+
#puts "Usage:"
|
11
|
+
#puts "Create a new caboose app:"
|
12
|
+
#puts " caboose new <app_path>"
|
13
|
+
#puts "Initialize an existing rails app as a new caboose app:"
|
14
|
+
#puts " caboose init [<app_path>]\n\n"
|
15
|
+
#exit
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
global_opts = Trollop::options do
|
18
|
+
banner <<-EOS
|
19
|
+
--------------------------------------------------------------------------------
|
20
|
+
Caboose CMS
|
21
|
+
A content management system built on top of Ruby on Rails.
|
22
|
+
--------------------------------------------------------------------------------
|
23
|
+
Usage:
|
24
|
+
caboose new <path>
|
25
|
+
caboose init [--force] [<path>]
|
26
|
+
--------------------------------------------------------------------------------
|
27
|
+
EOS
|
28
|
+
version "Caboose CMS Version #{Caboose::VERSION}\n\n"
|
29
|
+
stop_on ['version', 'new', 'init']
|
30
|
+
end
|
21
31
|
|
22
|
-
|
23
|
-
|
24
|
-
puts "Create a new caboose app:"
|
25
|
-
puts " caboose new <app_path>"
|
26
|
-
puts "Initialize an existing rails app as a new caboose app:"
|
27
|
-
puts " caboose init [<app_path>]\n\n"
|
28
|
-
exit
|
32
|
+
cmd = ARGV.shift
|
33
|
+
case cmd
|
29
34
|
|
30
35
|
when 'new'
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
path = ARGV.shift
|
38
|
+
if (path.nil?)
|
39
|
+
puts "Error: path for new app is required.\n\n"
|
40
|
+
global_opts.help
|
34
41
|
exit
|
35
42
|
end
|
43
|
+
|
36
44
|
puts "Creating the new rails app..."
|
37
45
|
`rails new #{path} -d=mysql`
|
46
|
+
helper = CabooseHelper.new(path)
|
38
47
|
helper.init_all
|
39
48
|
|
40
49
|
when 'init'
|
41
50
|
|
42
|
-
|
51
|
+
opts = Trollop::options do
|
52
|
+
opt :force, 'Force re-installation of all caboose files.', :default => false
|
53
|
+
end
|
54
|
+
|
55
|
+
path = ARGV.shift
|
56
|
+
path = Dir.pwd if path.nil?
|
57
|
+
is_rails_app = File.exists?(File.join(path, 'config', 'environment.rb'))
|
43
58
|
if (!is_rails_app)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
puts "Error: The supplied path (#{path}) doesn't seem to be a rails app.\n\n"
|
48
|
-
end
|
49
|
-
exit
|
59
|
+
puts "Error: Not a rails app.\n\n"
|
60
|
+
global_opts.help
|
61
|
+
exit
|
50
62
|
end
|
63
|
+
|
64
|
+
helper = CabooseHelper.new(path, opts.force)
|
51
65
|
helper.init_all
|
52
66
|
|
53
67
|
else
|
@@ -1,8 +1,9 @@
|
|
1
1
|
|
2
2
|
class CabooseHelper
|
3
3
|
|
4
|
-
def initialize(app_path)
|
4
|
+
def initialize(app_path, force = false)
|
5
5
|
@app_path = app_path
|
6
|
+
@force = force
|
6
7
|
end
|
7
8
|
|
8
9
|
def init_all
|
@@ -21,7 +22,7 @@ class CabooseHelper
|
|
21
22
|
filename = File.join(@app_path, filename)
|
22
23
|
copy_from = File.join(gem_root,'lib','sample_files', Pathname.new(filename).basename)
|
23
24
|
|
24
|
-
if (!File.exists?(filename))
|
25
|
+
if (!File.exists?(filename) || @force)
|
25
26
|
FileUtils.cp(copy_from, filename)
|
26
27
|
end
|
27
28
|
end
|
@@ -30,7 +31,8 @@ class CabooseHelper
|
|
30
31
|
def init_gem
|
31
32
|
puts "Adding the caboose gem to the Gemfile... "
|
32
33
|
filename = File.join(@app_path,'Gemfile')
|
33
|
-
return if !File.exists?(filename)
|
34
|
+
return if !File.exists?(filename)
|
35
|
+
return if !@force
|
34
36
|
|
35
37
|
file = File.open(filename, 'rb')
|
36
38
|
str = file.read
|
@@ -78,14 +80,14 @@ class CabooseHelper
|
|
78
80
|
puts "Adding the caboose initializer file..."
|
79
81
|
|
80
82
|
filename = File.join(@app_path,'config','initializers','caboose.rb')
|
81
|
-
return if File.exists?(filename)
|
83
|
+
return if File.exists?(filename) && !@force
|
82
84
|
|
83
85
|
Caboose::salt = Digest::SHA1.hexdigest(DateTime.now.to_s)
|
84
86
|
str = ""
|
85
87
|
str << "# Salt to ensure passwords are encrypted securely\n"
|
86
88
|
str << "Caboose::salt = '#{Caboose::salt}'\n\n"
|
87
89
|
str << "# Where page asset files will be uploaded\n"
|
88
|
-
str << "Caboose::assets_path =
|
90
|
+
str << "Caboose::assets_path = Rails.root.join('app', 'assets', 'caboose')\n\n"
|
89
91
|
str << "# Register any caboose plugins\n"
|
90
92
|
str << "#Caboose::plugins + ['MyCaboosePlugin']\n\n"
|
91
93
|
|
@@ -98,6 +100,7 @@ class CabooseHelper
|
|
98
100
|
|
99
101
|
filename = File.join(@app_path,'config','routes.rb')
|
100
102
|
return if !File.exists?(filename)
|
103
|
+
return if !@force
|
101
104
|
|
102
105
|
str = ""
|
103
106
|
str << "\t# Catch everything with caboose\n"
|
@@ -115,14 +118,6 @@ class CabooseHelper
|
|
115
118
|
end
|
116
119
|
|
117
120
|
def init_assets
|
118
|
-
puts "Adding the javascript files..."
|
119
|
-
init_file('app/assets/javascripts/caboose_before.js')
|
120
|
-
init_file('app/assets/javascripts/caboose_after.js')
|
121
|
-
|
122
|
-
puts "Adding the stylesheet files..."
|
123
|
-
init_file('app/assets/stylesheets/caboose_before.css')
|
124
|
-
init_file('app/assets/stylesheets/caboose_after.css')
|
125
|
-
|
126
121
|
puts "Adding the layout files..."
|
127
122
|
init_file('app/views/layouts/layout_default.html.erb')
|
128
123
|
end
|
@@ -146,174 +141,4 @@ class CabooseHelper
|
|
146
141
|
str = lines.join("\n")
|
147
142
|
File.open(File.join(@app_path,'config','initializers','session_store.rb'), 'w') {|file| file.write(str) }
|
148
143
|
end
|
149
|
-
|
150
|
-
def init_schema
|
151
|
-
drop_tables
|
152
|
-
create_tables
|
153
|
-
end
|
154
|
-
|
155
|
-
def drop_tables
|
156
|
-
puts "Dropping any existing caboose tables..."
|
157
|
-
c = ActiveRecord::Base.connection
|
158
|
-
c.drop_table :users if c.table_exists?('users')
|
159
|
-
c.drop_table :roles if c.table_exists?('roles')
|
160
|
-
c.drop_table :permissions if c.table_exists?('permissions')
|
161
|
-
c.drop_table :roles_users if c.table_exists?('roles_users')
|
162
|
-
c.drop_table :permissions_roles if c.table_exists?('permissions_roles')
|
163
|
-
c.drop_table :assets if c.table_exists?('assets')
|
164
|
-
c.drop_table :pages if c.table_exists?('pages')
|
165
|
-
c.drop_table :page_permissions if c.table_exists?('page_permissions')
|
166
|
-
c.drop_table :sessions if c.table_exists?('sessions')
|
167
|
-
c.drop_table :settings if c.table_exists?('settings')
|
168
|
-
end
|
169
|
-
|
170
|
-
def create_tables
|
171
|
-
puts "Creating required caboose tables..."
|
172
|
-
|
173
|
-
c = ActiveRecord::Base.connection
|
174
|
-
|
175
|
-
# User/Role/Permissions
|
176
|
-
c.create_table :users do |t|
|
177
|
-
t.string :first_name
|
178
|
-
t.string :last_name
|
179
|
-
t.string :username
|
180
|
-
t.string :email
|
181
|
-
t.string :password
|
182
|
-
t.string :password_reset_id
|
183
|
-
t.datetime :password_reset_sent
|
184
|
-
t.string :token
|
185
|
-
end
|
186
|
-
c.create_table :roles do |t|
|
187
|
-
t.integer :parent_id
|
188
|
-
t.string :name
|
189
|
-
t.string :description
|
190
|
-
end
|
191
|
-
c.create_table :permissions do |t|
|
192
|
-
t.string :resource
|
193
|
-
t.string :action
|
194
|
-
end
|
195
|
-
|
196
|
-
# Role membership
|
197
|
-
c.create_table :roles_users do |t|
|
198
|
-
t.references :role
|
199
|
-
t.references :user
|
200
|
-
end
|
201
|
-
c.add_index :roles_users, :role_id
|
202
|
-
c.add_index :roles_users, :user_id
|
203
|
-
|
204
|
-
# Role permissions
|
205
|
-
c.create_table :permissions_roles do |t|
|
206
|
-
t.references :role
|
207
|
-
t.references :permission
|
208
|
-
end
|
209
|
-
c.add_index :permissions_roles, :role_id
|
210
|
-
c.add_index :permissions_roles, :permission_id
|
211
|
-
|
212
|
-
# Pages and Assets
|
213
|
-
c.create_table :assets do |t|
|
214
|
-
t.references :page
|
215
|
-
t.references :user
|
216
|
-
t.datetime :date_uploaded
|
217
|
-
t.string :name
|
218
|
-
t.string :filename
|
219
|
-
t.string :description
|
220
|
-
t.string :extension
|
221
|
-
end
|
222
|
-
c.create_table :pages do |t|
|
223
|
-
t.integer :parent_id
|
224
|
-
t.string :title
|
225
|
-
t.string :menu_title
|
226
|
-
t.text :content
|
227
|
-
t.string :slug
|
228
|
-
t.string :alias
|
229
|
-
t.string :uri
|
230
|
-
t.string :redirect_url
|
231
|
-
t.boolean :hide, :default => false
|
232
|
-
t.integer :content_format, :default => Caboose::Page::CONTENT_FORMAT_HTML
|
233
|
-
t.text :custom_css
|
234
|
-
t.text :custom_js
|
235
|
-
t.string :layout
|
236
|
-
t.integer :sort_order, :default => 0
|
237
|
-
t.boolean :custom_sort_children, :default => false
|
238
|
-
t.string :seo_title, :limit => 70
|
239
|
-
t.string :meta_description, :limit => 156
|
240
|
-
t.string :meta_robots, :default => 'index, follow' # Multi-select options: none, noindex, nofollow, nosnippet, noodp, noarchive
|
241
|
-
t.string :canonical_url
|
242
|
-
t.string :fb_description, :limit => 156
|
243
|
-
t.string :gp_description, :limit => 156
|
244
|
-
end
|
245
|
-
c.create_table :page_permissions do |t|
|
246
|
-
t.references :role
|
247
|
-
t.references :page
|
248
|
-
t.string :action
|
249
|
-
end
|
250
|
-
c.create_table :sessions do |t|
|
251
|
-
t.string :session_id, :null => false
|
252
|
-
t.text :data
|
253
|
-
t.timestamps
|
254
|
-
end
|
255
|
-
c.add_index :sessions, :session_id
|
256
|
-
c.add_index :sessions, :updated_at
|
257
|
-
c.change_column :sessions, :created_at, :datetime, :null => true
|
258
|
-
c.change_column :sessions, :updated_at, :datetime, :null => true
|
259
|
-
c.create_table :settings do |t|
|
260
|
-
t.string :name
|
261
|
-
t.text :value
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
def init_data
|
267
|
-
puts "Loading data into caboose tables..."
|
268
|
-
|
269
|
-
admin_user = Caboose::User.create(first_name: 'Admin', last_name: 'User', username: 'admin', email: 'william@nine.is')
|
270
|
-
admin_user.password = Digest::SHA1.hexdigest(Caboose::salt + 'caboose')
|
271
|
-
admin_user.save
|
272
|
-
|
273
|
-
admin_role = Caboose::Role.create(parent_id: -1, name: 'Admin')
|
274
|
-
elo_role = Caboose::Role.create(parent_id: -1, name: 'Everyone Logged Out')
|
275
|
-
eli_role = Caboose::Role.create(parent_id: elo_role.id, name: 'Everyone Logged In')
|
276
|
-
|
277
|
-
elo_user = Caboose::User.create(first_name: 'John', last_name: 'Doe', username: 'elo', email: 'william@nine.is')
|
278
|
-
|
279
|
-
admin_perm = Caboose::Permission.create(resource: 'all', action: 'all')
|
280
|
-
Caboose::Permission.create(resource: 'users' , action: 'view')
|
281
|
-
Caboose::Permission.create(resource: 'users' , action: 'edit')
|
282
|
-
Caboose::Permission.create(resource: 'users' , action: 'delete')
|
283
|
-
Caboose::Permission.create(resource: 'users' , action: 'add')
|
284
|
-
Caboose::Permission.create(resource: 'roles' , action: 'view')
|
285
|
-
Caboose::Permission.create(resource: 'roles' , action: 'edit')
|
286
|
-
Caboose::Permission.create(resource: 'roles' , action: 'delete')
|
287
|
-
Caboose::Permission.create(resource: 'roles' , action: 'add')
|
288
|
-
Caboose::Permission.create(resource: 'permissions' , action: 'view')
|
289
|
-
Caboose::Permission.create(resource: 'permissions' , action: 'edit')
|
290
|
-
Caboose::Permission.create(resource: 'permissions' , action: 'delete')
|
291
|
-
Caboose::Permission.create(resource: 'permissions' , action: 'add')
|
292
|
-
|
293
|
-
# Add the admin user to the admin role
|
294
|
-
admin_user.roles.push(admin_role)
|
295
|
-
admin_user.save
|
296
|
-
|
297
|
-
# Add the elo to the elo role
|
298
|
-
elo_user.roles.push(elo_role)
|
299
|
-
elo_user.save
|
300
|
-
|
301
|
-
# Add the all/all permission to the admin role
|
302
|
-
admin_role.permissions.push(admin_perm)
|
303
|
-
admin_role.save
|
304
|
-
|
305
|
-
# Create the home page
|
306
|
-
home_page = Caboose::Page.create(title: 'Home' , parent_id: -1, hide: 0, layout: 'home' , uri: '')
|
307
|
-
admin_page = Caboose::Page.create(title: 'Admin' , parent_id: home_page.id, hide: 0, layout: 'admin', alias: 'admin', slug: 'admin', uri: 'admin')
|
308
|
-
login_page = Caboose::Page.create(title: 'Login' , parent_id: home_page.id, hide: 0, layout: 'login', alias: 'login', slug: 'login', uri: 'login')
|
309
|
-
Caboose::PagePermission.create(role_id: elo_role.id, page_id: home_page.id, action: 'view')
|
310
|
-
Caboose::PagePermission.create(role_id: elo_role.id, page_id: login_page.id, action: 'view')
|
311
|
-
|
312
|
-
# Create the required settings
|
313
|
-
Caboose::Setting.create(name: 'version' , value: Caboose::VERSION)
|
314
|
-
Caboose::Setting.create(name: 'site_name' , value: 'New Caboose Site')
|
315
|
-
Caboose::Setting.create(name: 'site_url' , value: 'www.mycaboosesite.com')
|
316
|
-
Caboose::Setting.create(name: 'admin_email' , value: 'william@nine.is')
|
317
|
-
|
318
|
-
end
|
319
144
|
end
|
data/lib/caboose/version.rb
CHANGED
data/lib/tasks/caboose.rake
CHANGED
@@ -14,6 +14,8 @@ namespace :caboose do
|
|
14
14
|
task :create_tables => :environment do create_tables end
|
15
15
|
desc "Loads data into caboose tables"
|
16
16
|
task :load_data => :environment do load_data end
|
17
|
+
desc "Resets the admin password to 'caboose'"
|
18
|
+
task :reset_admin_pass => :environment do reset_admin_pass end
|
17
19
|
|
18
20
|
#=============================================================================
|
19
21
|
|
@@ -128,7 +130,7 @@ namespace :caboose do
|
|
128
130
|
|
129
131
|
end
|
130
132
|
|
131
|
-
def
|
133
|
+
def load_data
|
132
134
|
puts "Loading data into caboose tables..."
|
133
135
|
|
134
136
|
admin_user = Caboose::User.create(first_name: 'Admin', last_name: 'User', username: 'admin', email: 'william@nine.is')
|
@@ -181,4 +183,10 @@ namespace :caboose do
|
|
181
183
|
Caboose::Setting.create(name: 'admin_email' , value: 'william@nine.is')
|
182
184
|
|
183
185
|
end
|
186
|
+
|
187
|
+
def reset_admin_pass
|
188
|
+
admin_user = Caboose::User.where(username: 'admin').first
|
189
|
+
admin_user.password = Digest::SHA1.hexdigest(Caboose::salt + 'caboose')
|
190
|
+
admin_user.save
|
191
|
+
end
|
184
192
|
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.1.
|
4
|
+
version: 0.1.78
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -123,6 +123,22 @@ dependencies:
|
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: trollop
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
126
142
|
description: CMS built on rails with love.
|
127
143
|
email:
|
128
144
|
- william@nine.is
|
@@ -207,12 +223,6 @@ files:
|
|
207
223
|
- lib/caboose/engine.rb
|
208
224
|
- lib/caboose/version.rb
|
209
225
|
- lib/caboose.rb
|
210
|
-
- lib/sample_files/caboose.rb
|
211
|
-
- lib/sample_files/caboose_after.css
|
212
|
-
- lib/sample_files/caboose_after.js
|
213
|
-
- lib/sample_files/caboose_before.css
|
214
|
-
- lib/sample_files/caboose_before.js
|
215
|
-
- lib/sample_files/caboose_station.html.erb
|
216
226
|
- lib/sample_files/layout_default.html.erb
|
217
227
|
- lib/sample_files/tinymce.yml
|
218
228
|
- lib/tasks/caboose.rake
|
data/lib/sample_files/caboose.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Caboose CMS Settings
|
3
|
-
#
|
4
|
-
|
5
|
-
# Salt to ensure passwords are encrypted securely
|
6
|
-
Caboose::salt = 'CHANGE THIS TO A UNIQUE STRING!!!'
|
7
|
-
|
8
|
-
# Where page asset files will be uploaded
|
9
|
-
Caboose::assets_path = Rails.root.join('app', 'assets', 'caboose')
|
10
|
-
|
11
|
-
# Register any caboose plugins
|
12
|
-
#Caboose::plugins + ['MyCaboosePlugin']
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
<div id='caboose_station'>
|
3
|
-
<h2>Station</h2>
|
4
|
-
<ul>
|
5
|
-
<li><%= link_to 'My Account', "/users/#{@user.id}/edit" %></li>
|
6
|
-
<li><%= link_to 'Logout', "/logout" %></li>
|
7
|
-
<% if (@user.is_allowed('admin', 'view')) %>
|
8
|
-
<li><li><%= link_to 'Admin', "/admin" %></li></li>
|
9
|
-
<% end %>
|
10
|
-
<%
|
11
|
-
uru = session['use_redirect_urls'].nil? ? true : session['use_redirect_urls']
|
12
|
-
%>
|
13
|
-
<li><a href="javascript:caboose_set_redirect_url(<%= uru ? '0' : '1' %>, this);"><%= uru ? 'Disable' : 'Enable' %> Redirect Urls</a></li>
|
14
|
-
<% if (!@page_tasks.nil?) %>
|
15
|
-
<% @page_tasks.each do |href, task| %>
|
16
|
-
<li><%= link_to task, href %></li>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
</ul>
|