Index: app/helpers/admin/page_helper.rb
===================================================================
--- app/helpers/admin/page_helper.rb (revision 449)
+++ app/helpers/admin/page_helper.rb (working copy)
@@ -1,7 +1,8 @@
module Admin::PageHelper
+
def render_node(page, locals = {})
locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
- render :partial => 'node', :locals => locals
+ site_map_node :locals => locals
end
def expanded_rows
@@ -22,8 +23,7 @@
def tag_reference(class_name)
returning String.new do |output|
class_name.constantize.tag_descriptions.sort.each do |tag_name, description|
- output << render(:partial => "tag_reference",
- :locals => {:tag_name => tag_name, :description => description})
+ output << editor_tag_reference(:locals => {:tag_name => tag_name, :description => description})
end
end
end
@@ -44,4 +44,42 @@
def homepage
@homepage ||= Page.find_by_parent_id(nil)
end
-end
+
+ def self.included(base)
+ base.send :include, ViewConfig
+ end
+
+ module ViewConfig
+
+ def method_missing(method, *args, &block)
+ method_name = method.to_s
+ if method_name[0...7] == 'editor_'
+ if args[0].is_a? Hash
+ render_editor_partial(method_name.from(7), args[0])
+ else
+ render_editor_partial(method_name.from(7))
+ end
+ elsif method_name[0...9] == 'site_map_'
+ if args[0].is_a? Hash
+ render_site_map_partial(method_name.from(9), args[0])
+ else
+ render_site_map_partial(method_name.from(9))
+ end
+ else
+ super
+ end
+ end
+
+ def render_editor_partial(named, options = {})
+ options.merge!(:partial => 'editor/' + named)
+ render options
+ end
+
+ def render_site_map_partial(named, options = {})
+ options.merge!(:partial => 'site_map/' + named)
+ render options
+ end
+
+ end
+
+end
\ No newline at end of file
Index: app/models/page_part.rb
===================================================================
--- app/models/page_part.rb (revision 449)
+++ app/models/page_part.rb (working copy)
@@ -15,3 +15,48 @@
object_id_attr :filter, TextFilter
end
+
+module PagePart::AssociationExtension
+
+ def [](index)
+ if index.is_a? String
+ self.each do |part|
+ if part.name == index
+ return part
+ end
+ end
+ return nil
+ else
+ super
+ end
+ end
+
+ def update_association(params)
+ original_names = self.map { |part| part.name }
+ submited_part_names = (params[:part] || {}).values.map { |part| part[:name] }
+ names_to_remove = (original_names - submited_part_names)
+
+ submited_part_names.each_with_index do |name, index|
+ v = params[:part].values[index]
+ part = self[name]
+ if part.nil?
+ #create new part
+ new_part = PagePart.new;
+ new_part.attributes = v;
+ self << new_part
+ else
+ #update exisiting part
+ part.attributes = part.attributes.merge( v )
+ end
+ end
+
+ names_to_remove.each { |name| delete( self[name] ) }
+ end
+
+ def save
+ self.each do |part|
+ part.save
+ end
+ end
+
+end
\ No newline at end of file
Index: app/models/page.rb
===================================================================
--- app/models/page.rb (revision 449)
+++ app/models/page.rb (working copy)
@@ -9,7 +9,9 @@
# Associations
acts_as_tree :order => 'virtual DESC, title ASC'
- has_many :parts, :class_name => 'PagePart', :order => 'id', :dependent => :destroy
+ has_many :parts, :class_name => 'PagePart', :order => 'id', :dependent => :destroy,
+ :extend => PagePart::AssociationExtension
+
belongs_to :_layout, :class_name => 'Layout', :foreign_key => 'layout_id'
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by'
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by'
@@ -83,6 +85,31 @@
end
end
+ def update_associations_each
+ Page.reflect_on_all_associations.each do
+ |relation|
+ association = self.send(relation.name)
+ if association.respond_to?( :update_association )
+ yield association
+ end
+ end
+ end
+
+ def update_associations(params)
+ update_associations_each do |association|
+ association.update_association(params)
+ end
+ end
+
+ def save
+ if result = super
+ update_associations_each do |association|
+ association.save
+ end
+ end
+ result
+ end
+
def process(request, response)
@request, @response = request, response
if layout
Index: app/controllers/application.rb
===================================================================
--- app/controllers/application.rb (revision 449)
+++ app/controllers/application.rb (working copy)
@@ -27,7 +27,7 @@
def include_javascript(script)
@javascripts << script
end
-
+
private
def set_current_user
Index: app/controllers/admin/page_controller.rb
===================================================================
--- app/controllers/admin/page_controller.rb (revision 449)
+++ app/controllers/admin/page_controller.rb (working copy)
@@ -1,8 +1,11 @@
-class Admin::PageController < Admin::AbstractModelController
+class Admin::PageController < Admin::AbstractModelController
+
+ include Admin::PageHelper::ViewConfig
+
model_class Page
before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit]
attr_accessor :cache
-
+
def initialize
super
@cache = ResponseCache.instance
@@ -46,14 +49,14 @@
def add_part
part = PagePart.new(params[:part])
- render(:partial => 'part', :object => part, :layout => false)
+ editor_part :object => part, :layout => false
end
def children
- @parent = Page.find(params[:id])
- @level = params[:level].to_i
response.headers['Content-Type'] = 'text/html;charset=utf-8'
- render(:layout => false)
+ site_map_children(:layout => false,
+ :locals => {:level => params[:level].to_i,
+ :parent => Page.find(params[:id])})
end
def tag_reference
@@ -67,7 +70,7 @@
end
private
-
+
def announce_saved(message = nil)
flash[:notice] = message || "Your page has been saved below."
end
@@ -92,27 +95,8 @@
end
def save
- parts = @page.parts
- parts_to_update = {}
- (params[:part]||{}).each {|k,v| parts_to_update[v[:name]] = v }
-
- parts_to_remove = []
- @page.parts.each do |part|
- if(attrs = parts_to_update.delete(part.name))
- part.attributes = part.attributes.merge(attrs)
- else
- parts_to_remove << part
- end
- end
- parts_to_update.values.each do |attrs|
- @page.parts.build(attrs)
- end
- if result = @page.save
- new_parts = @page.parts - parts_to_remove
- new_parts.each { |part| part.save }
- @page.parts = new_parts
- end
- result
+ @page.update_associations(params)
+ @page.save
end
def clear_model_cache
Index: app/views/admin/page/_meta_row.rhtml
===================================================================
--- app/views/admin/page/_meta_row.rhtml (revision 449)
+++ app/views/admin/page/_meta_row.rhtml (working copy)
@@ -1,4 +0,0 @@
-
- |
- <%= send(meta_row[:type], "page", meta_row[:field], *meta_row[:args])%> |
-
\ No newline at end of file
Index: app/views/admin/page/site_map/_page.rhtml
===================================================================
--- app/views/admin/page/site_map/_page.rhtml (revision 0)
+++ app/views/admin/page/site_map/_page.rhtml (revision 0)
@@ -0,0 +1,22 @@
+<%
+expander = children ? image((expanded ? "collapse" : "expand"), :class => "expander", :alt => 'toggle children', :title => '', :align => 'center') : ""
+
+icon_name = page.virtual? ? "virtual-page" : "page"
+icon = image(icon_name, :class => "icon", :alt => 'page-icon', :title => '', :align => 'center')
+
+display_name = page.class.display_name
+page_type = display_name == 'Page' ? '' : %{(#{ display_name })}
+
+spinner = image('spinner.gif', :class => 'busy', :id => "busy-#{page.id}", :alt => "", :title => "", :align => "center", :style => 'display: none;')
+
+title = %{#{ page.title }}
+%>
+
+<% if simple -%>
+ <%= icon %>
+ <%= title %>
+<% else -%>
+ <%= expander %><%= icon %> <%= title %>
+ <%= page_type %>
+ <%= spinner %>
+<% end -%>
\ No newline at end of file
Index: app/views/admin/page/site_map/_table_header.rhtml
===================================================================
--- app/views/admin/page/site_map/_table_header.rhtml (revision 0)
+++ app/views/admin/page/site_map/_table_header.rhtml (revision 0)
@@ -0,0 +1,7 @@
+
+
+ | Page |
+ Status |
+ Modify |
+
+
Index: app/views/admin/page/site_map/_actions.rhtml
===================================================================
--- app/views/admin/page/site_map/_actions.rhtml (revision 0)
+++ app/views/admin/page/site_map/_actions.rhtml (revision 0)
@@ -0,0 +1,5 @@
+<% unless simple -%>
+ <%= page.status.name %> |
+ <%= link_to image('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %> |
+ <%= link_to image('remove', :alt => 'remove page'), page_remove_url(:id => page) %> |
+<% end -%>
\ No newline at end of file
Index: app/views/admin/page/site_map/_node.rhtml
===================================================================
--- app/views/admin/page/site_map/_node.rhtml (revision 0)
+++ app/views/admin/page/site_map/_node.rhtml (revision 0)
@@ -0,0 +1,36 @@
+<%
+count = page.children.count
+children = count > 0
+expanded = expanded_rows.include?(page.id)
+padding_left = (level * 22) + 4
+
+children_class = children ? (expanded ? ' children-visible' : ' children-hidden') : ' no-children'
+virtual_class = page.virtual? ? " virtual": ""
+-%>
+
+ |
+
+
+ <%=site_map_page :locals => {:simple => simple, :page => page, :children => children, :expanded => expanded} %>
+
+
+ |
+ <%=site_map_actions :locals => {:simple => simple, :page => page} %>
+
+
+
+<% if expanded %>
+ <%=site_map_children :locals => {:simple => simple, :parent => page, :level => level} %>
+<% end %>
+
+<%
+ #level = level + 1 -%>
+<%
+#if expanded
+# page.children.each do |child|
+-%>
+ <% # render_node child, :level => level, :simple => simple -%>
+<%
+# end
+#end
+-%>
Index: app/views/admin/page/site_map/_children.rhtml
===================================================================
--- app/views/admin/page/site_map/_children.rhtml (revision 0)
+++ app/views/admin/page/site_map/_children.rhtml (revision 0)
@@ -0,0 +1,4 @@
+<% level = level + 1 -%>
+<% parent.children.each do |child| -%>
+<%= render_node child, :level => level %>
+<% end -%>
\ No newline at end of file
Index: app/views/admin/page/site_map/_clear_cache.rhtml
===================================================================
--- app/views/admin/page/site_map/_clear_cache.rhtml (revision 0)
+++ app/views/admin/page/site_map/_clear_cache.rhtml (revision 0)
@@ -0,0 +1,8 @@
+
Index: app/views/admin/page/editor/_meta_row.rhtml
===================================================================
--- app/views/admin/page/editor/_meta_row.rhtml (revision 0)
+++ app/views/admin/page/editor/_meta_row.rhtml (revision 0)
@@ -0,0 +1,4 @@
+
+ |
+ <%= send(meta_row[:type], "page", meta_row[:field], *meta_row[:args])%> |
+
\ No newline at end of file
Index: app/views/admin/page/editor/_buttons.rhtml
===================================================================
--- app/views/admin/page/editor/_buttons.rhtml (revision 0)
+++ app/views/admin/page/editor/_buttons.rhtml (revision 0)
@@ -0,0 +1,6 @@
+<% @buttons_partials.each do |partial| %>
+ <%= render :partial => partial %>
+<% end %>
+
+ <%= save_model_button(@page) %> <%= save_model_and_continue_editing_button(@page) %> or <%= link_to "Cancel", page_index_url %>
+
Index: app/views/admin/page/editor/_layout_type_status.rhtml
===================================================================
--- app/views/admin/page/editor/_layout_type_status.rhtml (revision 0)
+++ app/views/admin/page/editor/_layout_type_status.rhtml (revision 0)
@@ -0,0 +1,10 @@
+
+
+ <%= select "page", "layout_id", [['', '']] + Layout.find(:all).map { |s| [s.name, s.id] } %>
+
+ <%= select "page", "class_name", [['', 'Page']] + Page.descendants.map { |p| [p.display_name, p.name] }.sort_by { |p| p.first } %>
+
+ <%= select "page", "status_id", Status.find_all.map { |s| [s.name, s.id] } %>
+
+
+<%= updated_stamp @page %>
Index: app/views/admin/page/editor/_tabs_area.rhtml
===================================================================
--- app/views/admin/page/editor/_tabs_area.rhtml (revision 0)
+++ app/views/admin/page/editor/_tabs_area.rhtml (revision 0)
@@ -0,0 +1,26 @@
+
+
+
+ <%= link_to_function image('plus'), 'toggle_add_part_popup()', :title => 'Add Tab' %>
+ <%= link_to_function image('minus'), 'if(confirm(\'Delete the current tab?\')) { tabControl.removeTab(tabControl.selected) }', :title => 'Remove Tab' %>
+
+
+
+ <%= editor_part :collection => @page.parts %>
+
+
+
Index: app/views/admin/page/editor/_part.rhtml
===================================================================
--- app/views/admin/page/editor/_part.rhtml (revision 0)
+++ app/views/admin/page/editor/_part.rhtml (revision 0)
@@ -0,0 +1,18 @@
+<%
+@part = part
+@index = (params[:index] || @index || 1).to_i
+-%>
+
+
+ <%= hidden_field_tag "part[#{@index - 1}][name]", @part.name %>
+
+
+ <%= select_tag "part[#{@index - 1}][filter_id]", options_for_select([['', '']] + TextFilter.descendants.map { |s| s.filter_name }.sort, @part.filter_id) %>
+ Reference: <%= link_to_function "Filter", "load_filter_reference(#{@index - 1})" %> <%= link_to_function 'Available Tags', "load_tag_reference(#{@index-1});" %>
+
+
<%= text_area_tag "part[#{@index - 1}][content]", h(@part.content), :class => "textarea", :style => "width: 100%" %>
+
+
+<%
+@index += 1;
+-%>
\ No newline at end of file
Index: app/views/admin/page/editor/_popups.rhtml
===================================================================
--- app/views/admin/page/editor/_popups.rhtml (revision 0)
+++ app/views/admin/page/editor/_popups.rhtml (revision 0)
@@ -0,0 +1,33 @@
+<% content_for :popups do -%>
+
+
+
+<% end -%>
\ No newline at end of file
Index: app/views/admin/page/editor/_title_fields.rhtml
===================================================================
--- app/views/admin/page/editor/_title_fields.rhtml (revision 0)
+++ app/views/admin/page/editor/_title_fields.rhtml (revision 0)
@@ -0,0 +1,31 @@
+
+
+ <%= text_field "page", "title", :class => 'textbox', :maxlength => 255 %>
+
+
+
+
+ id="more-extended-metadata">More
+ id="less-extended-metadata">Less
+
+
Index: app/views/admin/page/editor/_header.rhtml
===================================================================
--- app/views/admin/page/editor/_header.rhtml (revision 0)
+++ app/views/admin/page/editor/_header.rhtml (revision 0)
@@ -0,0 +1,5 @@
+<% if @page.new_record? -%>
+New Page
+<% else -%>
+Edit Page
+<% end -%>
Index: app/views/admin/page/editor/_javascripts.rhtml
===================================================================
--- app/views/admin/page/editor/_javascripts.rhtml (revision 0)
+++ app/views/admin/page/editor/_javascripts.rhtml (revision 0)
@@ -0,0 +1,103 @@
+<% content_for('page_scripts') do -%>
+ function part_added() {
+ var partNameField = $('part-name-field');
+ var partIndexField = $('part-index-field');
+ var index = parseInt(partIndexField.value);
+ var tab = 'tab-' + index;
+ var caption = partNameField.value;
+ var page = 'page-' + index;
+ tabControl.addTab(tab, caption, page);
+ Element.hide('add-part-popup');
+ Element.hide('busy');
+ partNameField.value = '';
+ partIndexField.value = (index + 1).toString();
+ $('add-part-button').disabled = false;
+ Field.focus(partNameField);
+ tabControl.select(tab);
+ }
+ function part_loading() {
+ $('add-part-button').disabled = true;
+ new Effect.Appear('busy');
+ }
+ function valid_part_name() {
+ var partNameField = $('part-name-field');
+ var name = partNameField.value.downcase().strip();
+ var result = true;
+ if (name == '') {
+ alert('Part name cannot be empty.');
+ return false;
+ }
+ tabControl.tabs.each(function(pair){
+ if (tabControl.tabs[pair.key].caption == name) {
+ result = false;
+ alert('Part name must be unique.');
+ throw $break;
+ }
+ })
+ return result;
+ }
+ function center(element) {
+ var header = $('header')
+ element = $(element);
+ element.style.position = 'absolute';
+ var dim = Element.getDimensions(element);
+ var top = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
+ element.style.top = (top + 200) + 'px';
+ element.style.left = ((header.offsetWidth - dim.width) / 2) + 'px';
+ }
+ function toggle_add_part_popup() {
+ var popup = $('add-part-popup');
+ var partNameField = $('part-name-field');
+ center(popup);
+ Element.toggle(popup);
+ Field.focus(partNameField);
+ }
+ var last_type = "<%= @page.class_name %>";
+ function load_tag_reference(part) {
+ page_type = $F('page_class_name');
+ popup = $('tag-reference-popup');
+ if(last_type != page_type) {
+ url = "<%= tag_reference_url %>";
+ params = "class_name=" + page_type;
+ new Effect.Highlight('tag-reference-link-'+ part);
+ req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true });
+ } else {
+ center(popup);
+ Element.toggle(popup);
+ }
+ return false;
+ }
+ var last_filter = "<%= default_filter_name %>";
+ function load_filter_reference(part) {
+ filter_type = $F("part[" + part + "][filter_id]");
+ popup = $('filter-reference-popup');
+ if(last_filter != filter_type) {
+ url = "<%= filter_reference_url %>";
+ params = "filter_name=" + filter_type;
+ new Effect.Highlight('filter-reference-link-'+ part);
+ req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true });
+ } else {
+ center(popup);
+ Element.toggle(popup);
+ }
+ return false;
+ }
+<% end -%>
+
+<% content_for :page_css do %>
+ #content #extended-metadata .fieldset {
+ margin-left: 0;
+ margin-right: 0;
+ margin-bottom: .5em;
+ padding: 0;
+ }
+ #content #extended-metadata .fieldset td.label {
+ text-align: left;
+ width: 15%;
+ }
+ #content #extended-metadata .fieldset td.field .textbox {
+ width: 90%;
+ }
+<% end %>
+
+<% include_javascript "tag_reference_search" %>
Index: app/views/admin/page/editor/_tag_reference.rhtml
===================================================================
--- app/views/admin/page/editor/_tag_reference.rhtml (revision 0)
+++ app/views/admin/page/editor/_tag_reference.rhtml (revision 0)
@@ -0,0 +1,4 @@
+
+
<r:<%= tag_name %> />
+
<%= description %>
+
\ No newline at end of file
Index: app/views/admin/page/_node.rhtml
===================================================================
--- app/views/admin/page/_node.rhtml (revision 449)
+++ app/views/admin/page/_node.rhtml (working copy)
@@ -1,50 +0,0 @@
-<%
-count = page.children.count
-children = count > 0
-expanded = expanded_rows.include?(page.id)
-padding_left = (level * 22) + 4
-
-children_class = children ? (expanded ? ' children-visible' : ' children-hidden') : ' no-children'
-virtual_class = page.virtual? ? " virtual": ""
-
-expander = children ? image((expanded ? "collapse" : "expand"), :class => "expander", :alt => 'toggle children', :title => '', :align => 'center') : ""
-
-icon_name = page.virtual? ? "virtual-page" : "page"
-icon = image(icon_name, :class => "icon", :alt => 'page-icon', :title => '', :align => 'center')
-
-title = %{#{ page.title }}
-
-display_name = page.class.display_name
-page_type = display_name == 'Page' ? '' : %{(#{ display_name })}
-
-spinner = image('spinner.gif', :class => 'busy', :id => "busy-#{page.id}", :alt => "", :title => "", :align => "center", :style => 'display: none;')
--%>
-
- |
-
-<% if simple -%>
- <%= icon %>
- <%= title %>
-<% else -%>
- <%= expander %><%= icon %> <%= title %>
- <%= page_type %>
- <%= spinner %>
-<% end -%>
-
- |
-<% unless simple -%>
- <%= page.status.name %> |
- <%= link_to image('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %> |
- <%= link_to image('remove', :alt => 'remove page'), page_remove_url(:id => page) %> |
-<% end -%>
-
-<% level = level + 1 -%>
-<%
-if expanded
- page.children.each do |child|
--%>
-<%= render_node child, :level => level, :simple => simple -%>
-<%
- end
-end
--%>
Index: app/views/admin/page/_part.rhtml
===================================================================
--- app/views/admin/page/_part.rhtml (revision 449)
+++ app/views/admin/page/_part.rhtml (working copy)
@@ -1,18 +0,0 @@
-<%
-@part = part
-@index = (params[:index] || @index || 1).to_i
--%>
-
-
- <%= hidden_field_tag "part[#{@index - 1}][name]", @part.name %>
-
-
- <%= select_tag "part[#{@index - 1}][filter_id]", options_for_select([['', '']] + TextFilter.descendants.map { |s| s.filter_name }.sort, @part.filter_id) %>
- Reference: <%= link_to_function "Filter", "load_filter_reference(#{@index - 1})" %> <%= link_to_function 'Available Tags', "load_tag_reference(#{@index-1});" %>
-
-
<%= text_area_tag "part[#{@index - 1}][content]", h(@part.content), :class => "textarea", :style => "width: 100%" %>
-
-
-<%
-@index += 1;
--%>
\ No newline at end of file
Index: app/views/admin/page/edit.rhtml
===================================================================
--- app/views/admin/page/edit.rhtml (revision 449)
+++ app/views/admin/page/edit.rhtml (working copy)
@@ -1,223 +1,21 @@
-<% content_for('page_scripts') do -%>
- function part_added() {
- var partNameField = $('part-name-field');
- var partIndexField = $('part-index-field');
- var index = parseInt(partIndexField.value);
- var tab = 'tab-' + index;
- var caption = partNameField.value;
- var page = 'page-' + index;
- tabControl.addTab(tab, caption, page);
- Element.hide('add-part-popup');
- Element.hide('busy');
- partNameField.value = '';
- partIndexField.value = (index + 1).toString();
- $('add-part-button').disabled = false;
- Field.focus(partNameField);
- tabControl.select(tab);
- }
- function part_loading() {
- $('add-part-button').disabled = true;
- new Effect.Appear('busy');
- }
- function valid_part_name() {
- var partNameField = $('part-name-field');
- var name = partNameField.value.downcase().strip();
- var result = true;
- if (name == '') {
- alert('Part name cannot be empty.');
- return false;
- }
- tabControl.tabs.each(function(pair){
- if (tabControl.tabs[pair.key].caption == name) {
- result = false;
- alert('Part name must be unique.');
- throw $break;
- }
- })
- return result;
- }
- function center(element) {
- var header = $('header')
- element = $(element);
- element.style.position = 'absolute';
- var dim = Element.getDimensions(element);
- var top = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
- element.style.top = (top + 200) + 'px';
- element.style.left = ((header.offsetWidth - dim.width) / 2) + 'px';
- }
- function toggle_add_part_popup() {
- var popup = $('add-part-popup');
- var partNameField = $('part-name-field');
- center(popup);
- Element.toggle(popup);
- Field.focus(partNameField);
- }
- var last_type = "<%= @page.class_name %>";
- function load_tag_reference(part) {
- page_type = $F('page_class_name');
- popup = $('tag-reference-popup');
- if(last_type != page_type) {
- url = "<%= tag_reference_url %>";
- params = "class_name=" + page_type;
- new Effect.Highlight('tag-reference-link-'+ part);
- req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true });
- } else {
- center(popup);
- Element.toggle(popup);
- }
- return false;
- }
- var last_filter = "<%= default_filter_name %>";
- function load_filter_reference(part) {
- filter_type = $F("part[" + part + "][filter_id]");
- popup = $('filter-reference-popup');
- if(last_filter != filter_type) {
- url = "<%= filter_reference_url %>";
- params = "filter_name=" + filter_type;
- new Effect.Highlight('filter-reference-link-'+ part);
- req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true });
- } else {
- center(popup);
- Element.toggle(popup);
- }
- return false;
- }
-<% end -%>
+<%= editor_javascripts %>
-<% content_for :page_css do %>
- #content #extended-metadata .fieldset {
- margin-left: 0;
- margin-right: 0;
- margin-bottom: .5em;
- padding: 0;
- }
- #content #extended-metadata .fieldset td.label {
- text-align: left;
- width: 15%;
- }
- #content #extended-metadata .fieldset td.field .textbox {
- width: 90%;
- }
-<% end %>
+<%= editor_header %>
-<% include_javascript "tag_reference_search" %>
-<% if @page.new_record? -%>
-New Page
-<% else -%>
-Edit Page
-<% end -%>
-
-
-<% content_for :popups do -%>
-
-
-
-<% end -%>
+<%= editor_popups %>
+
<%= focus 'page_title' %>
Index: app/views/admin/page/index.rhtml
===================================================================
--- app/views/admin/page/index.rhtml (revision 449)
+++ app/views/admin/page/index.rhtml (working copy)
@@ -3,16 +3,12 @@
Pages
-
-
- | Page |
- Status |
- Modify |
-
-
+
+ <%=site_map_table_header%>
+
<% if @homepage -%>
-<%= render_node @homepage -%>
+ <%= render_node @homepage -%>
<% else -%>
| No Pages |
@@ -20,16 +16,11 @@
<% end -%>
+
-
+
+<%=site_map_clear_cache%>
\ No newline at end of file
Index: app/views/admin/page/_tag_reference.rhtml
===================================================================
--- app/views/admin/page/_tag_reference.rhtml (revision 449)
+++ app/views/admin/page/_tag_reference.rhtml (working copy)
@@ -1,4 +0,0 @@
-
-
<r:<%= tag_name %> />
-
<%= description %>
-
\ No newline at end of file
Index: app/views/admin/page/children.rhtml
===================================================================
--- app/views/admin/page/children.rhtml (revision 449)
+++ app/views/admin/page/children.rhtml (working copy)
@@ -1,4 +0,0 @@
-<% level = @level + 1 -%>
-<% @parent.children.each do |child| -%>
-<%= render_node child, :expand => 1, :level => level %>
-<% end -%>
\ No newline at end of file
Index: lib/plugins/extension_patches/lib/view_paths_extension.rb
===================================================================
--- lib/plugins/extension_patches/lib/view_paths_extension.rb (revision 449)
+++ lib/plugins/extension_patches/lib/view_paths_extension.rb (working copy)
@@ -9,13 +9,50 @@
alias full_template_path full_template_path_with_paths
}
end
-
+
+ #for example searching for
+ # site_map/_node
+ #
+ #We want to search in order of:
+ #
+ #1. in each extension directory:
+ #
+ # normal rails location
+ #vendor..extensions... site_map/_node
+ # location based on current controller
+ #vendor..extensions... admin/content/site_map/_node
+ # location based on controller inheritance
+ #vendor..extensions... admin/page/site_map/_node
+ #
+ #2. in normal rails app/views:
+ #
+ # normal rails location
+ #site_map/_node
+ # location based on current controller
+ #admin/content/site_map/_node
+ # location based on controller inheritance
+ #admin/page/site_map/_node
+ #admin/abstract_model/site_map/_node (stop looking when we get to here)
def full_template_path_with_paths (template_path, extension)
- view_paths.reverse_each do |path|
+ base_paths_to_check = [@base_path] + view_paths
+
+ base_paths_to_check.reverse_each do |path|
full_path = File.join(path, "#{template_path}.#{extension}")
+
+ logger.debug("looking for:" + template_path + " in " + full_path)
return full_path if File.exists?(full_path)
+
+ controller_class = controller.class
+ while(controller_class != Admin::AbstractModelController and controller_class.respond_to?(:controller_path)) do
+ controller_based_path = File.join(
+ path, controller_class.controller_path , "#{template_path}.#{extension}")
+ logger.debug("looking for:" + template_path + " in " + controller_based_path)
+ return controller_based_path if File.exists?(controller_based_path)
+ controller_class = controller_class.superclass
+ end
end
- full_template_path_without_paths(template_path, extension)
+
+ full_template_path_without_paths(template_path, extension)
end
end
Index: lib/radiant/extension_loader.rb
===================================================================
--- lib/radiant/extension_loader.rb (revision 449)
+++ lib/radiant/extension_loader.rb (working copy)
@@ -78,10 +78,23 @@
end
end
initializer.initialize_routing
+ extensions_loaded
activated_extensions
end
alias :reactivate :activate_extensions
+ def do_after_activate_extensions(&block)
+ @after_load_blocks ||= Array.new;
+ @after_load_blocks << block;
+ end
+
+ def extensions_loaded
+ @after_load_blocks ||= Array.new;
+ @after_load_blocks.each{ |block| block.call }
+ @after_load_blocks = Array.new
+ ActionController::Base.logger.debug "Extensions Loading Completed";
+ end
+
private
def activate(extension)
Index: lib/radiant/extension.rb
===================================================================
--- lib/radiant/extension.rb (revision 449)
+++ lib/radiant/extension.rb (working copy)
@@ -11,6 +11,10 @@
attr_writer :active
+ def logger
+ ActionController::Base.logger;
+ end
+
def active?
@active
end
Index: public/javascripts/sitemap.js
===================================================================
--- public/javascripts/sitemap.js (revision 449)
+++ public/javascripts/sitemap.js (working copy)
@@ -1,3 +1,4 @@
+var expanderURL = function(id, level) { return '/admin/ui/pages/children/' + id + '/' + level; }
var SiteMap = Class.create();
SiteMap.prototype = Object.extend({}, RuledTable.prototype); // Inherit from RuledTable
@@ -131,7 +132,7 @@
var id = this.extractPageId(row).toString();
new Ajax.Updater(
row,
- '/admin/ui/pages/children/' + id + '/' + level,
+ expanderURL(id, level),
{
asynchronous: true,
insertion: Insertion.After,