Merge branch 'master' of https://github.com/sgrove/engine into sgrove-master
This commit is contained in:
commit
6ba884e459
1
Gemfile
1
Gemfile
@ -25,6 +25,7 @@ gem 'fog', '0.3.7'
|
|||||||
gem 'mimetype-fu'
|
gem 'mimetype-fu'
|
||||||
gem 'actionmailer-with-request'
|
gem 'actionmailer-with-request'
|
||||||
gem 'heroku', '1.18.2'
|
gem 'heroku', '1.18.2'
|
||||||
|
gem 'bushido'
|
||||||
gem 'httparty', '>= 0.6.1'
|
gem 'httparty', '>= 0.6.1'
|
||||||
gem 'RedCloth', '4.2.7'
|
gem 'RedCloth', '4.2.7'
|
||||||
gem 'delayed_job', '2.1.4'
|
gem 'delayed_job', '2.1.4'
|
||||||
|
7
bushido.json
Normal file
7
bushido.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"platform": "rails",
|
||||||
|
"platform_version": 3,
|
||||||
|
"ruby_version": "1.9.2",
|
||||||
|
"sql": false,
|
||||||
|
"mongodb": true
|
||||||
|
}
|
@ -1,3 +1,10 @@
|
|||||||
|
# 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|
|
CarrierWave.configure do |config|
|
||||||
|
|
||||||
case Rails.env.to_sym
|
case Rails.env.to_sym
|
||||||
|
@ -10,7 +10,7 @@ Locomotive.configure do |config|
|
|||||||
# during the installation wizzard.
|
# during the installation wizzard.
|
||||||
# Ex:
|
# Ex:
|
||||||
# config.default_domain = Rails.env.production? ? 'heroku.com' : 'example.com'
|
# config.default_domain = Rails.env.production? ? 'heroku.com' : 'example.com'
|
||||||
config.default_domain = 'example.com'
|
config.default_domain = ENV["APP_TLD"] || 'example.com'
|
||||||
|
|
||||||
# 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.lastest_items_nb = 5
|
config.lastest_items_nb = 5
|
||||||
@ -32,6 +32,14 @@ Locomotive.configure do |config|
|
|||||||
# config.heroku = { :name => '<my heroku app name>', :login => 'john@doe.net', :password => 'easy' }
|
# config.heroku = { :name => '<my heroku app name>', :login => 'john@doe.net', :password => 'easy' }
|
||||||
config.heroku = false
|
config.heroku = false
|
||||||
|
|
||||||
|
# tell if the application is hosted on Bushido.
|
||||||
|
# If enabled, there's no further configuration needed.
|
||||||
|
# Bushido will take care of eveything
|
||||||
|
#
|
||||||
|
# Ex:
|
||||||
|
# config.bushido = true
|
||||||
|
config.bushido = ENV['HOSTING_PLATFORM'] == 'bushido'
|
||||||
|
|
||||||
# Locomotive uses the DelayedJob gem for the theme import module.
|
# Locomotive uses the DelayedJob gem for the theme import module.
|
||||||
# In case you want to deploy to Heroku, you will have to pay for an extra dyno.
|
# In case you want to deploy to Heroku, you will have to pay for an extra dyno.
|
||||||
# If you do not mind about importing theme without DelayedJob, disable it.
|
# If you do not mind about importing theme without DelayedJob, disable it.
|
||||||
@ -41,5 +49,5 @@ Locomotive.configure do |config|
|
|||||||
config.default_locale = :en
|
config.default_locale = :en
|
||||||
|
|
||||||
# Configure the e-mail address which will be shown in the DeviseMailer, NotificationMailer, ...etc
|
# Configure the e-mail address which will be shown in the DeviseMailer, NotificationMailer, ...etc
|
||||||
config.mailer_sender = 'support@example.com'
|
config.mailer_sender = ENV['BUSHIDO_DOMAIN'] ? "support@#{ENV['BUSHIDO_DOMAIN']}" : 'support@example.com'
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
require 'digest/sha1'
|
||||||
|
|
||||||
# Your secret key for verifying the integrity of signed cookies.
|
# Your secret key for verifying the integrity of signed cookies.
|
||||||
# If you change this key, all old signed cookies will become invalid!
|
# If you change this key, all old signed cookies will become invalid!
|
||||||
# Make sure the secret is at least 30 characters and all random,
|
# Make sure the secret is at least 30 characters and all random,
|
||||||
# no regular words or you'll be exposed to dictionary attacks.
|
# no regular words or you'll be exposed to dictionary attacks.
|
||||||
Rails.application.config.secret_token = 'aa84844b97e90edda8e005a686d82c3bef1f8e20a1255301f1d0886fc592a45ef2393d64b0c3d3ea858b1f6406ad6f15305666264716a79fcfa17de93ad0d69d'
|
token = ENV['BUSHIDO_SALT'] || 'aa84844b97e90edda8e005a686d82c3bef1f8e20a1255301f1d0886fc592a45ef2393d64b0c3d3ea858b1f6406ad6f15305666264716a79fcfa17de93ad0d69d'
|
||||||
|
Rails.application.config.secret_token = Digest::SHA1.hexdigest(token)
|
||||||
|
@ -31,3 +31,5 @@ production:
|
|||||||
# heroku
|
# heroku
|
||||||
# uri: <%= ENV['MONGOHQ_URL'] %>
|
# uri: <%= ENV['MONGOHQ_URL'] %>
|
||||||
|
|
||||||
|
# bushido (mongohq_url will also work)
|
||||||
|
uri: <%= ENV['MONGODB_URL'] %>
|
||||||
|
@ -9,6 +9,7 @@ require 'locomotive/liquid'
|
|||||||
require 'locomotive/mongoid'
|
require 'locomotive/mongoid'
|
||||||
require 'locomotive/carrierwave'
|
require 'locomotive/carrierwave'
|
||||||
require 'locomotive/heroku'
|
require 'locomotive/heroku'
|
||||||
|
require 'locomotive/bushido'
|
||||||
require 'locomotive/custom_fields'
|
require 'locomotive/custom_fields'
|
||||||
require 'locomotive/httparty'
|
require 'locomotive/httparty'
|
||||||
require 'locomotive/inherited_resources'
|
require 'locomotive/inherited_resources'
|
||||||
@ -24,6 +25,7 @@ require 'locomotive/session_store'
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
|
|
||||||
include Locomotive::Heroku
|
include Locomotive::Heroku
|
||||||
|
include Locomotive::BushidoSupport
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :config
|
attr_accessor :config
|
||||||
@ -51,9 +53,12 @@ module Locomotive
|
|||||||
:key => Locomotive.config.cookie_key
|
:key => Locomotive.config.cookie_key
|
||||||
}
|
}
|
||||||
|
|
||||||
# Heroku support
|
# Hosting-platform support
|
||||||
self.enable_heroku if self.heroku?
|
self.enable_heroku if self.heroku?
|
||||||
|
|
||||||
|
# Bushido support
|
||||||
|
self.enable_bushido if self.bushido?
|
||||||
|
|
||||||
# Devise
|
# Devise
|
||||||
Devise.mailer_sender = self.config.mailer_sender
|
Devise.mailer_sender = self.config.mailer_sender
|
||||||
|
|
||||||
|
69
lib/locomotive/bushido.rb
Normal file
69
lib/locomotive/bushido.rb
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
require 'bushido'
|
||||||
|
require 'locomotive/bushido/custom_domain'
|
||||||
|
|
||||||
|
module Locomotive
|
||||||
|
module BushidoSupport
|
||||||
|
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
class << self
|
||||||
|
attr_accessor :bushido_domains
|
||||||
|
attr_accessor :bushido_subdomain
|
||||||
|
|
||||||
|
puts @bushido_domains
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module ClassMethods
|
||||||
|
|
||||||
|
def bushido?
|
||||||
|
ENV["HOSTING_PLATFORM"] == "bushido"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def enable_bushido
|
||||||
|
self.enhance_site_model
|
||||||
|
|
||||||
|
self.bushido_domains = Bushido::App.domains
|
||||||
|
self.bushido_subdomain = Bushido::App.subdomain
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def enhance_site_model
|
||||||
|
Site.send :include, Locomotive::BushidoSupport::CustomDomain
|
||||||
|
end
|
||||||
|
|
||||||
|
# manage domains
|
||||||
|
|
||||||
|
def add_bushido_domain(name)
|
||||||
|
Locomotive.logger "[add bushido domain] #{name}"
|
||||||
|
Bushido::App.add_domain(name)
|
||||||
|
|
||||||
|
if Bushido::Command.last_command_successful?
|
||||||
|
self.bushido_domains << name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def remove_bushido_domain(name)
|
||||||
|
Locomotive.logger "[remove bushido domain] #{name}"
|
||||||
|
Bushido::App.remove_domain(name)
|
||||||
|
|
||||||
|
if Bushido::Command.last_command_successful?
|
||||||
|
self.bushido_domains.delete(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def set_bushido_subdomain(name)
|
||||||
|
Locomotive.logger "[set bushido subdomain] #{name}.bushi.do"
|
||||||
|
Bushido::App.set_subdomain(name)
|
||||||
|
|
||||||
|
if Bushido::Command.last_command_successful?
|
||||||
|
self.bushido_subdomain = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
52
lib/locomotive/bushido/custom_domain.rb
Normal file
52
lib/locomotive/bushido/custom_domain.rb
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
module Locomotive
|
||||||
|
module BushidoSupport
|
||||||
|
module CustomDomain
|
||||||
|
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
|
||||||
|
after_save :add_bushido_domains
|
||||||
|
after_destroy :remove_bushido_domains
|
||||||
|
|
||||||
|
alias_method_chain :add_subdomain_to_domains, :bushido
|
||||||
|
end
|
||||||
|
|
||||||
|
module InstanceMethods
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def add_subdomain_to_domains_with_bushido
|
||||||
|
unless self.domains_change.nil?
|
||||||
|
full_subdomain = "#{self.subdomain}.#{Locomotive.config.default_domain}"
|
||||||
|
@bushido_domains_change = {
|
||||||
|
:added => self.domains_change.last - self.domains_change.first - [full_subdomain],
|
||||||
|
:removed => self.domains_change.first - self.domains_change.last - [full_subdomain]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
add_subdomain_to_domains_without_bushido
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_bushido_domains
|
||||||
|
return if @bushido_domains_change.nil?
|
||||||
|
|
||||||
|
@bushido_domains_change[:added].each do |name|
|
||||||
|
Locomotive.add_bushido_domain(name)
|
||||||
|
end
|
||||||
|
@bushido_domains_change[:removed].each do |name|
|
||||||
|
Locomotive.remove_bushido_domain(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_bushido_domains
|
||||||
|
self.domains_without_subdomain.each do |name|
|
||||||
|
Locomotive.remove_bushido_domain(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -11,6 +11,7 @@ module Locomotive
|
|||||||
:cookie_key => '_locomotive_session',
|
:cookie_key => '_locomotive_session',
|
||||||
:enable_logs => false,
|
:enable_logs => false,
|
||||||
:heroku => false,
|
:heroku => false,
|
||||||
|
:bushido => false,
|
||||||
:delayed_job => true,
|
:delayed_job => true,
|
||||||
:default_locale => :en,
|
:default_locale => :en,
|
||||||
:mailer_sender => 'support@example.com'
|
:mailer_sender => 'support@example.com'
|
||||||
|
@ -15,6 +15,7 @@ require 'custom_fields'
|
|||||||
require 'mimetype_fu'
|
require 'mimetype_fu'
|
||||||
require 'actionmailer_with_request'
|
require 'actionmailer_with_request'
|
||||||
require 'heroku'
|
require 'heroku'
|
||||||
|
require 'bushido'
|
||||||
require 'httparty'
|
require 'httparty'
|
||||||
require 'redcloth'
|
require 'redcloth'
|
||||||
require 'delayed_job_mongoid'
|
require 'delayed_job_mongoid'
|
||||||
|
15
lib/tasks/bushido.rake
Normal file
15
lib/tasks/bushido.rake
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
require 'bushido'
|
||||||
|
require 'jammit'
|
||||||
|
|
||||||
|
namespace :bushido do
|
||||||
|
desc "Prepare an app to run on the Bushido hosting platform, only called during the initial installation. Called just before booting the app."
|
||||||
|
task :install do
|
||||||
|
Jammit.package!
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Prepare an app to run on the Bushido hosting platform, called on every update. Called just before booting the app."
|
||||||
|
task :update do
|
||||||
|
Jammit.package!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user