Sha256: f12b57e301d95be702d269ee0b0d6ffb8f8edee2052e2e90c2a8c39808e36bf1

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'refinerycms-base'

module Refinery
  module Sites
    class Engine < Rails::Engine
      initializer "static assets" do |app|
        app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
      end

      config.after_initialize do
        Refinery::Plugin.register do |plugin|
          plugin.name = "sites"
          plugin.activity = {
            :class => Site,
            :title => 'name'
          }
        end
      end
    end
  end
end

module PagesControllerSite
  def home_with_site
    if (@site)
      error_404 unless (@page = Page.find(@site.page_id)).present?
    else
      home_without_site
    end
  end
end

class ActionController::Base
  # Loading the Current Site
  before_filter :load_site
  protected
  def load_site
    @site = Site.find_by_hostname(request.host)
    return if ::PagesController.include? PagesControllerSite
    # Monkey-Patch the Page-Controller for loading the right root-Page
    ::PagesController.class_eval do
      include PagesControllerSite
      alias_method_chain :home, :site
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
refinerycms-multisite-0.0.5 lib/refinerycms-multisite.rb
refinerycms-multisite-0.0.4 lib/refinerycms-multisite.rb