a little bit of cleaning + prepare the engine to make it work with the hosting extensions

This commit is contained in:
Didier Lafforgue 2012-02-18 01:57:06 +01:00
parent d0cc2984b8
commit ffee024a96
16 changed files with 18 additions and 378 deletions

View File

@ -31,95 +31,3 @@ load 'lib/tasks/cucumber.rake'
# === Default task === # === Default task ===
task :default => [:spec, :cucumber] task :default => [:spec, :cucumber]
# begin
# require 'rdoc/task'
# rescue LoadError
# require 'rdoc/rdoc'
# require 'rake/rdoctask'
# RDoc::Task = Rake::RDocTask
# end
# # require File.expand_path('../config/application', __FILE__)
#
# require 'rubygems'
#
# require 'rake/dsl_definition'
# require 'rake'
# require 'rdoc/task'
# require 'rubygems/package_task'
#
# # Locomotive::Application.load_tasks
#
# gemspec = eval(File.read('locomotive_cms.gemspec'))
# Gem::PackageTask.new(gemspec) do |pkg|
# pkg.gem_spec = gemspec
# end
#
# desc 'build the gem and release it to rubygems.org'
# task :release => :gem do
# sh "gem push pkg/custom_fields-#{gemspec.version}.gem"
# end
#
# task :default => [:spec, :cucumber]
#
# # only for running the tests suite in the order observed in *nix systems
# task :spec_nix do
# files = %w(
# lib/core_ext_spec.rb
# lib/locomotive/routing/site_dispatcher_spec.rb
# lib/locomotive/bushido_spec.rb
# lib/locomotive/render_spec.rb
# lib/locomotive/httparty/patches_spec.rb
# lib/locomotive/httparty/webservice_spec.rb
# lib/locomotive/configuration_spec.rb
# lib/locomotive/liquid/tags/consume_spec.rb
# lib/locomotive/liquid/tags/with_scope_spec.rb
# lib/locomotive/liquid/tags/nav_spec.rb
# lib/locomotive/liquid/tags/editable/content_spec.rb
# lib/locomotive/liquid/tags/editable/short_text_spec.rb
# lib/locomotive/liquid/tags/seo_spec.rb
# lib/locomotive/liquid/tags/paginate_spec.rb
# lib/locomotive/liquid/drops/content_spec.rb
# lib/locomotive/liquid/drops/contents_spec.rb
# lib/locomotive/liquid/drops/page_spec.rb
# lib/locomotive/liquid/drops/site_spec.rb
# lib/locomotive/liquid/filters/resize_spec.rb
# lib/locomotive/liquid/filters/html_spec.rb
# lib/locomotive/liquid/filters/date_spec.rb
# lib/locomotive/liquid/filters/text_spec.rb
# lib/locomotive/liquid/filters/misc_spec.rb
# lib/locomotive/heroku_spec.rb
# models/content_entry_spec.rb
# models/editable_element_spec.rb
# models/account_spec.rb
# models/content_type_spec.rb
# models/snippet_spec.rb
# models/ability_spec.rb
# models/membership_spec.rb
# models/page_spec.rb
# models/asset_spec.rb
# models/theme_asset_spec.rb
# models/site_spec.rb
# cells/admin/main_menu_cell_spec.rb
# cells/admin/global_actions_spec.rb
# cells/admin/settings_menu_cell_spec.rb
# requests/seo_trailing_slash_spec.rb
# ).collect { |f| File.join('spec', f) }.join(' ')
#
# sh "bundle exec rspec #{files}"
# end
#
# task :travis do
# ["rspec spec", "cucumber -b"].each do |cmd|
# puts "Starting to run #{cmd}..."
# system("export DISPLAY=:99.0 && bundle exec #{cmd}")
# raise "#{cmd} failed!" unless $?.exitstatus == 0
# end
# end

View File

@ -1,105 +0,0 @@
embed_assets: off
# compress_assets: off
# package_assets: off
s3_bucket: <%= ENV['S3_BUCKET'] %>
s3_access_key_id: <%= ENV['S3_KEY_ID'] %>
s3_secret_access_key: <%= ENV['S3_SECRET_KEY'] %>
javascripts:
box:
- public/javascripts/admin/jquery.js
installation:
- public/javascripts/admin/jquery.js
- public/javascripts/admin/installation.js
common:
- public/javascripts/admin/jquery.js
- public/javascripts/admin/jquery.ui.js
- public/javascripts/admin/rails.js
- public/javascripts/admin/utils.js
- public/javascripts/admin/plugins/cmd.js
- public/javascripts/admin/plugins/subscribe.js
- public/javascripts/admin/plugins/shortcut.js
- public/javascripts/admin/plugins/toggle.js
- public/javascripts/admin/plugins/growl.js
- public/javascripts/admin/plugins/cookie.js
- public/javascripts/admin/locales/datepicker_de.js
- public/javascripts/admin/locales/datepicker_fr.js
- public/javascripts/admin/locales/datepicker_pt-BR.js
- public/javascripts/admin/locales/datepicker_it.js
- public/javascripts/admin/application.js
- public/javascripts/admin/guiders-1.1.0.js
- public/javascripts/admin/tutorial.js
custom_fields:
- public/javascripts/admin/plugins/fancybox.js
- public/javascripts/admin/plugins/mustache.js
- public/javascripts/admin/custom_fields.js
edit_custom_fields:
- public/javascripts/admin/plugins/tiny_mce/tinymce.js
- public/javascripts/admin/plugins/json2.js
- public/javascripts/admin/plugins/fancybox.js
- public/javascripts/admin/plugins/mustache.js
- public/javascripts/admin/custom_fields/category.js
- public/javascripts/admin/custom_fields/has_many.js
contents:
- public/javascripts/admin/plugins/tiny_mce/tinymce.js
- public/javascripts/admin/contents.js
content_types:
- public/javascripts/admin/plugins/codemirror/codemirror.min.js
- public/javascripts/admin/content_types.js
site:
- public/javascripts/admin/site.js
- public/javascripts/admin/plugins/codemirror/codemirror.min.js
import:
- public/javascripts/admin/plugins/json2.js
- public/javascripts/admin/plugins/smartupdater.js
- public/javascripts/admin/import.js
account:
- public/javascripts/admin/account.js
pages:
- public/javascripts/admin/pages.js
- public/javascripts/admin/plugins/menu_toggler.js
edit_page:
- public/javascripts/admin/plugins/tiny_mce/tinymce.js
- public/javascripts/admin/editable_elements.js
- public/javascripts/admin/pages.js
image_picker:
- public/javascripts/admin/plugins/json2.js
- public/javascripts/admin/plugins/scrollTo.js
- public/javascripts/admin/plugins/codemirror/codemirror.min.js
- public/javascripts/admin/plugins/fancybox.js
- public/javascripts/admin/plugins/plupload/plupload.full.js
- public/javascripts/admin/plugins/imagepicker.js
snippets:
- public/javascripts/admin/snippets.js
theme_assets:
- public/javascripts/admin/theme_assets.js
stylesheets:
ie:
- public/stylesheets/admin/blueprint/ie.css
box:
- public/stylesheets/admin/blueprint/screen.css
- public/stylesheets/admin/box.css
- public/stylesheets/admin/safari.css
common:
- public/stylesheets/admin/blueprint/screen.css
- public/stylesheets/admin/layout.css
- public/stylesheets/admin/jquery/ui.css
- public/stylesheets/admin/plugins/toggle.css
- public/stylesheets/admin/menu.css
- public/stylesheets/admin/buttons.css
- public/stylesheets/admin/formtastic.css
- public/stylesheets/admin/formtastic_changes.css
- public/stylesheets/admin/assets.css
- public/stylesheets/admin/sites_picker.css
- public/stylesheets/admin/application.css
- public/stylesheets/admin/safari.css
- public/stylesheets/admin/guiders-1.1.0.css
fancybox:
- public/stylesheets/admin/plugins/fancybox.css
- public/stylesheets/admin/fancybox_changes.css
installation:
- public/stylesheets/admin/installation.css
editable_elements:
- public/stylesheets/admin/editable_elements.css

View File

@ -1,38 +0,0 @@
# require 'locomotive'
#
# # TODO: Make this store to RAILS_ROOT/permanent
#
# # On bushido, the app directory is destroyed on every update, so everything is lost.
# # The only place this doesn't happen is the RAILS_ROOT/permanent folder.
# # Also, RAILS_ROOT/permanent/store is symlinked to RAILS_ROOT/public/store on every update,
# # so store your publicly-accessible files here (e.g. templates, etc.)
#
# CarrierWave.configure do |config|
#
# config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')
#
# case Rails.env.to_sym
#
# when :development
# config.storage = :file
# config.root = File.join(Rails.root, 'public')
#
# when :production
# if Locomotive.bushido?
# config.storage = :file
# config.root = File.join(Rails.root, 'public')
# config.store_dir = 'store'
# else
# config.storage = :s3
# config.s3_access_key_id = ENV['S3_KEY_ID']
# config.s3_secret_access_key = ENV['S3_SECRET_KEY']
# config.s3_bucket = ENV['S3_BUCKET']
# # config.s3_cname = 'ENV['S3_CNAME']
#
# # settings for the local filesystem
# # config.storage = :file
# # config.root = File.join(Rails.root, 'public')
# end
# end
#
# end unless Locomotive.engine?

View File

@ -1,31 +0,0 @@
# require 'locomotive'
#
# unless Locomotive.engine?
#
# require 'dragonfly'
#
# ## initialize Dragonfly ##
#
# app = Dragonfly[:images]
# app.configure_with(:rails)
# app.configure_with(:imagemagick)
#
# ## configure it ##
#
# Dragonfly[:images].configure do |c|
# # Convert absolute location needs to be specified
# # to avoid issues with Phusion Passenger not using $PATH
# convert = `which convert`.strip.presence || "/usr/local/bin/convert"
# c.convert_command = convert
# c.identify_command = convert
#
# c.allow_fetch_url = true
# c.allow_fetch_file = true
#
# c.url_format = '/images/dynamic/:job/:basename.:format'
# end
#
# end
#
#
#

View File

@ -1,14 +0,0 @@
# # Be sure to restart your server when you modify this file.
#
# # Add new inflection rules using the following format
# # (all these examples are active by default):
# # ActiveSupport::Inflector.inflections do |inflect|
# # inflect.plural /^(ox)$/i, '\1en'
# # inflect.singular /^(ox)en/i, '\1'
# # inflect.irregular 'person', 'people'
# # inflect.uncountable %w( fish sheep )
# # end
#
# ActiveSupport::Inflector.inflections do |inflect|
# end
#

View File

@ -1,5 +0,0 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

View File

@ -1,8 +0,0 @@
# if Rails.env.test? && defined?(Locomotive::Application) # does not need it for the engine version
# Locomotive::Application.configure do
# config.generators do |g|
# g.integration_tool :rspec
# g.test_framework :rspec
# end
# end
# end

View File

@ -1,10 +0,0 @@
# # Be sure to restart your server when you modify this file.
# require 'digest/sha1'
#
# # Your secret key for verifying the integrity of signed cookies.
# # If you change this key, all old signed cookies will become invalid!
# # Make sure the secret is at least 30 characters and all random,
# # no regular words or you'll be exposed to dictionary attacks.
# token = ENV['BUSHIDO_SALT'] || 'aa84844b97e90edda8e005a686d82c3bef1f8e20a1255301f1d0886fc592a45ef2393d64b0c3d3ea858b1f6406ad6f15305666264716a79fcfa17de93ad0d69d'
#
# Rails.application.config.secret_token = Digest::SHA1.hexdigest(token)

View File

@ -16,22 +16,6 @@ Locomotive.configure do |config|
# end # end
config.multi_sites = false config.multi_sites = false
# configure the hosting target for the production environment. LocomotiveCMS can be installed in:
# - your own server
# - Heroku (you need to create an account in this case)
# - Bushi.do (see the bushi.do website for more explanations)
#
# the possible options are: server, heroku, bushido or auto (default)
# if you select 'auto', LocomotiveCMS will look after specific ENV variables to check
# the matching platform (Heroku and Bushido set their own ENV variables).
#
config.hosting = :auto
# In case you host LocomotiveCMS in Heroku, the engine uses the heroku api to add / remove domains.
# config.heroku = {
# :api_key => '<your_heroku_api_key>
# }
# configure how many items we display in sub menu in the "Contents" section. # configure how many items we display in sub menu in the "Contents" section.
# config.ui = { # config.ui = {
# :latest_entries_nb => 5, # :latest_entries_nb => 5,

View File

@ -31,18 +31,6 @@ module Locomotive
end end
end end
def self.engine?
self.const_defined?('Engine')
end
def self.default_site_template_present?
File.exists?(self.default_site_template_path)
end
def self.default_site_template_path
File.join(Rails.root, 'tmp/default_site_template.zip')
end
def self.configure def self.configure
self.config ||= Configuration.new self.config ||= Configuration.new
@ -76,6 +64,9 @@ module Locomotive
rescue ::Mongoid::Errors::InvalidDatabase => e rescue ::Mongoid::Errors::InvalidDatabase => e
# let assume it's because of the first install (meaning no config.yml file) # let assume it's because of the first install (meaning no config.yml file)
end end
# enable the hosting solution if both we are not in test or dev and that the config.hosting option has been filled up
self.enable_hosting
end end
def self.add_middlewares def self.add_middlewares
@ -101,6 +92,12 @@ module Locomotive
end end
end end
def self.enable_hosting
if (!Rails.env.test? && !Rails.env.development?) && !self.config.hosting.blank? && self.respond_to?(:"enable_#{self.config.hosting}")
self.send(:"enable_#{self.config.hosting}")
end
end
def self.define_subdomain_and_domains_options def self.define_subdomain_and_domains_options
if self.config.multi_sites? if self.config.multi_sites?
self.config.manage_subdomain = self.config.manage_domains = true self.config.manage_subdomain = self.config.manage_domains = true

View File

@ -11,7 +11,6 @@ module Locomotive
:site_locales => %w{en de fr pt-BR it nl no es ru}, :site_locales => %w{en de fr pt-BR it nl no es ru},
:cookie_key => '_locomotive_session', :cookie_key => '_locomotive_session',
:enable_logs => false, :enable_logs => false,
:hosting => :auto,
:delayed_job => false, :delayed_job => false,
:default_locale => :en, :default_locale => :en,
:mailer_sender => 'support@example.com', :mailer_sender => 'support@example.com',

View File

@ -17,17 +17,6 @@ Locomotive.configure do |config|
end end
# config.multi_sites = false # config.multi_sites = false
# configure the hosting target for the production environment. Locomotive can be installed in:
# - your own server
# - Heroku (you need to create an account in this case)
# - Bushi.do (see the bushi.do website for more explanations)
#
# the possible options are: server, heroku, bushido or auto (default)
# if you select 'auto', Locomotive will look after specific ENV variables to check
# the matching platform (Heroku and Bushido set their own ENV variables).
#
config.hosting = :server
# In case you host Locomotive in Heroku, the engine uses the heroku api to add / remove domains. # In case you host Locomotive in Heroku, the engine uses the heroku api to add / remove domains.
# there are 2 ways of passing heroku credentials to Locomotive # there are 2 ways of passing heroku credentials to Locomotive
# - from ENV variables: HEROKU_LOGIN & HEROKU_PASSWORD # - from ENV variables: HEROKU_LOGIN & HEROKU_PASSWORD

View File

@ -12,6 +12,13 @@ describe Locomotive::Configuration do
Locomotive.config.reserved_subdomains.should == ['empty'] Locomotive.config.reserved_subdomains.should == ['empty']
end end
it 'calls the hosting enabler if provided' do
Rails.env.stubs(:test?).returns(false)
Locomotive.expects(:enable_bushido).once
Locomotive.config.hosting = :bushido
Locomotive.enable_hosting
end
after(:each) do after(:each) do
Locomotive.config = @old_config Locomotive.config = @old_config
end end

View File

@ -22,10 +22,6 @@ RSpec.configure do |config|
Locomotive.configure_for_test(true) Locomotive.configure_for_test(true)
end end
config.before(:each) do
Locomotive.config.heroku = false
end
config.before(:suite) do config.before(:suite) do
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = 'mongoid' DatabaseCleaner.orm = 'mongoid'

View File

@ -1,28 +1,3 @@
require 'rspec-cells' require 'rspec-cells'
require 'cell/test_case' require 'cell/test_case'
require 'rspec/rails/example/cell_example_group' require 'rspec/rails/example/cell_example_group'
#
# module CellsResetter
#
# def self.method_missing(meth, *args)
# if meth =~ /^new_(.*)_klass/
# name = $1
#
# klass_name = name.camelize
#
# ::Locomotive.send(:remove_const, klass_name)
# load "locomotive/#{name}.rb"
#
# "::Locomotive::#{klass_name}".constantize.any_instance.stubs(:sections).returns(args.first)
# end
# end
#
# def self.clean!
# [:menu_cell, :main_menu_cell, :global_actions_cell, :settings_menu_cell].each do |name|
# ::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
# load "locomotive/#{name}.rb"
# end
# end
#
# end

View File

@ -17,16 +17,12 @@ def Locomotive.configure_for_test(force = false)
Locomotive.configure do |config| Locomotive.configure do |config|
config.multi_sites do |multi_sites| config.multi_sites do |multi_sites|
multi_sites.domain = 'example.com' multi_sites.domain = 'example.com'
multi_sites.reserved_subdomains = %w(www admin email blog webmail mail support help site sites) multi_sites.reserved_subdomains = %w(www admin locomotive email blog webmail mail support help site sites)
end end
config.hosting = :none
config.enable_logs = true config.enable_logs = true
if force if force
ENV['APP_TLD'] = ENV['HEROKU_SLUG'] = ENV['APP_NAME'] = ENV['HEROKU_LOGIN'] = ENV['HEROKU_PASSWORD'] = nil
Locomotive.define_subdomain_and_domains_options Locomotive.define_subdomain_and_domains_options
Locomotive.send(:remove_const, 'Site') if Locomotive.const_defined?('Site') Locomotive.send(:remove_const, 'Site') if Locomotive.const_defined?('Site')