diff --git a/app/helpers/admin/sites_helper.rb b/app/helpers/admin/sites_helper.rb index 65590f0..5f15081 100644 --- a/app/helpers/admin/sites_helper.rb +++ b/app/helpers/admin/sites_helper.rb @@ -1,6 +1,6 @@ module Admin::SitesHelper def order_links(site) - returning String.new do |output| + String.new.tap do |output| output << link_to(image("move_to_top.png", :alt => "Move to top"), move_to_top_admin_site_path(site), :method => :put) output << link_to(image("move_higher.png", :alt => "Move up"), move_higher_admin_site_path(site), :method => :post) output << link_to(image("move_lower.png", :alt => "Move down"), move_lower_admin_site_path(site), :method => :post) diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..d1b69b1 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,10 @@ +ActionController::Routing::Routes.draw do |map| + map.namespace :admin, :member => { :remove => :get } do |admin| + admin.resources :sites, :member => { + :move_higher => :post, + :move_lower => :post, + :move_to_top => :put, + :move_to_bottom => :put + } + end +end diff --git a/lib/multi_site/page_extensions.rb b/lib/multi_site/page_extensions.rb index 1fbd8d4..5c83f3a 100644 --- a/lib/multi_site/page_extensions.rb +++ b/lib/multi_site/page_extensions.rb @@ -1,30 +1,30 @@ module MultiSite::PageExtensions def self.included(base) base.class_eval { - alias_method_chain :url, :sites + alias_method_chain :path, :sites mattr_accessor :current_site has_one :site, :foreign_key => "homepage_id", :dependent => :nullify } base.extend ClassMethods class << base - alias_method_chain :find_by_url, :sites + alias_method_chain :find_by_path, :sites end end module ClassMethods - def find_by_url_with_sites(url, live=true) + def find_by_path_with_sites(url, live=true) root = find_by_parent_id(nil) if self.current_site.is_a?(Site) root = self.current_site.homepage end raise Page::MissingRootPageError unless root - root.find_by_url(url, live) + root.find_by_path(url, live) end end - def url_with_sites + def path_with_sites if parent - parent.child_url(self) + parent.child_path(self) else "/" end diff --git a/multi_site_extension.rb b/multi_site_extension.rb index 7f16b25..56c7ab0 100644 --- a/multi_site_extension.rb +++ b/multi_site_extension.rb @@ -1,22 +1,12 @@ require_dependency 'application_controller' class MultiSiteExtension < Radiant::Extension - version "0.9.0" + version "1.0.0.rc2" description %{ Enables virtual sites to be created with associated domain names. Also scopes the sitemap view to any given page (or the root of an individual site). } url "http://radiantcms.org/" - define_routes do |map| - map.namespace :admin, :member => { :remove => :get } do |admin| - admin.resources :sites, :member => { - :move_higher => :post, - :move_lower => :post, - :move_to_top => :put, - :move_to_bottom => :put - } - end - end def activate require 'multi_site/route_extensions' @@ -26,7 +16,7 @@ def activate Admin::PagesController.send :include, MultiSite::PagesControllerExtensions admin.pages.index.add :bottom, "site_subnav" tab 'Settings' do |tab| - tab.add_item 'Sites', '/admin/sites' + tab.add_item t('sites'), '/admin/sites' end load_default_regions end @@ -36,7 +26,7 @@ def deactivate def load_default_regions Radiant::AdminUI.class_eval { attr_accessor :sites } - admin.sites = returning OpenStruct.new do |sites| + admin.sites = OpenStruct.new.tap do |sites| sites.index = Radiant::AdminUI::RegionSet.new do |index| index.header.concat %w{name_th match_th base_th modify_th order_th} index.row.concat %w{name_td match_td base_td modify_td order_td}