Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Add support for multiple subdomains and admin pages to manage them. Requires authentication_engine or similar authentication solution.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
db/migrate
lib
public
tasks
test
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
init.rb
install.rb
uninstall.rb

README.rdoc

SiteEngine

This Rails 2.3 engine will give you a system for managing multiple subdomains for a site, and the admin pages for managing them. It consists of two models, Site and Page, where pages acts as a nested set and are associated with a Site. Each page has content through a polymorphic relationship. This engine is still work in progress and not ready for use.

Pages acts as nested sets, and belong to Sites. Pages belong to polymorphic content. When viewing a page, its content will be rendered with a call to a partial by the name of the content Model in its view directory.

Requirements

  1. You need Rails 2.3! This engine is not based on the rails-engines plugin.

  2. You need the SubdomainFu gem

  3. The Awesome Nested Set gem from CollectiveIdea

Installation

$ script/plugin install git://github.com/angantyr/site_engine.git

For some reason, the gems don't get required correctly from within the engine, so in your environments.rb, add:

config.gem 'mbleigh-subdomain-fu', :lib => "subdomain-fu", :source => "http://gems.github.com"
config.gem 'collectiveidea-awesome_nested_set', :lib => "awesome_nested_set", :source => "http://gems.github.com"

Then synchronize neccessary assets, by running this rake task, and then migrate the db:

$ rake site_engine:sync
$ rake db:migrate

the site_engine:sync rake task does the following, so use it with care on an existing site:

  1. moves the migration files over to db/migrate

  2. moves a site_config.yml file and it's initializer into config

  3. moves a helper over. rails doesn't seem to pick up helpers inside engines

Configuration

A couple of simple steps to get up and running:

  1. In your application_controller.rb, include the site engine module, and a before filter:

class ApplicationController < ActionController::Base include SiteEngine before_filter :site_required … end

  1. Add the following root route:

map.root :controller => "pages"

This will use the index action on the pages controller to find the first topic for the current_site, usually “default” for the 'www' domain, and display it.

For any model, you want to display as a “page”, you need to do two things:

First, set up the polymorhic content relationship with a page:

class Topic < ActiveRecord::Base
  has_one :page, :as => :content
end

And, then make sure that there is a partial with the model name inside its view directory:

app/views/topics/_topic.html.erb

More to come…

Something went wrong with that request. Please try again.