radiant 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +1 -1
- data/CONTRIBUTORS +6 -0
- data/app/controllers/application.rb +1 -0
- data/app/helpers/admin/page_helper.rb +12 -1
- data/app/helpers/application_helper.rb +4 -0
- data/app/models/page_context.rb +1 -1
- data/app/models/response_cache.rb +2 -2
- data/app/views/admin/layout/index.rhtml +15 -15
- data/app/views/admin/layout/new.rhtml +13 -13
- data/app/views/admin/layout/remove.rhtml +9 -9
- data/app/views/admin/page/_node.rhtml +13 -14
- data/app/views/admin/page/_part.rhtml +8 -8
- data/app/views/admin/page/index.rhtml +44 -17
- data/app/views/admin/page/remove.rhtml +3 -3
- data/app/views/admin/snippet/index.rhtml +15 -15
- data/app/views/admin/snippet/new.rhtml +14 -14
- data/app/views/admin/snippet/remove.rhtml +8 -8
- data/app/views/admin/user/index.rhtml +19 -19
- data/app/views/admin/user/new.rhtml +26 -26
- data/app/views/admin/user/preferences.rhtml +13 -13
- data/app/views/admin/user/remove.rhtml +8 -8
- data/app/views/admin/welcome/login.rhtml +7 -7
- data/app/views/layouts/application.rhtml +50 -50
- data/bin/radiant +347 -244
- data/config/environment.rb +1 -1
- data/db/migrate/001_create_radiant_tables.rb +2 -0
- data/db/migrate/002_insert_initial_data.rb +12 -5
- data/lib/console_utils.rb +167 -0
- data/lib/radiant.rb +15 -2
- data/lib/tasks/release.rake +10 -6
- data/public/.htaccess +40 -0
- data/public/images/layout.png +0 -0
- data/public/images/new-layout.png +0 -0
- data/script/version +5 -0
- data/test/fixtures/pages.yml +39 -39
- data/test/functional/admin/page_controller_test.rb +47 -0
- data/test/functional/site_controller_test.rb +6 -0
- data/test/unit/page_context_test.rb +3 -1
- metadata +7 -6
- data/config/locomotive.yml +0 -6
- data/test/fixtures/pages.yml.rej +0 -28
- data/test/unit/page_context_test.rb.rej +0 -26
@@ -5,24 +5,24 @@
|
|
5
5
|
<% end -%>
|
6
6
|
|
7
7
|
<form method="post">
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
<div class="form-area">
|
9
|
+
<p class="title">
|
10
|
+
<label for="snippet_name">Name</label>
|
11
|
+
<%= text_field "snippet", "name", :class => 'textbox', :maxlength => 100 %>
|
12
|
+
</p>
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
<p class="content">
|
15
|
+
<label for="snippet_content">Body</label>
|
16
|
+
<%= text_area "snippet", "content", :class => "textarea", :style => "width: 100%" %></p>
|
17
|
+
<p>
|
18
|
+
<label for="snippet_filter">Filter</label>
|
19
19
|
<%= select_tag "snippet[filter_id]", options_for_select([['none', '']] + TextFilter.find_all.map { |f| f.registered_id }, @snippet.filter_id) %>
|
20
|
-
|
20
|
+
</p>
|
21
21
|
<%= updated_stamp @snippet %>
|
22
22
|
</div>
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
<p class="buttons">
|
24
|
+
<%= save_model_button(@snippet) %> <%= save_model_and_continue_editing_button(@snippet) %> or <%= link_to "Cancel", snippet_index_url %>
|
25
|
+
</p>
|
26
26
|
</form>
|
27
27
|
|
28
28
|
<%= focus 'snippet_name' %>
|
@@ -2,15 +2,15 @@
|
|
2
2
|
<p>Are you sure you want to <strong class="warning">permanently remove</strong> the following snippet?</p>
|
3
3
|
|
4
4
|
<table id="snippets" class="index" cellpadding="0" cellspacing="0" border="0">
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
<tbody>
|
6
|
+
<tr class="node level-1" onmouseover="Element.addClassName(this, 'highlight');" onmouseout="Element.removeClassName(this, 'highlight');">
|
7
|
+
<td class="snippet">
|
8
|
+
<%= @snippet.name %>
|
9
|
+
</td>
|
10
|
+
</tr>
|
11
|
+
</tbody>
|
12
12
|
</table>
|
13
13
|
|
14
14
|
<form method="post">
|
15
|
-
|
15
|
+
<p class="buttons"><%= submit_tag "Delete Snippet", :class => 'button' %> or <%= link_to 'Cancel', snippet_index_url %></p>
|
16
16
|
</form>
|
@@ -1,38 +1,38 @@
|
|
1
1
|
<h1>Users</h1>
|
2
2
|
|
3
3
|
<table id="users" class="index" cellpadding="0" cellspacing="0" border="0">
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th class="user">Name / Login</th>
|
7
|
+
<th class="roles">Roles</th>
|
8
|
+
<th class="modify">Modify</th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
12
|
<% unless @users.empty? -%>
|
13
13
|
<% for user in @users -%>
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
<tr class="node level-1">
|
15
|
+
<td class="user">
|
16
|
+
<%= link_to user.name, user_edit_url(:id => user) %>
|
17
|
+
<small class="login"><%= user.login %></small>
|
18
|
+
</td>
|
19
|
+
<td class="roles">
|
20
|
+
<%=
|
21
21
|
roles = []
|
22
22
|
roles << 'Administrator' if user.admin?
|
23
23
|
roles << 'Developer' if user.developer?
|
24
24
|
roles.join(', ')
|
25
25
|
%>
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
</td>
|
27
|
+
<td class="remove"><%= user.id != session[:user].id ? link_to(image_tag('remove', :alt => 'Remove User'), user_remove_url(:id => user)) : image_tag('remove-disabled', :alt => 'Remove') %></td>
|
28
|
+
</tr>
|
29
29
|
<% end -%>
|
30
30
|
<% else -%>
|
31
31
|
<tr>
|
32
32
|
<td colspan="3" class="note">No Users</td>
|
33
33
|
</tr>
|
34
34
|
<% end -%>
|
35
|
-
|
35
|
+
</tbody>
|
36
36
|
</table>
|
37
37
|
<script type="text/javascript">
|
38
38
|
// <![CDATA[
|
@@ -8,41 +8,41 @@
|
|
8
8
|
<table class="fieldset" cellpadding="0" cellspacing="0" border="0">
|
9
9
|
<tr>
|
10
10
|
<td class="label"><label for="user_name">Name</label></td>
|
11
|
-
|
12
|
-
|
11
|
+
<td class="field"><%= text_field "user", "name", :class => 'textbox', :maxlength => 100 %></td>
|
12
|
+
<td class="help">Required.</td>
|
13
13
|
</tr>
|
14
14
|
<tr>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
<td class="label"><label class="optional" for="user_email">E-mail</label></td>
|
16
|
+
<td class="field"><%= text_field "user", "email", :class => 'textbox', :maxlength => 255 %></td>
|
17
|
+
<td class="help">Optional. Please use a valid e-mail address.</td>
|
18
|
+
</tr>
|
19
19
|
<tr>
|
20
20
|
<td class="label"><label for="user_login">Username</label></td>
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
<td class="field"><%= text_field "user", "login", :class => 'textbox', :maxlength => 40 %></td>
|
22
|
+
<td class="help">At least 3 characters. Must be unique.</td>
|
23
|
+
</tr>
|
24
|
+
<tr>
|
25
|
+
<td class="label"><label for="user_password">Password</label></td>
|
26
|
+
<td class="field"><%= password_field "user", "password", :class => 'textbox', :value => '', :maxlength => 40 %></td>
|
27
|
+
<td class="help" rowspan="2">At least 5 characters. <% unless @user.new_record? %>Leave password blank for it to remain unchanged.<% end %></td>
|
28
|
+
</tr>
|
24
29
|
<tr>
|
25
|
-
|
26
|
-
|
27
|
-
<td class="help" rowspan="2">At least 5 characters. <% unless @user.new_record? %>Leave password blank for it to remain unchanged.<% end %></td>
|
30
|
+
<td class="label"><label for="user_password_confirmation">Confirm Password</label></td>
|
31
|
+
<td class="field"><%= password_field "user", "password_confirmation", :class => 'textbox', :value => '', :maxlength => 40 %></td>
|
28
32
|
</tr>
|
29
33
|
<tr>
|
30
|
-
|
31
|
-
|
34
|
+
<td class="label"><label for="user_admin">Roles</label></td>
|
35
|
+
<td class="field">
|
36
|
+
<span class="checkbox"><%= check_box "user", "admin" %> Administrator</span>
|
37
|
+
<span class="checkbox"><%= check_box "user", "developer" %> Developer</span>
|
38
|
+
</td>
|
39
|
+
<td class="help">Roles restrict user privileges and turn parts of the administrative interface on or off.</td>
|
32
40
|
</tr>
|
33
|
-
|
34
|
-
<td class="label"><label for="user_admin">Roles</label></td>
|
35
|
-
<td class="field">
|
36
|
-
<span class="checkbox"><%= check_box "user", "admin" %> Administrator</span>
|
37
|
-
<span class="checkbox"><%= check_box "user", "developer" %> Developer</span>
|
38
|
-
</td>
|
39
|
-
<td class="help">Roles restrict user privileges and turn parts of the administrative interface on or off.</td>
|
40
|
-
</tr>
|
41
|
-
</table>
|
41
|
+
</table>
|
42
42
|
<%= updated_stamp @user %>
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
<p class="buttons">
|
44
|
+
<%= save_model_button(@user) %> <%= save_model_and_continue_editing_button(@user) %> or <%= link_to "Cancel", user_index_url %>
|
45
|
+
</p>
|
46
46
|
</form>
|
47
47
|
|
48
48
|
<%= focus 'user_name' %>
|
@@ -3,27 +3,27 @@
|
|
3
3
|
<form method="post">
|
4
4
|
<table class="fieldset" cellpadding="0" cellspacing="0" border="0">
|
5
5
|
<tr>
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<td class="label"><label for="user_password">Password</label></td>
|
7
|
+
<td class="field"><%= password_field "user", "password", :class => 'textbox', :value => '', :maxlength => 40 %></td>
|
8
|
+
<td class="help" rowspan="2">At least 5 characters. <% unless @user.new_record? %>Leave password blank for it to remain unchanged.<% end %></td>
|
9
9
|
</tr>
|
10
10
|
<tr>
|
11
|
-
|
12
|
-
|
11
|
+
<td class="label"><label for="user_password_confirmation">Confirm Password</label></td>
|
12
|
+
<td class="field"><%= password_field "user", "password_confirmation", :class => 'textbox', :value => '', :maxlength => 40 %></td>
|
13
13
|
</tr>
|
14
14
|
<tr>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
<td class="label"><label for="user_email">E-mail</label></td>
|
16
|
+
<td class="field"><%= text_field "user", "email", :class => 'textbox', :maxlength => 255 %></td>
|
17
|
+
<td class="help">Optional.</td>
|
18
|
+
</tr>
|
19
19
|
</table>
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
<p class="buttons">
|
21
|
+
<%= submit_tag 'Save Changes' %> or <%= link_to "Cancel", admin_url %>
|
22
|
+
</p>
|
23
23
|
</form>
|
24
24
|
|
25
25
|
<script type="text/javascript">
|
26
26
|
// <![CDATA[
|
27
|
-
|
27
|
+
Field.focus('user_password');
|
28
28
|
// ]]>
|
29
29
|
</script>
|
@@ -2,15 +2,15 @@
|
|
2
2
|
<p>Are you sure you want to <strong class="warning">permanently remove</strong> the following user?</p>
|
3
3
|
|
4
4
|
<table id="users" class="index" cellpadding="0" cellspacing="0" border="0">
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
<tbody>
|
6
|
+
<tr class="node level-1" onmouseover="Element.addClassName(this, 'highlight');" onmouseout="Element.removeClassName(this, 'highlight');">
|
7
|
+
<td class="user">
|
8
|
+
<%= @user.name %>
|
9
|
+
</td>
|
10
|
+
</tr>
|
11
|
+
</tbody>
|
12
12
|
</table>
|
13
13
|
|
14
14
|
<form method="post">
|
15
|
-
|
15
|
+
<p class="buttons"><%= submit_tag "Delete User", :class => 'button' %> or <%= link_to 'Cancel', user_index_url %></p>
|
16
16
|
</form>
|
@@ -38,13 +38,13 @@
|
|
38
38
|
<h1>Please Login</h1>
|
39
39
|
|
40
40
|
<form method="post">
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
<p><label for="user_login">Username</label>
|
42
|
+
<%= text_field "user", "login", :class => 'textbox', :value => '', :maxlength => 40 %></p>
|
43
|
+
<p><label for="user_password">Password</label>
|
44
|
+
<%= password_field "user", "password", :class => 'textbox', :value => '', :maxlength => 40 %></p>
|
45
|
+
<p class="buttons">
|
46
|
+
<%= submit_tag 'Login', :class => 'button' %>
|
47
|
+
</p>
|
48
48
|
</form>
|
49
49
|
</div>
|
50
50
|
|
@@ -1,75 +1,75 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
+
<title><%= @page_title || default_page_title %></title>
|
7
|
+
<%= stylesheet_link_tag 'admin' %>
|
8
|
+
<%= javascript_include_tag 'prototype' %>
|
9
|
+
<%= javascript_include_tag 'string' %>
|
10
|
+
<%= javascript_include_tag 'effects' %>
|
11
|
+
<%= javascript_include_tag 'dragdrop' %>
|
12
|
+
<%= javascript_include_tag 'controls' %>
|
13
|
+
<%= javascript_include_tag 'tabcontrol' %>
|
14
|
+
<%= javascript_include_tag 'ruledtable' %>
|
15
|
+
<!--[if lt IE 7]>
|
16
|
+
<script defer type="text/javascript" src="/javascripts/pngfix.js"></script>
|
17
|
+
<![endif]-->
|
18
18
|
<% if @content_for_page_scripts -%>
|
19
|
-
|
20
|
-
|
19
|
+
<script type="text/javascript">
|
20
|
+
// <![CDATA[
|
21
21
|
<%= @content_for_page_scripts %>
|
22
|
-
|
23
|
-
|
22
|
+
// ]]>
|
23
|
+
</script>
|
24
24
|
<% end -%>
|
25
25
|
<% if @content_for_page_css -%>
|
26
|
-
|
26
|
+
<style type="text/css" media="screen">
|
27
27
|
<%= @content_for_page_css -%>
|
28
|
-
|
28
|
+
</style>
|
29
29
|
<% end -%>
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
</head>
|
31
|
+
<body>
|
32
|
+
<div id="header">
|
33
|
+
<div id="site-title"><%= link_to_unless_current title, admin_url %></div>
|
34
|
+
<div id="site-subtitle"><%= subtitle %></div>
|
35
35
|
<% if logged_in? -%>
|
36
|
-
|
36
|
+
<div id="navigation">
|
37
37
|
<%= links_for_navigation %>
|
38
|
-
|
38
|
+
</div>
|
39
39
|
<% end -%>
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
</div>
|
41
|
+
<hr class="hidden" />
|
42
|
+
<div id="main">
|
43
43
|
<% if flash[:notice] -%>
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
<div id="notice">
|
45
|
+
<p><%= flash[:notice] %></p>
|
46
|
+
</div>
|
47
47
|
<% end -%>
|
48
48
|
<% if flash[:error] -%>
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
<div id="error">
|
50
|
+
<p><%= flash[:error] %></p>
|
51
|
+
</div>
|
52
52
|
<% end -%>
|
53
|
-
|
53
|
+
<div id="content">
|
54
54
|
<%= yield%>
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
<hr class="hidden" />
|
58
|
+
<div id="footer">
|
59
|
+
<p>This site was made with Ruby and is powered by <a href="http://radiantcms.org">Radiant CMS</a> version <%= Radiant::Version %>.</p>
|
60
|
+
<p id="site-links">
|
61
61
|
<% if logged_in? -%>
|
62
62
|
<% if admin? -%>
|
63
|
-
|
63
|
+
<%= nav_link_to 'Users', user_index_url %>
|
64
64
|
<% else -%>
|
65
65
|
<%= nav_link_to 'Preferences', user_preferences_url %>
|
66
66
|
<% end -%>
|
67
67
|
<span class="separator"> | </span>
|
68
|
-
|
69
|
-
|
68
|
+
<%= nav_link_to 'Log Out', logout_url %>
|
69
|
+
<span class="separator"> | </span>
|
70
70
|
<% end -%>
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
<%= link_to image_tag('view-site.gif', :alt => 'View Site', :title => '', :align => 'center'), homepage_url %>
|
72
|
+
</p>
|
73
|
+
</div>
|
74
|
+
</body>
|
75
75
|
</html>
|
data/bin/radiant
CHANGED
@@ -1,305 +1,408 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
autoload 'OptionParser', 'optparse'
|
4
|
-
autoload '
|
5
|
-
autoload '
|
6
|
-
autoload 'Radiant', File.join(File.dirname(__FILE__), "..", "lib", "radiant")
|
4
|
+
autoload 'Radiant', File.join(File.dirname(__FILE__), "..", "lib", "radiant")
|
5
|
+
autoload 'ConsoleUtils', File.join(File.dirname(__FILE__), "..", "lib", "console_utils")
|
7
6
|
|
8
7
|
class RadiantCommandApplication
|
8
|
+
include ConsoleUtils
|
9
|
+
|
9
10
|
def self.run(args = ARGV)
|
10
11
|
new.run(args)
|
11
12
|
end
|
12
13
|
|
13
14
|
def initialize
|
14
|
-
@indent = 0
|
15
|
-
@out = $stdout
|
16
|
-
@in = $stdin
|
17
15
|
@ignore = %w( . .. .svn )
|
18
16
|
@radiant_root = File.expand_path(clean_path(File.join(File.dirname(__FILE__), '..')))
|
19
17
|
end
|
20
18
|
|
21
19
|
def run(args = [])
|
22
20
|
parse_args(args)
|
23
|
-
if @
|
24
|
-
|
25
|
-
puts @opts
|
26
|
-
else
|
27
|
-
announce "Unpacking Radiant #{@type}..." do
|
28
|
-
case @type
|
29
|
-
when :application
|
30
|
-
unpack_radiant_application
|
31
|
-
when :instance
|
32
|
-
unpack_radiant_instance
|
33
|
-
end
|
34
|
-
make_scripts_executable
|
35
|
-
end
|
36
|
-
puts "Done."
|
37
|
-
output_additional_instructions
|
38
|
-
end
|
21
|
+
determine_application_type if [:normal, :upgrade].include?(@mode)
|
22
|
+
send "run_#{@mode}"
|
39
23
|
end
|
40
24
|
|
41
25
|
private
|
42
26
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@type = :instance
|
47
|
-
@overwrite = false
|
48
|
-
@dirname = args.pop unless args.last =~ /^-/
|
49
|
-
@dirname = clean_path(@dirname) unless @dirname.nil?
|
50
|
-
@help = @dirname.nil?
|
51
|
-
|
52
|
-
@opts = OptionParser.new do |opts|
|
53
|
-
opts.banner = "Usage: #{File.basename($0)} [options] path"
|
54
|
-
opts.separator "Create a Radiant application at path."
|
55
|
-
opts.separator ""
|
27
|
+
def parse_args(args)
|
28
|
+
args = args.dup
|
56
29
|
|
57
|
-
|
30
|
+
@overwrite = false
|
31
|
+
@dirname = args.pop unless args.last =~ /^-/
|
32
|
+
@dirname = clean_path(@dirname) unless @dirname.nil?
|
33
|
+
@mode = :normal
|
58
34
|
|
59
|
-
opts.
|
60
|
-
"
|
61
|
-
"
|
62
|
-
|
63
|
-
"'instance' mode, which basically means that the `radiant` command ",
|
64
|
-
"only unpacks the files necessary to run the application and all ",
|
65
|
-
"other files are 'linked' in at run time. Where the files are linked ",
|
66
|
-
"in from depends on whether you run the `radiant` command from a gem ",
|
67
|
-
"or another unpacked Radiant install.\n"
|
68
|
-
) do |type|
|
69
|
-
@type = :application
|
70
|
-
end
|
35
|
+
@opts = OptionParser.new do |opts|
|
36
|
+
opts.banner = "Usage: #{File.basename($0)} [options] PATH"
|
37
|
+
opts.separator "Create a Radiant application at PATH."
|
38
|
+
opts.separator ""
|
71
39
|
|
72
|
-
|
73
|
-
@overwrite = true
|
74
|
-
end
|
40
|
+
opts.separator "Options:\n"
|
75
41
|
|
76
|
-
|
77
|
-
|
42
|
+
opts.on("--upgrade",
|
43
|
+
"Upgrade an existing install to the latest version. It is highly",
|
44
|
+
"recommended that you back up your installation before upgrading.\n") do
|
45
|
+
@mode = :upgrade
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("--unpack",
|
49
|
+
"Completely unpack Radiant and cause it to run in 'application' mode. ",
|
50
|
+
"Without this flag Radiant is unpacked in 'instance' mode, which ",
|
51
|
+
"basically means that the `radiant` command only unpacks the files ",
|
52
|
+
"necessary to run the application and all other files are 'linked' in ",
|
53
|
+
"at run time. Where the files are linked in from depends on whether ",
|
54
|
+
"you run the `radiant` command from a gem or another unpacked ",
|
55
|
+
"Radiant install.\n") do
|
56
|
+
@application_type = :application
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("-f", "--force", "Overwrites and delete files in PATH without prompting.\n") do |type|
|
60
|
+
@overwrite = true
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("--no-backups", "Turn file backups off during an upgrade.\n") do
|
64
|
+
@backups = false
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on("-v", "--version", "Display the Radiant version number for this command.\n") do
|
68
|
+
@mode = :version
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on("--current-version", "Display the Radiant version number for the install at PATH.\n") do
|
72
|
+
@mode = :current_version
|
73
|
+
end
|
74
|
+
|
75
|
+
opts.on("-?", "--help", "Display this message.\n") do
|
76
|
+
@mode = :help
|
77
|
+
end
|
78
78
|
end
|
79
|
-
end
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
begin
|
81
|
+
@opts.parse(args)
|
82
|
+
if @dirname.nil? and [:normal, :upgrade, :current_version].include?(@mode)
|
83
|
+
puts 'Invalid path.'
|
84
|
+
@mode = :help
|
85
|
+
end
|
86
|
+
rescue OptionParser::ParseError => e
|
87
|
+
puts e.message.capitalize
|
88
|
+
@mode = :help
|
89
|
+
end
|
86
90
|
end
|
87
|
-
end
|
88
91
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
+
def run_normal
|
93
|
+
announce "Unpacking Radiant #{ @application_type }..." do
|
94
|
+
send "unpack_radiant_#{ @application_type }"
|
95
|
+
make_scripts_executable
|
96
|
+
end
|
97
|
+
puts "Done."
|
98
|
+
output_additional_instructions
|
92
99
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
|
101
|
+
def run_upgrade
|
102
|
+
case
|
103
|
+
when current_version.nil?
|
104
|
+
announce_not_installed
|
105
|
+
when current_version == latest_version
|
106
|
+
announce_already_upgraded
|
107
|
+
else
|
108
|
+
announce "Upgrading Radiant to version #{ latest_version }..." do
|
109
|
+
@backups = @overwrite || ask_yes_or_no("Would you like to create backups of files that Radiant replaces", :no) if @backups.nil?
|
110
|
+
send "upgrade_#{ @application_type }_to_0_5_1"
|
111
|
+
change_radiant_gem_version_in_instance_config_to(latest_version) if @application_type == :instance
|
112
|
+
end
|
113
|
+
puts "Done."
|
114
|
+
end
|
101
115
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
config/database.sqlite.yml
|
106
|
-
config/database.postgresql.yml
|
107
|
-
config/environment.rb
|
108
|
-
config/environments/development.rb
|
109
|
-
config/environments/production.rb
|
110
|
-
config/environments/test.rb
|
111
|
-
script/server
|
112
|
-
script/setup_database
|
113
|
-
script/about
|
114
|
-
script/plugin
|
115
|
-
script/process/reaper
|
116
|
-
script/process/spawner
|
117
|
-
script/process/spinner
|
118
|
-
script/runner
|
119
|
-
README
|
120
|
-
CHANGELOG
|
121
|
-
CONTRIBUTORS
|
122
|
-
LICENSE
|
123
|
-
).each do |file|
|
124
|
-
copy_file File.join(@radiant_root, file), File.join(@dirname, file)
|
116
|
+
|
117
|
+
def run_version
|
118
|
+
puts latest_version
|
125
119
|
end
|
126
|
-
|
127
|
-
|
120
|
+
|
121
|
+
def run_current_version
|
122
|
+
if current_version
|
123
|
+
puts current_version
|
124
|
+
else
|
125
|
+
announce_not_installed
|
126
|
+
end
|
128
127
|
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
def make_scripts_executable
|
134
|
-
(
|
135
|
-
Dir[File.join(@dirname, 'script', '**/*')] +
|
136
|
-
Dir[File.join(@dirname, 'public', 'dispatch.*')]
|
137
|
-
).each do |filename|
|
138
|
-
make_executable(filename)
|
128
|
+
|
129
|
+
def run_help
|
130
|
+
puts
|
131
|
+
puts @opts
|
139
132
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
puts
|
148
|
-
puts " 2. Create config/database.yml for your database setup. (There are"
|
149
|
-
puts " several examples in the config directory.)"
|
150
|
-
puts
|
151
|
-
puts " 3. Run the database setup script:"
|
152
|
-
puts
|
153
|
-
puts " % script/setup_database production"
|
154
|
-
puts
|
155
|
-
puts " 4. Start it like a normal Rails application. To test execute:"
|
156
|
-
puts
|
157
|
-
puts " % script/server production"
|
158
|
-
puts
|
159
|
-
puts " And open your Web browser on port 3000 (http://localhost:3000)."
|
160
|
-
puts
|
161
|
-
puts "See the README for more details."
|
162
|
-
end
|
163
|
-
|
164
|
-
def instance_config_filename
|
165
|
-
File.join(@dirname, 'config', 'instance.yml')
|
166
|
-
end
|
167
|
-
|
168
|
-
def create_instance_config
|
169
|
-
text = gem? ? "Gem Version: #{ Radiant::Version }" : "Radiant Root: #{@radiant_root}"
|
170
|
-
create_file instance_config_filename, text
|
171
|
-
end
|
172
|
-
|
173
|
-
def remove_instance_config
|
174
|
-
remove_file instance_config_filename
|
175
|
-
end
|
176
|
-
|
177
|
-
def config_stub_filename(filename)
|
178
|
-
File.join(@dirname, 'config', filename + '.rb')
|
179
|
-
end
|
180
|
-
|
181
|
-
def create_config_stub(filename)
|
182
|
-
make_path File.join(@dirname, 'config', File.dirname(filename))
|
183
|
-
create_file config_stub_filename(filename), %{require File.join(RADIANT_ROOT, "config", "#{filename}") }
|
184
|
-
end
|
185
|
-
|
186
|
-
def remove_config_stub(filename)
|
187
|
-
remove_file config_stub_filename(filename)
|
188
|
-
end
|
189
|
-
|
190
|
-
def announce(text)
|
191
|
-
puts text
|
192
|
-
@indent += 1
|
193
|
-
yield
|
194
|
-
@indent -= 1
|
195
|
-
end
|
196
|
-
|
197
|
-
def copy_files(from, to)
|
198
|
-
make_path(to)
|
199
|
-
Dir.foreach(from) do |file|
|
200
|
-
unless @ignore.include?(file)
|
201
|
-
full_name = File.join(from, file)
|
202
|
-
if File.directory?(full_name)
|
203
|
-
copy_files full_name, File.join(to, file)
|
133
|
+
|
134
|
+
def determine_application_type
|
135
|
+
if @mode == :normal
|
136
|
+
@application_type ||= :instance
|
137
|
+
else
|
138
|
+
if File.exists? instance_config_filename
|
139
|
+
@application_type ||= :instance
|
204
140
|
else
|
205
|
-
|
141
|
+
@application_type ||= :application
|
206
142
|
end
|
207
143
|
end
|
208
144
|
end
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
145
|
+
|
146
|
+
def announce_not_installed
|
147
|
+
puts 'Cannot detect that Radiant is installed in this directory!'
|
148
|
+
end
|
149
|
+
|
150
|
+
def announce_already_upgraded
|
151
|
+
puts "Your Radiant install is already at the latest version (#{ latest_version })."
|
152
|
+
end
|
153
|
+
|
154
|
+
def unpack_radiant_application
|
155
|
+
%w( cache log vendor/plugins ).each do |path|
|
156
|
+
make_path(File.join(@dirname, path))
|
157
|
+
end
|
158
|
+
remove_instance_config
|
159
|
+
remove_config_stub('routes')
|
160
|
+
copy_files @radiant_root, @dirname
|
161
|
+
end
|
217
162
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
163
|
+
def unpack_radiant_instance
|
164
|
+
%w( cache config db log public script vendor/plugins ).each do |path|
|
165
|
+
make_path(File.join(@dirname, path))
|
166
|
+
end
|
167
|
+
%w(
|
168
|
+
CHANGELOG
|
169
|
+
config/boot.rb
|
170
|
+
config/database.mysql.yml
|
171
|
+
config/database.postgresql.yml
|
172
|
+
config/database.sqlite.yml
|
173
|
+
config/environment.rb
|
174
|
+
config/environments/development.rb
|
175
|
+
config/environments/production.rb
|
176
|
+
config/environments/test.rb
|
177
|
+
CONTRIBUTORS
|
178
|
+
LICENSE
|
179
|
+
README
|
180
|
+
script/about
|
181
|
+
script/console
|
182
|
+
script/plugin
|
183
|
+
script/process/reaper
|
184
|
+
script/process/spawner
|
185
|
+
script/process/spinner
|
186
|
+
script/runner
|
187
|
+
script/server
|
188
|
+
script/setup_database
|
189
|
+
script/version
|
190
|
+
).each do |file|
|
191
|
+
copy_file File.join(@radiant_root, file), File.join(@dirname, file)
|
192
|
+
end
|
193
|
+
%w( public ).each do |path|
|
194
|
+
copy_files File.join(@radiant_root, path), File.join(@dirname, path)
|
195
|
+
end
|
196
|
+
create_instance_config
|
197
|
+
create_config_stub('routes')
|
222
198
|
end
|
223
|
-
end
|
224
199
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
200
|
+
def make_scripts_executable
|
201
|
+
(
|
202
|
+
Dir[File.join(@dirname, 'public', 'dispatch.*')] +
|
203
|
+
Dir[File.join(@dirname, 'script', '**/*')]
|
204
|
+
).each do |filename|
|
205
|
+
make_executable(filename)
|
231
206
|
end
|
232
|
-
make_dir path
|
233
207
|
end
|
234
|
-
end
|
235
208
|
|
236
|
-
|
237
|
-
|
238
|
-
|
209
|
+
def output_additional_instructions
|
210
|
+
puts
|
211
|
+
puts "Now, if this is a fresh install do the following:"
|
212
|
+
puts
|
213
|
+
puts " 1. Create a MySQL/PostgreSQL/SQLite database for your Web site."
|
214
|
+
puts
|
215
|
+
puts " 2. Create config/database.yml for your database setup. (There are"
|
216
|
+
puts " several examples in the config directory.)"
|
217
|
+
puts
|
218
|
+
puts " 3. Run the database setup script:"
|
219
|
+
puts
|
220
|
+
puts " % script/setup_database production"
|
221
|
+
puts
|
222
|
+
puts " 4. Start it like a normal Rails application. To test execute:"
|
223
|
+
puts
|
224
|
+
puts " % script/server production"
|
225
|
+
puts
|
226
|
+
puts " And open your Web browser on port 3000 (http://localhost:3000)."
|
227
|
+
puts
|
228
|
+
puts "See the README for additional details."
|
239
229
|
end
|
240
|
-
puts "created #{filename}"
|
241
|
-
end
|
242
230
|
|
243
|
-
|
244
|
-
|
245
|
-
FileUtils.rm file
|
246
|
-
puts "removed #{file}"
|
231
|
+
def instance_config_filename
|
232
|
+
File.join(@dirname, 'config', 'instance.yml')
|
247
233
|
end
|
248
|
-
end
|
249
234
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
235
|
+
def create_instance_config(options = {})
|
236
|
+
version = options.delete(:version) || Radiant::Version
|
237
|
+
text = gem? ? "Gem Version: #{ version }" : "Radiant Root: #{@radiant_root}"
|
238
|
+
create_file instance_config_filename, text, options
|
239
|
+
end
|
254
240
|
|
255
|
-
|
256
|
-
|
257
|
-
|
241
|
+
def remove_instance_config
|
242
|
+
remove_file instance_config_filename, :force => true
|
243
|
+
end
|
258
244
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
end
|
245
|
+
def config_stub_filename(filename)
|
246
|
+
File.join(@dirname, 'config', filename + '.rb')
|
247
|
+
end
|
263
248
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
249
|
+
def create_config_stub(filename)
|
250
|
+
make_path File.join(@dirname, 'config', File.dirname(filename))
|
251
|
+
create_file config_stub_filename(filename), %{require File.join(RADIANT_ROOT, "config", "#{filename}") }
|
252
|
+
end
|
268
253
|
|
269
|
-
|
270
|
-
|
271
|
-
|
254
|
+
def remove_config_stub(filename)
|
255
|
+
remove_file config_stub_filename(filename), :force => true
|
256
|
+
end
|
257
|
+
|
258
|
+
def invalid_option
|
259
|
+
puts "Invalid option."
|
260
|
+
end
|
272
261
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
case gets.strip.downcase
|
278
|
-
when "yes", "y"
|
279
|
-
break true
|
280
|
-
when "no", "n"
|
281
|
-
break false
|
282
|
-
when ""
|
283
|
-
break default == :yes
|
284
|
-
else
|
285
|
-
invalid_option
|
286
|
-
end
|
262
|
+
def gem?
|
263
|
+
parent_dir = File.expand_path(File.join(@radiant_root, '..'))
|
264
|
+
last_part = parent_dir.split(%r{\\|/}).pop
|
265
|
+
last_part.downcase == 'gems'
|
287
266
|
end
|
288
|
-
end
|
289
267
|
|
290
|
-
|
291
|
-
|
292
|
-
|
268
|
+
def current_version
|
269
|
+
@current_version ||= begin
|
270
|
+
version_script = File.join(@dirname, 'script/version')
|
271
|
+
if File.exists?(version_script)
|
272
|
+
version_string = IO.popen(version_script).read.to_s.strip
|
273
|
+
$1 if version_string =~ /Radiant (\d[\d\.]+)/
|
274
|
+
else
|
275
|
+
'0.5.0' if File.directory? File.join(@dirname, 'config')
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
293
279
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
280
|
+
def latest_version
|
281
|
+
Radiant::Version.to_s
|
282
|
+
end
|
283
|
+
|
284
|
+
def file_sub(filename, pattern, substitution)
|
285
|
+
lines = read_file(filename)
|
286
|
+
if lines.sub! pattern, substitution
|
287
|
+
write_file(filename, lines)
|
288
|
+
true
|
289
|
+
else
|
290
|
+
false
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def change_rails_gem_version_in_environment_to(version)
|
295
|
+
filename = File.join(@dirname, 'config/environment.rb')
|
296
|
+
if file_sub(filename, /RAILS_GEM_VERSION\s*=\s*'\d[\.\d]+'/m, "RAILS_GEM_VERSION = '#{version}'")
|
297
|
+
puts "updated Rails version to #{version} in config/environment.rb"
|
298
|
+
else
|
299
|
+
print "> failed to update Rails version to #{version} in config/environment.rb\n#{ indentation }you may need to do this yourself\n"
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
def change_radiant_gem_version_in_instance_config_to(version)
|
304
|
+
filename = File.join(@dirname, 'config/instance.yml')
|
305
|
+
if file_sub(filename, /Gem Version\s*:\s*\d[\.\d]+/m, "Gem Version: #{version}")
|
306
|
+
puts "updated Radiant version to #{version} in config/instance.yml"
|
307
|
+
else
|
308
|
+
print "> failed to update Radiant version to #{version} in config/instance.yml\n#{ indentation }you may need to do this yourself\n"
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def upgrade_files(lines)
|
313
|
+
lines = lines.split("\n").map { |l| l.strip }.reject { |l| l.empty? }
|
314
|
+
lines.each do |line|
|
315
|
+
command, filename = line.split(/\s+/, 2)
|
316
|
+
prompt = !(command =~ /!$/)
|
317
|
+
to = File.join(@dirname, filename)
|
318
|
+
case command
|
319
|
+
when /^(overwrite|create)/
|
320
|
+
command = $1
|
321
|
+
from = File.join(@radiant_root, filename)
|
322
|
+
backup_file(filename) if @backups and File.file?(to) and (@overwrite or ask_yes_or_no("backup #{filename}"))
|
323
|
+
if command == 'overwrite'
|
324
|
+
copy_file from, to, :overwrite => (@overwrite or !prompt)
|
325
|
+
else
|
326
|
+
copy_file from, to
|
327
|
+
end
|
328
|
+
when /^remove/
|
329
|
+
unless prompt
|
330
|
+
remove_file to, :force => true
|
331
|
+
else
|
332
|
+
remove_file to
|
333
|
+
end
|
334
|
+
else
|
335
|
+
raise 'unknown upgrade command'
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
def upgrade_instance_to_0_5_1
|
341
|
+
upgrade_files %{
|
342
|
+
overwrite! CHANGELOG
|
343
|
+
overwrite! CONTRIBUTORS
|
344
|
+
create public/.htaccess
|
345
|
+
create public/images/layout.png
|
346
|
+
overwrite! public/images/new-layout.png
|
347
|
+
create script/console
|
348
|
+
create script/version
|
349
|
+
}
|
350
|
+
make_executable(File.join(@dirname, 'script/version'))
|
351
|
+
change_rails_gem_version_in_environment_to '1.1.5'
|
352
|
+
end
|
353
|
+
|
354
|
+
def upgrade_application_to_0_5_1
|
355
|
+
upgrade_files %{
|
356
|
+
overwrite app/controllers/application.rb
|
357
|
+
overwrite app/helpers/admin/page_helper.rb
|
358
|
+
overwrite app/helpers/application_helper.rb
|
359
|
+
overwrite app/models/page_context.rb
|
360
|
+
overwrite app/models/response_cache.rb
|
361
|
+
overwrite app/views/admin/layout/index.rhtml
|
362
|
+
overwrite app/views/admin/layout/new.rhtml
|
363
|
+
overwrite app/views/admin/layout/remove.rhtml
|
364
|
+
overwrite app/views/admin/page/index.rhtml
|
365
|
+
overwrite app/views/admin/page/remove.rhtml
|
366
|
+
overwrite app/views/admin/page/_node.rhtml
|
367
|
+
overwrite app/views/admin/page/_part.rhtml
|
368
|
+
overwrite app/views/admin/snippet/index.rhtml
|
369
|
+
overwrite app/views/admin/snippet/new.rhtml
|
370
|
+
overwrite app/views/admin/snippet/remove.rhtml
|
371
|
+
overwrite app/views/admin/user/index.rhtml
|
372
|
+
overwrite app/views/admin/user/new.rhtml
|
373
|
+
overwrite app/views/admin/user/preferences.rhtml
|
374
|
+
overwrite app/views/admin/user/remove.rhtml
|
375
|
+
overwrite app/views/admin/welcome/login.rhtml
|
376
|
+
overwrite app/views/layouts/application.rhtml
|
377
|
+
overwrite bin/radiant
|
378
|
+
overwrite! CHANGELOG
|
379
|
+
overwrite! CONTRIBUTORS
|
380
|
+
overwrite db/migrate/001_create_radiant_tables.rb
|
381
|
+
overwrite db/migrate/002_insert_initial_data.rb
|
382
|
+
overwrite db/schema.rb
|
383
|
+
create lib/console_utils.rb
|
384
|
+
overwrite lib/tasks/release.rake
|
385
|
+
overwrite lib/radiant.rb
|
386
|
+
create public/.htaccess
|
387
|
+
create public/images/layout.png
|
388
|
+
overwrite! public/images/new-layout.png
|
389
|
+
create script/console
|
390
|
+
create script/version
|
391
|
+
overwrite test/fixtures/pages.yml
|
392
|
+
remove! test/fixtures/pages.yml.rej
|
393
|
+
overwrite test/functional/admin/page_controller_test.rb
|
394
|
+
overwrite test/functional/site_controller_test.rb
|
395
|
+
overwrite test/unit/page_context_test.rb
|
396
|
+
remove! test/unit/page_context_test.rb.rej
|
397
|
+
}
|
398
|
+
make_executable(File.join(@dirname, 'script/version'))
|
399
|
+
change_rails_gem_version_in_environment_to '1.1.5'
|
400
|
+
end
|
299
401
|
end
|
300
402
|
|
301
403
|
trap('INT') do
|
302
404
|
puts
|
303
405
|
exit
|
304
406
|
end
|
305
|
-
|
407
|
+
|
408
|
+
RadiantCommandApplication.run
|