refinerycms-multisite 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/.gitignore +96 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +4 -0
  4. data/Rakefile +2 -0
  5. data/app/controllers/admin/sites_controller.rb +10 -0
  6. data/app/controllers/application_controller.rb +8 -0
  7. data/app/helpers/admin/sites_helper.rb +10 -0
  8. data/app/helpers/application_helper.rb +2 -0
  9. data/app/models/hostname.rb +4 -0
  10. data/app/models/site.rb +34 -0
  11. data/app/views/admin/sites/_actions.html.erb +15 -0
  12. data/app/views/admin/sites/_form.html.erb +51 -0
  13. data/app/views/admin/sites/_hostname_fields.html.erb +5 -0
  14. data/app/views/admin/sites/_records.html.erb +22 -0
  15. data/app/views/admin/sites/_site.html.erb +20 -0
  16. data/app/views/admin/sites/_sites.html.erb +5 -0
  17. data/app/views/admin/sites/edit.html.erb +1 -0
  18. data/app/views/admin/sites/index.html.erb +15 -0
  19. data/app/views/admin/sites/new.html.erb +1 -0
  20. data/app/views/layouts/application.html.haml +20 -0
  21. data/app/views/shared/_footer.html.erb +4 -0
  22. data/app/views/shared/_header.html.erb +15 -0
  23. data/app/views/sitemap/index.xml.builder +22 -0
  24. data/config/locales/de.yml +11 -0
  25. data/config/locales/en.yml +13 -0
  26. data/config/routes.rb +9 -0
  27. data/db/migrate/20110418095543_create_sites.rb +14 -0
  28. data/db/migrate/20110418095626_create_hostnames.rb +13 -0
  29. data/db/seeds.rb +12 -0
  30. data/lib/generators/refinerycms_sites_generator.rb +8 -0
  31. data/lib/refinerycms-multisite/version.rb +5 -0
  32. data/lib/refinerycms-multisite.rb +22 -0
  33. data/lib/tasks/.gitkeep +0 -0
  34. data/readme.md +0 -0
  35. data/refinerycms-multisite.gemspec +25 -0
  36. data/spec/acceptance/acceptance_helper.rb +5 -0
  37. data/spec/acceptance/support/helpers.rb +5 -0
  38. data/spec/acceptance/support/paths.rb +9 -0
  39. data/spec/controllers/admin/site_controller_spec.rb +41 -0
  40. data/spec/factories.rb +13 -0
  41. data/spec/models/factory_girl_spec.rb +14 -0
  42. data/spec/models/hostname_spec.rb +17 -0
  43. data/spec/models/site_spec.rb +9 -0
  44. data/spec/views/inherited_resource_helpers.rb +20 -0
  45. metadata +152 -0
data/.gitignore ADDED
@@ -0,0 +1,96 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ pkg/*
4
+
5
+ db/*.sqlite3
6
+ db/*.sqlite3.db
7
+ log/*.log
8
+ tmp/**/*
9
+
10
+ *~
11
+ \#*\#
12
+ config/database.yml
13
+ coverage/
14
+ db/*.sqlite3
15
+ db/*.sqlite3-journal
16
+ log/*.log
17
+ *.swp
18
+ nbproject
19
+ public/system/**/*
20
+ private/**/*
21
+ .DS_Store
22
+ webrat*html
23
+ mkmf.log
24
+ public/javascripts/all.js
25
+ public/stylesheets/all.css
26
+ .yardoc
27
+ .idea
28
+ # Rails
29
+ .bundle
30
+ db/*.sqlite3
31
+ db/*.sqlite3-journal
32
+ *.log
33
+ tmp/**/*
34
+
35
+ # Documentation
36
+ doc/api
37
+ doc/app
38
+ doc/*
39
+ .yardoc
40
+ .yardopts
41
+
42
+ # Public Uploads
43
+ public/system/*
44
+ public/themes/*
45
+
46
+ # Public Cache
47
+ public/javascripts/cache
48
+ public/stylesheets/cache
49
+
50
+ # Vendor Cache
51
+ vendor/cache
52
+
53
+ # Acts as Indexed
54
+ index/**/*
55
+
56
+ # Refinery Specific
57
+ *.tmproj
58
+ *.autobackupbyrefinery.*
59
+ .autotest
60
+
61
+ # Mac
62
+ .DS_Store
63
+
64
+ # Windows
65
+ Thumbs.db
66
+
67
+ # NetBeans
68
+ nbproject
69
+
70
+ # Eclipse
71
+ .project
72
+
73
+ # Redcar
74
+ .redcar
75
+
76
+ # Rubinius
77
+ *.rbc
78
+
79
+ # Vim
80
+ *.swp
81
+ *.swo
82
+
83
+ # RubyMine
84
+ .idea
85
+
86
+ # Backup
87
+ *~
88
+
89
+ # Capybara Bug
90
+ capybara-*html
91
+
92
+ # sass
93
+ .sass-cache
94
+ .sass-cache/*
95
+
96
+
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-1.8.7@refinerycms-multisite
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in refinerycms-multisite.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,10 @@
1
+ class Admin::SitesController < Admin::BaseController
2
+ helper :refinery_settings
3
+
4
+ crudify :site,
5
+ :title_attribute => :name,
6
+ :order => "name ASC",
7
+ #:redirect_to_url => :redirect_to_where?,
8
+ :xhr_paging => true
9
+
10
+ end
@@ -0,0 +1,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ before_filter :load_site
3
+ protect_from_forgery
4
+ protected
5
+ def load_site
6
+ @site = Site.find_by_hostname(request.host)
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Admin::SitesHelper
2
+ def link_to_add_fields(name, f, association)
3
+ new_object = f.object.class.reflect_on_association(association).klass.new
4
+ fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
5
+ render(association.to_s.singularize + "_fields", :f => builder)
6
+ end
7
+ link_to_function(name, "add_fields(this, \"#{association}\",
8
+ \"#{escape_javascript(fields)}\")")
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ class Hostname < ActiveRecord::Base
2
+ belongs_to :site
3
+ attr_accessible :hostname, :created_at, :updated_at, :site_id
4
+ end
@@ -0,0 +1,34 @@
1
+ class Site < ActiveRecord::Base
2
+ belongs_to :page
3
+ attr_accessible :name, :page_id, :stylesheet, :hostnames,
4
+ :hostnames_attributes
5
+
6
+ has_many :hostnames,
7
+ :dependent => :destroy
8
+
9
+ accepts_nested_attributes_for :hostnames, :allow_destroy => true
10
+
11
+ def self.find_by_hostname(hostname)
12
+ Site.joins(:hostnames).where(:hostnames=>{:hostname=>hostname}).first ||
13
+ Site.joins(:hostnames).where(:hostnames=>{:hostname=>'*'}).first
14
+ end
15
+
16
+ # Monkey-Patch the Page-Controller for loading the right root-Page
17
+ PagesController.class_eval do
18
+ def home
19
+ if (@site)
20
+ error_404 unless (@page = Page.find(@site.page_id)).present?
21
+ else
22
+ error_404 unless (@page = Page.where(:link_url => '/').first).present?
23
+ end
24
+ end
25
+ end
26
+ # Monkey-Patch the Application-Controller for loading the current site
27
+ ApplicationController.class_eval do
28
+ before_filter :load_site
29
+ protected
30
+ def load_site
31
+ @site = Site.find_by_hostname(request.host)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,15 @@
1
+ <ul>
2
+ <li>
3
+ <%= render :partial => "/shared/admin/search",
4
+ :locals => {
5
+ :url => admin_sites_url
6
+ } %>
7
+ </li>
8
+ <li>
9
+ <%= link_to t('.new'), new_admin_site_url({
10
+ :dialog => true,
11
+ :width => 725,
12
+ :height => 475
13
+ }), :class => "add_icon" %>
14
+ </li>
15
+ </ul>
@@ -0,0 +1,51 @@
1
+ <%= form_for [:admin, @site] do |f| %>
2
+
3
+ <%= render :partial => "/shared/admin/error_messages",
4
+ :locals => {
5
+ :object => @site,
6
+ :include_object_name => true
7
+ } %>
8
+
9
+ <div class='field'>
10
+ <%= f.label :name %>
11
+ <%= f.text_field :name, :class => "larger widest" %>
12
+ </div>
13
+ <div class='field'>
14
+ <%= f.label :page_id %>
15
+ <%= f.select :page_id, nested_set_options(Page, @page) {|i| "#{'-' * i.level} #{i.title}" },
16
+ :include_blank => true %>
17
+ </div>
18
+ <div class='field'>
19
+ <%= f.label :stylesheet %>
20
+ <%= f.text_field :stylesheet%>
21
+ </div>
22
+ <%= f.label :hostnames %>
23
+ <%= f.fields_for :hostnames do |hf| %>
24
+ <%= render 'hostname_fields', :f=>hf %>
25
+ <% end %>
26
+ <p><%= link_to_add_fields refinery_icon_tag('add.png'), f,
27
+ :hostnames %></p>
28
+ <%= render :partial => "/shared/admin/form_actions",
29
+ :locals => {
30
+ :f => f,
31
+ :continue_editing => false,
32
+ :submit_button_title => t('.restart_may_be_in_order_html'),
33
+ :delete_title => t('delete', :scope => 'admin.sites'),
34
+ :delete_confirmation => t('message', :scope => 'shared.admin.delete',
35
+ :title => @site.name.to_s.titleize),
36
+ :hide_delete => (!@site.persisted? or from_dialog?)
37
+ } %>
38
+ <% end -%>
39
+ <% content_for :javascripts do %>
40
+ <script type="text/javascript">
41
+ function remove_fields(link) {
42
+ $(link).prev("input[type=hidden]").val("1");
43
+ $(link).closest(".fields").hide();
44
+ }
45
+ function add_fields(link, association, content) {
46
+ var new_id = new Date().getTime();
47
+ var regexp = new RegExp("new_" + association, "g");
48
+ $(link).before(content.replace(regexp, new_id));
49
+ }
50
+ </script>
51
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <p class="fields">
2
+ <%= f.text_field :hostname %>
3
+ <%= f.hidden_field :_destroy %>
4
+ <%= link_to_function refinery_icon_tag('delete.png'), "remove_fields(this)" %>
5
+ </p>
@@ -0,0 +1,22 @@
1
+ <% if searching? %>
2
+ <h2>
3
+ <%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %>
4
+ </h2>
5
+ <% end %>
6
+ <% if @sites.any? %>
7
+ <div class='pagination_container'>
8
+ <%= render :partial => 'sites' %>
9
+ </div>
10
+ <% else %>
11
+ <p>
12
+ <% if searching? %>
13
+ <%= t('no_results', :scope => 'shared.admin.search') %>
14
+ <% else %>
15
+ <strong>
16
+ <%= t('.empty_set') %>
17
+ <%= t('.create_first', :link => t('new', :scope => 'admin.sites.actions')
18
+ ) %>
19
+ </strong>
20
+ <% end %>
21
+ </p>
22
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>'>
2
+ <span class='title'>
3
+ <%= site.name.to_s.titleize %>
4
+ <span class="preview">- <%= site.hostnames.map {|host| host.hostname+" "}
5
+ %></span>
6
+ </span>
7
+ <span class='actions'>
8
+ <%= link_to refinery_icon_tag('application_edit.png'),
9
+ edit_admin_site_path(site, :dialog => true,
10
+ :width => 725, :height => 525),
11
+ :title => t('edit', :scope => 'admin.sites') %>
12
+ <%= link_to refinery_icon_tag('delete.png'),
13
+ admin_site_path(site),
14
+ :class => 'cancel confirm-delete',
15
+ :title => t('delete', :scope => 'admin.sites'),
16
+ :confirm => t('message', :scope => 'shared.admin.delete',
17
+ :title => site.name),
18
+ :method => :delete %>
19
+ </span>
20
+ </li>
@@ -0,0 +1,5 @@
1
+ <%= will_paginate @refinery_settings %>
2
+ <ul class="<%= ['pagination_frame', pagination_css_class].compact.join(' ') %>">
3
+ <%= render :partial => 'site',
4
+ :collection => @sites %>
5
+ </ul>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,15 @@
1
+ <div id='records'>
2
+ <%= render :partial => 'records' %>
3
+ </div>
4
+ <div id='actions'>
5
+ <%= render :partial => 'actions' %>
6
+ </div>
7
+ <% content_for :javascripts do %>
8
+ <script>
9
+ $(document).ready(function() {
10
+ $('#records ul li .actions a[href*=edit]').each(function(i, li) {
11
+ $(li).attr('name', $(li).attr('tooltip'));
12
+ });
13
+ });
14
+ </script>
15
+ <% end -%>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,20 @@
1
+ !!!
2
+ - if @site.try(:stylesheet)
3
+ - content_for :stylesheets do
4
+ = stylesheet_link_tag @site.stylesheet
5
+ = render :partial => "/shared/html_tag"
6
+ - site_bar = render(:partial => "/shared/site_bar", :locals => {:head => true})
7
+ = render :partial => "/shared/head"
8
+ %body
9
+ /
10
+ = request.host
11
+ -#= site_bar
12
+ = render :partial => "/shared/ie6check" if request.env['HTTP_USER_AGENT'] =~ /MSIE/
13
+ #container
14
+ %header
15
+ = render :partial => "/shared/header"
16
+ %section#page
17
+ = yield
18
+ %footer
19
+ = render :partial => "/shared/footer"
20
+ = render :partial => "/shared/javascripts"
@@ -0,0 +1,4 @@
1
+ <p>
2
+ <%= t('.copyright', :year => Time.now.year,
3
+ :site_name => @site.try(:name) || RefinerySetting.find_or_set(:site_name, "Company Name")) %>
4
+ </p>
@@ -0,0 +1,15 @@
1
+ <h1 id='logo'>
2
+ <%= link_to RefinerySetting.find_or_set(:site_name, "Company Name"), root_path %>
3
+ </h1>
4
+ <%=
5
+ ::Fiber.new {
6
+ ::Fiber.yield(
7
+ render(:partial => "/shared/menu", :locals => {
8
+ :dom_id => 'menu',
9
+ :css => 'menu',
10
+ :roots => @menu_pages.where(:parent_id => @site.try(:page_id)),
11
+ :collection => @menu_pages.where(@menu_pages.arel_table[:parent_id].not_eq(nil)),
12
+ :selected_item => (@page if defined?(::Page))
13
+ })
14
+ )
15
+ }.resume %>
@@ -0,0 +1,22 @@
1
+ xml.instruct!
2
+
3
+ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
4
+
5
+ @pages.each do |page|
6
+ # exclude sites that are external to our own domain.
7
+ page_url = if page.url.is_a?(Hash)
8
+ # This is how most pages work without being overriden by link_url
9
+ page.url.merge({:only_path => false})
10
+ elsif page.url.to_s !~ /^http/
11
+ # handle relative link_url addresses.
12
+ "#{request.protocol}#{request.host_with_port}#{page.url}"
13
+ end
14
+
15
+ # Add XML entry only if there is a valid page_url found above.
16
+ xml.url do
17
+ xml.loc url_for(page_url)
18
+ xml.lastmod page.updated_at.to_date
19
+ end if page_url.present?
20
+ end
21
+
22
+ end
@@ -0,0 +1,11 @@
1
+ de:
2
+ plugins:
3
+ sites:
4
+ title: Sites
5
+ admin:
6
+ sites:
7
+ actions:
8
+ new: 'Site hinzufügen'
9
+ edit: 'Site anpassen'
10
+ delete: 'Site entfernen'
11
+
@@ -0,0 +1,13 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ plugins:
6
+ sites:
7
+ title: Sites
8
+ admin:
9
+ sites:
10
+ actions:
11
+ new: 'new site'
12
+ edit: 'edit site'
13
+ delete: 'remove site'
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ Refinery::Application.routes.draw do
2
+
3
+ scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
4
+ resources :sites do
5
+ resources :hostnames
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,14 @@
1
+ class CreateSites < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :sites do |t|
4
+ t.string :name
5
+ t.integer :page_id
6
+ t.string :stylesheet
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :sites
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class CreateHostnames < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :hostnames do |t|
4
+ t.string :hostname
5
+ t.integer :site_id
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :hostnames
12
+ end
13
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,12 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
8
+ # Refinery seeds
9
+ Dir[Rails.root.join('db', 'seeds', '*.rb').to_s].each do |file|
10
+ puts "Loading db/seeds/#{file.split(File::SEPARATOR).last}"
11
+ load(file)
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'refinery/generators'
2
+
3
+ class RefinerycmsMultisite < ::Refinery::Generators::EngineInstaller
4
+
5
+ source_root File.expand_path('../../../', __FILE__)
6
+ engine_name "refinery_multisite"
7
+
8
+ end
@@ -0,0 +1,5 @@
1
+ module Refinerycms
2
+ module Multisite
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+
2
+ require 'refinerycms-base'
3
+
4
+ module Refinery
5
+ module Sites
6
+ class Engine < Rails::Engine
7
+ initializer "static assets" do |app|
8
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
9
+ end
10
+
11
+ config.after_initialize do
12
+ Refinery::Plugin.register do |plugin|
13
+ plugin.name = "sites"
14
+ plugin.activity = {
15
+ :class => Site,
16
+ :title => 'name'
17
+ }
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
File without changes
data/readme.md ADDED
File without changes
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "refinerycms-multisite/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "refinerycms-multisite"
7
+ s.version = Refinerycms::Multisite::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Andreas König"]
10
+ s.email = ["koa@panter.ch"]
11
+ s.homepage = ""
12
+ s.summary = %q{Multisite-Plugin for Refinery-CMS}
13
+ s.description = %q{Manage multiple Site with Refinery-CMS}
14
+
15
+ s.rubyforge_project = "refinerycms-multisite"
16
+ s.add_dependency "refinerycms-pages"
17
+ s.add_development_dependency "refinerycms-testing"
18
+ s.add_development_dependency "shoulda-matchers"
19
+
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require "steak"
3
+
4
+ # Put your acceptance spec helpers inside /spec/acceptance/support
5
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
@@ -0,0 +1,5 @@
1
+ module HelperMethods
2
+ # Put helper methods you need to be available in all tests here.
3
+ end
4
+
5
+ RSpec.configuration.include HelperMethods, :type => :acceptance
@@ -0,0 +1,9 @@
1
+ module NavigationHelpers
2
+ # Put helper methods related to the paths in your application here.
3
+
4
+ def homepage
5
+ "/"
6
+ end
7
+ end
8
+
9
+ RSpec.configuration.include NavigationHelpers, :type => :acceptance
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Admin::SitesController do
4
+ include Devise::TestHelpers
5
+
6
+ before(:each) do
7
+ sign_in Factory.create(:refinery_user)
8
+ @origin_site=Factory.create(:site)
9
+ @origin_site.save
10
+ end
11
+
12
+ context 'GET on new' do
13
+ before(:each) { get :new }
14
+ it('assigns a new site') { assigns(:site).should be_a_new(Site) }
15
+ it('responds with success') { response.should be_success }
16
+ end
17
+
18
+ context 'POST on create' do
19
+ before(:each) { post :create, :post => Factory.attributes_for(:site) }
20
+ it('responds with a redirect') do
21
+ response.should redirect_to(:action=>:index)
22
+ end
23
+ it('creates a new site') { assigns(:site).should_not be_a_new_record }
24
+ end
25
+
26
+ context 'persisted site' do
27
+ let(:site) { Factory(:site) }
28
+ context 'GET on edit' do
29
+ before(:each) { get :edit, :id => site }
30
+ it('response with success') { response.should be_success }
31
+ end
32
+ context 'GET on index' do
33
+ before(:each) { get :index }
34
+ it('response with success') { response.should be_success}
35
+ it('assigns sites') do
36
+ assigns(:sites).should include(@origin_site)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
data/spec/factories.rb ADDED
@@ -0,0 +1,13 @@
1
+ Factory.define :post do |f|
2
+ f.title 'Post title'
3
+ end
4
+
5
+ Factory.define :hostname do |f|
6
+ f.hostname 'example.com'
7
+ end
8
+
9
+ Factory.define :site do |f|
10
+ f.name 'ex'
11
+ f.hostnames {|site| [site.association(:hostname),
12
+ site.association(:hostname, :hostname=>'test.host')]}
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe "FactoryGirl" do
4
+
5
+ describe "a hostname by factory" do
6
+ let(:hostname){Factory.build(:hostname)}
7
+ it{hostname.should be_valid}
8
+ end
9
+
10
+ describe "a sites by factory" do
11
+ let(:site){Factory.build(:site)}
12
+ it{site.should be_valid}
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hostname do
4
+ it 'initializes' do
5
+ Hostname.new.should_not be_nil
6
+ end
7
+ describe "hostname" do
8
+ it {should allow_value('localhost').for(:hostname)}
9
+ end
10
+ describe "find host example.com" do
11
+ it 'find saved hostname' do
12
+ Factory.build(:hostname, :hostname=>'example.com').save
13
+
14
+ Hostname.find_by_hostname('example.com').should_not be_nil
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+ require File.expand_path('../../factories', __FILE__)
3
+
4
+ describe Site do
5
+ describe 'find sites by hostname' do
6
+ Factory.build(:site).save
7
+ puts Site.find_by_hostname('example.com')
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ module InheritedResourceHelpers
2
+
3
+ # mock url and other helper methods contributed by inherited resource
4
+ def mock_inherited_resource(resource)
5
+ view.stub(:collection_path).and_return('/collection_path')
6
+ view.stub(:edit_resource_path).and_return('/edit_resource_path')
7
+ view.stub(:new_resource_path).and_return('/new_resource_path')
8
+ view.stub(:parent_path).and_return('/parent_path')
9
+ view.stub(:resource_path).and_return('/resource_path')
10
+
11
+ view.stub(:collection_url).and_return('/collection_url')
12
+ view.stub(:edit_resource_url).and_return('/edit_resource_url')
13
+ view.stub(:new_resource_url).and_return('/new_resource_url')
14
+ view.stub(:parent_url).and_return('/parent_url')
15
+ view.stub(:resource_url).and_return('/resource_url')
16
+
17
+ view.stub(:collection).and_return([resource])
18
+ view.stub(:resource).and_return(resource)
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-multisite
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "Andreas K\xC3\xB6nig"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-26 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: refinerycms-pages
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: refinerycms-testing
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: shoulda-matchers
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ description: Manage multiple Site with Refinery-CMS
64
+ email:
65
+ - koa@panter.ch
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - .gitignore
74
+ - .rvmrc
75
+ - Gemfile
76
+ - Rakefile
77
+ - app/controllers/admin/sites_controller.rb
78
+ - app/controllers/application_controller.rb
79
+ - app/helpers/admin/sites_helper.rb
80
+ - app/helpers/application_helper.rb
81
+ - app/models/hostname.rb
82
+ - app/models/site.rb
83
+ - app/views/admin/sites/_actions.html.erb
84
+ - app/views/admin/sites/_form.html.erb
85
+ - app/views/admin/sites/_hostname_fields.html.erb
86
+ - app/views/admin/sites/_records.html.erb
87
+ - app/views/admin/sites/_site.html.erb
88
+ - app/views/admin/sites/_sites.html.erb
89
+ - app/views/admin/sites/edit.html.erb
90
+ - app/views/admin/sites/index.html.erb
91
+ - app/views/admin/sites/new.html.erb
92
+ - app/views/layouts/application.html.haml
93
+ - app/views/shared/_footer.html.erb
94
+ - app/views/shared/_header.html.erb
95
+ - app/views/sitemap/index.xml.builder
96
+ - config/locales/de.yml
97
+ - config/locales/en.yml
98
+ - config/routes.rb
99
+ - db/migrate/20110418095543_create_sites.rb
100
+ - db/migrate/20110418095626_create_hostnames.rb
101
+ - db/seeds.rb
102
+ - lib/generators/refinerycms_sites_generator.rb
103
+ - lib/refinerycms-multisite.rb
104
+ - lib/refinerycms-multisite/version.rb
105
+ - lib/tasks/.gitkeep
106
+ - readme.md
107
+ - refinerycms-multisite.gemspec
108
+ - spec/acceptance/acceptance_helper.rb
109
+ - spec/acceptance/support/helpers.rb
110
+ - spec/acceptance/support/paths.rb
111
+ - spec/controllers/admin/site_controller_spec.rb
112
+ - spec/factories.rb
113
+ - spec/models/factory_girl_spec.rb
114
+ - spec/models/hostname_spec.rb
115
+ - spec/models/site_spec.rb
116
+ - spec/views/inherited_resource_helpers.rb
117
+ has_rdoc: true
118
+ homepage: ""
119
+ licenses: []
120
+
121
+ post_install_message:
122
+ rdoc_options: []
123
+
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ requirements: []
145
+
146
+ rubyforge_project: refinerycms-multisite
147
+ rubygems_version: 1.6.2
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: Multisite-Plugin for Refinery-CMS
151
+ test_files: []
152
+