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.

Files changed (42) hide show
  1. data/CHANGELOG +1 -1
  2. data/CONTRIBUTORS +6 -0
  3. data/app/controllers/application.rb +1 -0
  4. data/app/helpers/admin/page_helper.rb +12 -1
  5. data/app/helpers/application_helper.rb +4 -0
  6. data/app/models/page_context.rb +1 -1
  7. data/app/models/response_cache.rb +2 -2
  8. data/app/views/admin/layout/index.rhtml +15 -15
  9. data/app/views/admin/layout/new.rhtml +13 -13
  10. data/app/views/admin/layout/remove.rhtml +9 -9
  11. data/app/views/admin/page/_node.rhtml +13 -14
  12. data/app/views/admin/page/_part.rhtml +8 -8
  13. data/app/views/admin/page/index.rhtml +44 -17
  14. data/app/views/admin/page/remove.rhtml +3 -3
  15. data/app/views/admin/snippet/index.rhtml +15 -15
  16. data/app/views/admin/snippet/new.rhtml +14 -14
  17. data/app/views/admin/snippet/remove.rhtml +8 -8
  18. data/app/views/admin/user/index.rhtml +19 -19
  19. data/app/views/admin/user/new.rhtml +26 -26
  20. data/app/views/admin/user/preferences.rhtml +13 -13
  21. data/app/views/admin/user/remove.rhtml +8 -8
  22. data/app/views/admin/welcome/login.rhtml +7 -7
  23. data/app/views/layouts/application.rhtml +50 -50
  24. data/bin/radiant +347 -244
  25. data/config/environment.rb +1 -1
  26. data/db/migrate/001_create_radiant_tables.rb +2 -0
  27. data/db/migrate/002_insert_initial_data.rb +12 -5
  28. data/lib/console_utils.rb +167 -0
  29. data/lib/radiant.rb +15 -2
  30. data/lib/tasks/release.rake +10 -6
  31. data/public/.htaccess +40 -0
  32. data/public/images/layout.png +0 -0
  33. data/public/images/new-layout.png +0 -0
  34. data/script/version +5 -0
  35. data/test/fixtures/pages.yml +39 -39
  36. data/test/functional/admin/page_controller_test.rb +47 -0
  37. data/test/functional/site_controller_test.rb +6 -0
  38. data/test/unit/page_context_test.rb +3 -1
  39. metadata +7 -6
  40. data/config/locomotive.yml +0 -6
  41. data/test/fixtures/pages.yml.rej +0 -28
  42. data/test/unit/page_context_test.rb.rej +0 -26
data/CHANGELOG CHANGED
@@ -1 +1 @@
1
- = Change Log
1
+ = Change Log
data/CONTRIBUTORS CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  The following people have submitted changes which have been applied to the core:
4
4
 
5
+ === 0.5.1
6
+ * Daniel Shepherd
7
+ * Paul Smith
8
+ * Bodhi Philpot
9
+
10
+ === 0.5.0
5
11
  * Matt McCray
6
12
  * Paul Smith
7
13
  * Scott Walter
@@ -1,3 +1,4 @@
1
+ require_dependency 'radiant'
1
2
  require_dependency 'login_system'
2
3
 
3
4
  ActionView::Base.field_error_proc = Proc.new do |html, instance|
@@ -1,8 +1,19 @@
1
1
  module Admin::PageHelper
2
2
  def render_node(page, locals = {})
3
- locals.reverse_merge!( :level => 0, :expand => 3, :simple => false ).merge!( :page => page )
3
+ locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
4
4
  render :partial => 'node', :locals => locals
5
5
  end
6
+
7
+ def expanded_rows
8
+ case
9
+ when row_string = (cookies['expanded_rows'] || []).first
10
+ row_string.split(',').map { |x| Integer(x) rescue nil }.compact
11
+ when @homepage
12
+ [@homepage.id]
13
+ else
14
+ []
15
+ end
16
+ end
6
17
 
7
18
  def meta_errors?
8
19
  !!(@page.errors[:slug] or @page.errors[:breadcrumb])
@@ -138,4 +138,8 @@ module ApplicationHelper
138
138
  def toggle_javascript_for(id)
139
139
  "javascript:Element.toggle('#{id}', 'more-#{id}', 'less-#{id}')"
140
140
  end
141
+
142
+ def cookies
143
+ @cookies
144
+ end
141
145
  end
@@ -208,7 +208,7 @@ class PageContext < Radius::Context
208
208
  contextual = boolean_attr['contextual', true]
209
209
  if inherit and contextual
210
210
  part = part_page.part(part_name)
211
- page.behavior.render_snippet(part)
211
+ page.behavior.render_snippet(part) unless part.nil?
212
212
  else
213
213
  part_page.behavior.render_page_part(part_name)
214
214
  end
@@ -22,7 +22,7 @@ class ResponseCache
22
22
  # Options are as follows:
23
23
  # :directory :: the path to the temporary cache directory
24
24
  # :expire_time :: the number of seconds a cached response is considered valid (defaults to 5 min)
25
- # :default_extension :: the extension cached files should use (defaults to '.html')
25
+ # :default_extension :: the extension cached files should use (defaults to '.yml')
26
26
  # :peform_caching :: boolean value that turns caching on or off (defaults to true)
27
27
  # :logger :: the application logging object (defaults to ActionController::Base.logger)
28
28
  #
@@ -109,4 +109,4 @@ class ResponseCache
109
109
  }.to_yaml
110
110
  cache_page(content, path)
111
111
  end
112
- end
112
+ end
@@ -5,29 +5,29 @@
5
5
  edit it or click <code>Remove</code> to delete it.</p>
6
6
 
7
7
  <table id="layouts" class="index" cellpadding="0" cellspacing="0" border="0">
8
- <thead>
9
- <tr>
10
- <th class="layout">Layout</th>
11
- <th class="modify">Modify</th>
12
- </tr>
13
- </thead>
14
- <tbody>
8
+ <thead>
9
+ <tr>
10
+ <th class="layout">Layout</th>
11
+ <th class="modify">Modify</th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
15
  <% unless @layouts.empty? -%>
16
16
  <% for layout in @layouts -%>
17
- <tr class="node level-1">
18
- <td class="layout">
19
- <%= image_tag 'page', :alt => 'layout-icon', :title => '', :align => 'center' %>
20
- <%= link_to layout.name, layout_edit_url(:id => layout) %>
21
- </td>
22
- <td class="remove"><%= link_to image_tag('remove', :alt => 'Remove Layout'), layout_remove_url(:id => layout) %></td>
23
- </tr>
17
+ <tr class="node level-1">
18
+ <td class="layout">
19
+ <%= image_tag 'layout', :alt => 'layout-icon', :title => '', :align => 'center' %>
20
+ <%= link_to layout.name, layout_edit_url(:id => layout) %>
21
+ </td>
22
+ <td class="remove"><%= link_to image_tag('remove', :alt => 'Remove Layout'), layout_remove_url(:id => layout) %></td>
23
+ </tr>
24
24
  <% end -%>
25
25
  <% else -%>
26
26
  <tr>
27
27
  <td colspan="2" class="note">No Layouts</td>
28
28
  </tr>
29
29
  <% end -%>
30
- </tbody>
30
+ </tbody>
31
31
  </table>
32
32
  <script type="text/javascript">
33
33
  // <![CDATA[
@@ -5,12 +5,12 @@
5
5
  <% end -%>
6
6
 
7
7
  <form method="post">
8
- <div class="form-area">
9
- <p class="title">
10
- <label for="layout_name">Name</label>
11
- <%= text_field "layout", "name", :class => 'textbox', :maxlength => 100 %>
12
- </p>
13
- <div id="extended-metadata" class="row"<%= meta_visible(:meta) %>>
8
+ <div class="form-area">
9
+ <p class="title">
10
+ <label for="layout_name">Name</label>
11
+ <%= text_field "layout", "name", :class => 'textbox', :maxlength => 100 %>
12
+ </p>
13
+ <div id="extended-metadata" class="row"<%= meta_visible(:meta) %>>
14
14
  <table class="fieldset" cellpadding="0" cellspacing="0" border="0">
15
15
  <tr>
16
16
  <td><label for="layout_content_type">Content-Type</label></td>
@@ -24,14 +24,14 @@
24
24
  <a id="less-extended-metadata" href="<%= toggle_javascript_for('extended-metadata') %>"<%= meta_visible(:meta_less) %>>Less</a>
25
25
  </small>
26
26
  </p>
27
- <p class="content">
28
- <label for="layout_content">Body</label>
29
- <%= text_area "layout", "content", :class => "textarea", :style => "width: 100%" %></p>
27
+ <p class="content">
28
+ <label for="layout_content">Body</label>
29
+ <%= text_area "layout", "content", :class => "textarea", :style => "width: 100%" %></p>
30
30
  <%= updated_stamp @layout %>
31
- </div>
32
- <p class="buttons">
33
- <%= save_model_button(@layout) %> <%= save_model_and_continue_editing_button(@layout) %> or <%= link_to "Cancel", layout_index_url %>
34
- </p>
31
+ </div>
32
+ <p class="buttons">
33
+ <%= save_model_button(@layout) %> <%= save_model_and_continue_editing_button(@layout) %> or <%= link_to "Cancel", layout_index_url %>
34
+ </p>
35
35
  </form>
36
36
 
37
37
  <%= focus 'layout_name' %>
@@ -2,16 +2,16 @@
2
2
  <p>Are you sure you want to <strong class="warning">permanently remove</strong> the following layout?</p>
3
3
 
4
4
  <table id="site-map" class="index" cellpadding="0" cellspacing="0" border="0">
5
- <tbody>
6
- <tr class="node level-1" onmouseover="Element.addClassName(this, 'highlight');" onmouseout="Element.removeClassName(this, 'highlight');">
7
- <td class="layout">
8
- <%= image_tag 'page', :alt => 'layout-icon', :title => '', :align => 'center' %>
9
- <%= @layout.name %>
10
- </td>
11
- </tr>
12
- </tbody>
5
+ <tbody>
6
+ <tr class="node level-1" onmouseover="Element.addClassName(this, 'highlight');" onmouseout="Element.removeClassName(this, 'highlight');">
7
+ <td class="layout">
8
+ <%= image_tag 'layout', :alt => 'layout-icon', :title => '', :align => 'center' %>
9
+ <%= @layout.name %>
10
+ </td>
11
+ </tr>
12
+ </tbody>
13
13
  </table>
14
14
 
15
15
  <form method="post">
16
- <p class="buttons"><%= submit_tag "Delete Layout", :class => 'button' %> or <%= link_to 'Cancel', layout_index_url %></p>
16
+ <p class="buttons"><%= submit_tag "Delete Layout", :class => 'button' %> or <%= link_to 'Cancel', layout_index_url %></p>
17
17
  </form>
@@ -1,8 +1,7 @@
1
1
  <%
2
2
  count = page.children.count
3
3
  children = count > 0
4
- expand = expand - 1
5
- expanded = expand > 0
4
+ expanded = expanded_rows.include?(page.id)
6
5
  padding_left = (level * 22) + 4
7
6
 
8
7
  children_class = children ? (expanded ? ' children-visible' : ' children-hidden') : ' no-children'
@@ -20,32 +19,32 @@ behavior = behavior_id.empty? ? '' : %{<small class="info">(#{ behavior_id })</s
20
19
 
21
20
  spinner = image_tag("spinner.gif", :class => 'busy', :id => "busy-#{page.id}", :alt => "", :title => "", :align => "center", :style => 'display: none;')
22
21
  -%>
23
- <tr id="page-<%= page.id %>" class="node level-<%= level %><%= children_class %><%= virtual_class %>">
24
- <td class="page" style="padding-left: <%= padding_left %>px">
25
- <span class="w1">
22
+ <tr id="page-<%= page.id %>" class="node level-<%= level %><%= children_class %><%= virtual_class %>">
23
+ <td class="page" style="padding-left: <%= padding_left %>px">
24
+ <span class="w1">
26
25
  <% if simple -%>
27
26
  <%= icon %>
28
27
  <%= title %>
29
28
  <% else -%>
30
29
  <%= expander %><a href="<%= page_edit_url(:id => page) %>"><%= icon %> <%= title %></a>
31
- <%= behavior %>
32
- <%= spinner %>
30
+ <%= behavior %>
31
+ <%= spinner %>
33
32
  <% end -%>
34
33
  </span>
35
- </td>
34
+ </td>
36
35
  <% unless simple -%>
37
- <td class="status <%= page.status.name.downcase %>-status"><%= page.status.name %></td>
38
- <td class="add-child"><%= link_to image_tag('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %></td>
39
- <td class="remove"><%= link_to image_tag('remove', :alt => 'remove page'), page_remove_url(:id => page) %></td>
36
+ <td class="status <%= page.status.name.downcase %>-status"><%= page.status.name %></td>
37
+ <td class="add-child"><%= link_to image_tag('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %></td>
38
+ <td class="remove"><%= link_to image_tag('remove', :alt => 'remove page'), page_remove_url(:id => page) %></td>
40
39
  <% end -%>
41
- </tr>
40
+ </tr>
42
41
  <% level = level + 1 -%>
43
42
  <%
44
43
  if expanded
45
44
  page.children.each do |child|
46
45
  -%>
47
- <%= render_node child, :level => level, :expand => expand, :simple => simple -%>
46
+ <%= render_node child, :level => level, :simple => simple -%>
48
47
  <%
49
48
  end
50
49
  end
51
- -%>
50
+ -%>
@@ -3,14 +3,14 @@
3
3
  @index = (params[:index] || @index || 1).to_i
4
4
  -%>
5
5
  <div class="page" id="page-<%= @index %>">
6
- <div class="part" id="part-<%= @index %>">
7
- <%= hidden_field_tag "part[#{@index - 1}][name]", @part.name %>
8
- <p>
9
- <label for="part[<%= @index - 1 %>}][filter_id]">Filter</label>
10
- <%= select_tag "part[#{@index - 1}][filter_id]", options_for_select([['<none>', '']] + TextFilter.find_all.map { |s| s.registered_id }, @part.filter_id) %>
11
- </p>
12
- <div><%= text_area_tag "part[#{@index - 1}][content]", h(@part.content), :class => "textarea", :style => "width: 100%" %></div>
13
- </div>
6
+ <div class="part" id="part-<%= @index %>">
7
+ <%= hidden_field_tag "part[#{@index - 1}][name]", @part.name %>
8
+ <p>
9
+ <label for="part[<%= @index - 1 %>}][filter_id]">Filter</label>
10
+ <%= select_tag "part[#{@index - 1}][filter_id]", options_for_select([['<none>', '']] + TextFilter.find_all.map { |s| s.registered_id }, @part.filter_id) %>
11
+ </p>
12
+ <div><%= text_area_tag "part[#{@index - 1}][content]", h(@part.content), :class => "textarea", :style => "width: 100%" %></div>
13
+ </div>
14
14
  </div>
15
15
  <%
16
16
  @index += 1;
@@ -2,6 +2,8 @@
2
2
  var SiteMap = Class.create();
3
3
  SiteMap.prototype = Object.extend({}, RuledTable.prototype); // Inherit from RuledTable
4
4
  Object.extend(SiteMap.prototype, {
5
+
6
+ expandedRows: <%= expanded_rows.to_json %>,
5
7
 
6
8
  onRowSetup: function(row) {
7
9
  Event.observe(row, 'click', this.onMouseClickRow.bindAsEventListener(this), false);
@@ -50,7 +52,11 @@
50
52
  expanders.push(image);
51
53
  }.bind(this));
52
54
  return expanders.first();
53
- },
55
+ },
56
+
57
+ saveExpandedCookie: function() {
58
+ document.cookie = "expanded_rows="+this.expandedRows.join(",")+"; path=/admin";
59
+ },
54
60
 
55
61
  hideBranch: function(row, img) {
56
62
  var level = this.extractLevel(row);
@@ -62,6 +68,13 @@
62
68
  }
63
69
  sibling = sibling.nextSibling;
64
70
  }
71
+ var pageId = this.extractPageId(row);
72
+ var newExpanded = [];
73
+ for(i=0; i < this.expandedRows.length; i++)
74
+ if(this.expandedRows[i] != pageId)
75
+ newExpanded.push(this.expandedRows[i]);
76
+ this.expandedRows = newExpanded;
77
+ this.saveExpandedCookie();
65
78
  if (img == null)
66
79
  img = this.getExpanderImageForRow(row);
67
80
  img.src = img.src.replace(/collapse/, 'expand');
@@ -69,17 +82,22 @@
69
82
  Element.addClassName(row, 'children-hidden');
70
83
  },
71
84
 
72
- showBranch: function(row, img) {
85
+ showBranchInternal: function(row, img) {
73
86
  var level = this.extractLevel(row);
74
87
  var sibling = row.nextSibling;
75
88
  var children = false;
89
+ var childOwningSiblings = [];
76
90
  while(sibling != null) {
77
91
  if (this.isRow(sibling)) {
78
92
  var siblingLevel = this.extractLevel(sibling);
79
93
  if (siblingLevel <= level) break;
80
94
  if (siblingLevel == level + 1) {
81
95
  Element.show(sibling);
82
- this.hideBranch(sibling);
96
+ if(sibling.className.match(/children-visible/)) {
97
+ childOwningSiblings.push(sibling);
98
+ } else {
99
+ this.hideBranch(sibling);
100
+ }
83
101
  }
84
102
  children = true;
85
103
  }
@@ -88,12 +106,21 @@
88
106
  if (!children)
89
107
  this.getBranch(row);
90
108
  if (img == null)
91
- img = this.getExpanderImageForRow(row);
109
+ img = this.getExpanderImageForRow(row);
92
110
  img.src = img.src.replace(/expand/, 'collapse');
111
+ for(i=0; i < childOwningSiblings.length; i++) {
112
+ this.showBranch(childOwningSiblings[i], null);
113
+ }
93
114
  Element.removeClassName(row, 'children-hidden');
94
115
  Element.addClassName(row, 'children-visible');
95
116
  },
96
117
 
118
+ showBranch: function(row, img) {
119
+ this.showBranchInternal(row, img);
120
+ this.expandedRows.push(this.extractPageId(row));
121
+ this.saveExpandedCookie();
122
+ },
123
+
97
124
  getBranch: function(row) {
98
125
  var level = this.extractLevel(row).toString();
99
126
  var id = this.extractPageId(row).toString();
@@ -140,22 +167,22 @@
140
167
  <h1>Pages</h1>
141
168
 
142
169
  <table id="site-map" class="index" cellpadding="0" cellspacing="0" border="0">
143
- <thead>
144
- <tr>
145
- <th class="page">Page</th>
146
- <th class="status">Status</th>
147
- <th class="modify" colspan="2">Modify</th>
148
- </tr>
149
- </thead>
150
- <tbody>
170
+ <thead>
171
+ <tr>
172
+ <th class="page">Page</th>
173
+ <th class="status">Status</th>
174
+ <th class="modify" colspan="2">Modify</th>
175
+ </tr>
176
+ </thead>
177
+ <tbody>
151
178
  <% if @homepage -%>
152
179
  <%= render_node @homepage -%>
153
180
  <% else -%>
154
- <tr>
155
- <td colspan="4" class="note">No Pages</td>
156
- </tr>
181
+ <tr>
182
+ <td colspan="4" class="note">No Pages</td>
183
+ </tr>
157
184
  <% end -%>
158
- </tbody>
185
+ </tbody>
159
186
  </table>
160
187
  <script type="text/javascript">
161
188
  // <![CDATA[
@@ -169,4 +196,4 @@
169
196
  <% end -%>
170
197
  <%= image_submit_tag 'clear-page-cache' %>
171
198
  </p>
172
- </form>
199
+ </form>
@@ -4,11 +4,11 @@
4
4
  <p>Are you sure you want to <strong class="warning">permanently remove</strong> the following <%= pages.downcase %>?</p>
5
5
 
6
6
  <table id="site-map" class="index" cellpadding="0" cellspacing="0" border="0">
7
- <tbody>
7
+ <tbody>
8
8
  <%= render_node @page, :simple => true -%>
9
- </tbody>
9
+ </tbody>
10
10
  </table>
11
11
 
12
12
  <form method="post">
13
- <p class="buttons"><%= submit_tag "Delete #{pages}", :class => 'button' %> or <%= link_to 'Cancel', page_index_url %></p>
13
+ <p class="buttons"><%= submit_tag "Delete #{pages}", :class => 'button' %> or <%= link_to 'Cancel', page_index_url %></p>
14
14
  </form>
@@ -3,29 +3,29 @@
3
3
  <p>Snippets are generally small pieces of content which are included in other pages or layouts.</p>
4
4
 
5
5
  <table id="snippets" class="index" cellpadding="0" cellspacing="0" border="0">
6
- <thead>
7
- <tr>
8
- <th class="snippet">Snippet</th>
9
- <th class="modify">Modify</th>
10
- </tr>
11
- </thead>
12
- <tbody>
6
+ <thead>
7
+ <tr>
8
+ <th class="snippet">Snippet</th>
9
+ <th class="modify">Modify</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
13
  <% unless @snippets.empty? -%>
14
14
  <% for snippet in @snippets -%>
15
- <tr class="node level-1">
16
- <td class="snippet">
17
- <%= image_tag "snippet", :class => "icon", :alt => 'snippet-icon', :title => '', :align => 'center' %>
18
- <%= link_to snippet.name, snippet_edit_url(:id => snippet) %></span>
19
- </td>
20
- <td class="remove"><%= link_to image_tag('remove', :alt => 'Remove Snippet'), snippet_remove_url(:id => snippet) %></td>
21
- </tr>
15
+ <tr class="node level-1">
16
+ <td class="snippet">
17
+ <%= image_tag "snippet", :class => "icon", :alt => 'snippet-icon', :title => '', :align => 'center' %>
18
+ <%= link_to snippet.name, snippet_edit_url(:id => snippet) %></span>
19
+ </td>
20
+ <td class="remove"><%= link_to image_tag('remove', :alt => 'Remove Snippet'), snippet_remove_url(:id => snippet) %></td>
21
+ </tr>
22
22
  <% end -%>
23
23
  <% else -%>
24
24
  <tr>
25
25
  <td colspan="2" class="note">No Snippets</td>
26
26
  </tr>
27
27
  <% end -%>
28
- </tbody>
28
+ </tbody>
29
29
  </table>
30
30
  <script type="text/javascript">
31
31
  // <![CDATA[