Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: radiant/radiant-multi-site-extension
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: hazg/radiant-multi-site-extension
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Jun 11, 2011

  1. Copy the full SHA
    79ea10f View commit details
  2. Locales in admin tab

    hazg committed Jun 11, 2011
    Copy the full SHA
    de82787 View commit details
Showing with 29 additions and 21 deletions.
  1. +1 −1 app/helpers/admin/sites_helper.rb
  2. +4 −0 config/locales/en.yml
  3. +4 −0 config/locales/ru.yml
  4. +10 −0 config/routes.rb
  5. +6 −6 lib/multi_site/page_extensions.rb
  6. +4 −14 multi_site_extension.rb
2 changes: 1 addition & 1 deletion app/helpers/admin/sites_helper.rb
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
en:
multi_sites:
sites: Sites
4 changes: 4 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
ru:
multi_sites:
sites: Сайты
10 changes: 10 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions lib/multi_site/page_extensions.rb
Original file line number Diff line number Diff line change
@@ -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
18 changes: 4 additions & 14 deletions multi_site_extension.rb
Original file line number Diff line number Diff line change
@@ -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 I18n.t('multi_sites.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}
@@ -48,6 +38,6 @@ def load_default_regions
end
sites.new = sites.edit
end
end

end
end