From 727a82474582ad6037cd2af8335217e62daafac1 Mon Sep 17 00:00:00 2001 From: dinedine Date: Thu, 16 Dec 2010 13:39:05 +0100 Subject: [PATCH] prepare locomotive as a gem --- Gemfile | 6 ++--- Gemfile.lock | 20 +++++++------- config/mongoid.yml | 13 +++++---- doc/TODO | 2 +- .../copy_assets/copy_assets_generator.rb | 14 ---------- .../locomotive/install/install_generator.rb | 24 ++++++++++------- .../locomotive/install/templates/README | 24 +++++++++-------- lib/locomotive/engine.rb | 22 ++++++++------- lib/locomotive/routing/site_dispatcher.rb | 1 + lib/locomotive/version.rb | 2 +- locomotive_cms.gemspec | 27 +++++++++++-------- 11 files changed, 78 insertions(+), 77 deletions(-) delete mode 100644 lib/generators/locomotive/copy_assets/copy_assets_generator.rb diff --git a/Gemfile b/Gemfile index 88336a1c..85260334 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'warden' gem 'devise', '= 1.1.3' gem 'mongoid', '2.0.0.beta.19' -gem 'bson_ext', '1.1.4' +gem 'bson_ext', '1.1.5' gem 'locomotive_mongoid_acts_as_tree', '0.1.5.1', :require => 'mongoid_acts_as_tree' gem 'will_paginate' @@ -27,8 +27,8 @@ gem 'actionmailer-with-request' gem 'heroku' gem 'httparty', '>= 0.6.1' gem 'RedCloth' -gem 'delayed_job', '2.1.0.pre2' -gem 'delayed_job_mongoid', '1.0.0.rc' +gem 'delayed_job', '2.1.2' +gem 'delayed_job_mongoid', '1.0.1' gem 'rubyzip' gem 'jammit-s3' diff --git a/Gemfile.lock b/Gemfile.lock index eafb11d7..29043c45 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,9 +7,9 @@ GIT GIT remote: http://github.com/ianwhite/pickle.git - revision: 55f2af5ff3f036f742605b34f5940ec663ff461a + revision: 02483df89b513a9598f73be500af96fe8a398dda specs: - pickle (0.4.3) + pickle (0.4.4) cucumber (>= 0.8) rake rspec (>= 1.3) @@ -53,7 +53,7 @@ GEM autotest (4.4.6) ZenTest (>= 4.4.1) bcrypt-ruby (2.1.2) - bson (1.1.4) + bson (1.1.5) bson_ext (1.1.4) builder (2.1.2) capybara (0.4.0) @@ -87,11 +87,11 @@ GEM mongoid (>= 2.0.0.beta.18) daemons (1.1.0) database_cleaner (0.6.0) - delayed_job (2.1.0.pre2) + delayed_job (2.1.2) activesupport (~> 3.0) daemons - delayed_job_mongoid (1.0.0.rc) - delayed_job (~> 2.1) + delayed_job_mongoid (1.0.1) + delayed_job (~> 2.1.1) mongoid (~> 2.0) devise (1.1.3) bcrypt-ruby (~> 2.1.2) @@ -99,7 +99,7 @@ GEM diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) - excon (0.3.3) + excon (0.3.4) factory_girl (1.3.2) factory_girl_rails (1.0) factory_girl (~> 1.3) @@ -125,7 +125,7 @@ GEM growl-glue (1.0.7) haml (3.0.18) has_scope (0.5.0) - heroku (1.14.8) + heroku (1.14.10) json_pure (>= 1.2.0, < 1.5.0) launchy (~> 0.3.2) rest-client (>= 1.4.0, < 1.7.0) @@ -267,8 +267,8 @@ DEPENDENCIES cucumber-rails custom_fields (= 1.0.0.beta2) database_cleaner - delayed_job (= 2.1.0.pre2) - delayed_job_mongoid (= 1.0.0.rc) + delayed_job (= 2.1.2) + delayed_job_mongoid (= 1.0.1) devise (= 1.1.3) factory_girl_rails fog (= 0.3.7) diff --git a/config/mongoid.yml b/config/mongoid.yml index cc850bec..c9ab9003 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -17,10 +17,9 @@ test: # set these environment variables on your prod server production: <<: *defaults - database: locomotive_dev - # <<: *defaults - # host: <%= ENV['MONGOID_HOST'] %> - # port: <%= ENV['MONGOID_PORT'] %> - # username: <%= ENV['MONGOID_USERNAME'] %> - # password: <%= ENV['MONGOID_PASSWORD'] %> - # database: <%= ENV['MONGOID_DATABASE'] %> \ No newline at end of file + database: locomotive_prod + host: <%= ENV['MONGOID_HOST'] %> + port: <%= ENV['MONGOID_PORT'] %> + username: <%= ENV['MONGOID_USERNAME'] %> + password: <%= ENV['MONGOID_PASSWORD'] %> + database: <%= ENV['MONGOID_DATABASE'] %> \ No newline at end of file diff --git a/doc/TODO b/doc/TODO index 2d78675b..2c318c4f 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,7 +1,7 @@ BOARD: x jammit-s3: assets -- copy assets.yml config file when using it as gem +- copy assets.yml config file when using it as gem (http://asciicasts.com/episodes/218-making-generators-in-rails-3) - import theme without delayed_job BACKLOG: diff --git a/lib/generators/locomotive/copy_assets/copy_assets_generator.rb b/lib/generators/locomotive/copy_assets/copy_assets_generator.rb deleted file mode 100644 index 5eb058f4..00000000 --- a/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Locomotive - class CopyAssetsGenerator < Rails::Generators::Base - - def self.source_root - @_locomotive_source_root ||= File.expand_path('../../../../../', __FILE__) - @_locomotive_source_root - end - - def copy_public_files - directory 'public', 'public', :recursive => true - end - - end -end diff --git a/lib/generators/locomotive/install/install_generator.rb b/lib/generators/locomotive/install/install_generator.rb index f2443a8a..d728fe57 100644 --- a/lib/generators/locomotive/install/install_generator.rb +++ b/lib/generators/locomotive/install/install_generator.rb @@ -1,21 +1,27 @@ module Locomotive class InstallGenerator < Rails::Generators::Base - def self.source_root - @_locomotive_source_root ||= File.expand_path('../templates', __FILE__) + source_root File.expand_path('../../../../../', __FILE__) + + def copy_mongoid_config + copy_file 'config/mongoid.yml', 'config/mongoid.yml' end + def copy_assets + directory 'public', 'public', :recursive => true + copy_file 'config/assets.yml', 'config/assets.yml' + end + def copy_initializer + @source_paths = nil # reset it for the find_in_source_paths method + + Locomotive::InstallGenerator.source_root(File.expand_path('../templates', __FILE__)) + template 'locomotive.rb', 'config/initializers/locomotive.rb' end - def seed_db - append_file 'db/seeds.rb', %{ -# Uncomment the following lines if you want to create the first website / account -#account = Account.create! :name => 'Admin', :email => 'admin@example.com', :password => 'locomotive', :password_confirmation => 'locomotive' -#site = Site.new :name => 'Locomotive test website', :subdomain => 'test' -#site.memberships.build :account => account, :admin => true -#site.save!} + def remove_index_html + remove_file 'public/index.html' end def show_readme diff --git a/lib/generators/locomotive/install/templates/README b/lib/generators/locomotive/install/templates/README index 2572a9ff..75662ffd 100644 --- a/lib/generators/locomotive/install/templates/README +++ b/lib/generators/locomotive/install/templates/README @@ -1,17 +1,19 @@ =============================================================================== -Locomotive initializer has been added to your application. Your db/seeds.rb file has also been updated. +The Locomotive initializer has been added to your application. - 1. Take a look at this to match your environment. - - 2. Uncomment added code in db/seeds.rb if necessary - -Note: do not forget to run rake db:seed if you modify your db/seeds.rb file. - -Once it is done, the next step is to install assets: + 1. Edit the config/initializers/locomotive.rb file (+ the config/mongoid.yml one) - bundle exec rails g locomotive:copy_assets - -Fire your application server and launch a browser ! + 2. Launch the server + + > unicorn_rails + + 3. Open your browser + + > open localhost:8080 + + 4. Follow the installation wizzard steps + + 5. Enjoy ! =============================================================================== \ No newline at end of file diff --git a/lib/locomotive/engine.rb b/lib/locomotive/engine.rb index 6efc5684..09ce0c6a 100644 --- a/lib/locomotive/engine.rb +++ b/lib/locomotive/engine.rb @@ -1,22 +1,24 @@ puts "...loading Locomotive engine" require 'rails' -require 'heroku' -require 'inherited_resources' -require 'mimetype_fu' -require 'liquid' require 'devise' -require 'carrierwave' -require 'formtastic' require 'mongoid' require 'mongoid_acts_as_tree' +require 'will_paginate' +require 'haml' +require 'liquid' +require 'formtastic' +require 'inherited_resources' +require 'carrierwave' +require 'custom_fields' +require 'mimetype_fu' +require 'actionmailer_with_request' +require 'heroku' require 'httparty' require 'redcloth' -require 'actionmailer_with_request' -require 'zip/zipfilesystem' -require 'custom_fields' require 'delayed_job_mongoid' -require 'will_paginate' +require 'zip/zipfilesystem' +require 'jammit' $:.unshift File.dirname(__FILE__) diff --git a/lib/locomotive/routing/site_dispatcher.rb b/lib/locomotive/routing/site_dispatcher.rb index 126621b3..01cba826 100644 --- a/lib/locomotive/routing/site_dispatcher.rb +++ b/lib/locomotive/routing/site_dispatcher.rb @@ -26,6 +26,7 @@ module Locomotive end def require_site + Locomotive.logger "[require_site] #{Account.count} account(s) / #{Site.count} site(s)" redirect_to admin_installation_url and return false if Account.count == 0 || Site.count == 0 render_no_site_error and return false if current_site.nil? diff --git a/lib/locomotive/version.rb b/lib/locomotive/version.rb index 8fc3bba0..82b2785d 100644 --- a/lib/locomotive/version.rb +++ b/lib/locomotive/version.rb @@ -1,3 +1,3 @@ module Locomotive #:nodoc - VERSION = "0.0.4.beta5" + VERSION = "0.0.4.beta6" end diff --git a/locomotive_cms.gemspec b/locomotive_cms.gemspec index 717191a3..a463fc22 100644 --- a/locomotive_cms.gemspec +++ b/locomotive_cms.gemspec @@ -18,28 +18,33 @@ Gem::Specification.new do |s| s.rubyforge_project = "nowarning" s.add_dependency "rails", ">= 3.0.0" - s.add_dependency "locomotive_liquid", "2.2.2" - s.add_dependency "bson_ext", "1.1.1" - s.add_dependency "mongoid", "2.0.0.beta.19" - s.add_dependency "locomotive_mongoid_acts_as_tree", "0.1.5.1" s.add_dependency "warden" s.add_dependency "devise", "= 1.1.3" + s.add_dependency "mongoid", "2.0.0.beta.19" + s.add_dependency "bson_ext", "1.1.5" + s.add_dependency "locomotive_mongoid_acts_as_tree", "0.1.5.1" + s.add_dependency "will_paginate" + s.add_dependency "haml", "= 3.0.18" + s.add_dependency "locomotive_liquid", "2.2.2" + s.add_dependency "formtastic", ">= 1.1.0" + s.add_dependency "inherited_resources", ">= 1.1.2" + + s.add_dependency "rmagick", "= 2.12.2" + s.add_dependency "locomotive_carrierwave", "0.5.0.1.beta2" + + s.add_dependency "custom_fields", "1.0.0.beta2" s.add_dependency "fog" s.add_dependency "mimetype-fu" - s.add_dependency "formtastic", ">= 1.1.0" - s.add_dependency "locomotive_carrierwave", "0.5.0.1.beta2" s.add_dependency "actionmailer-with-request" s.add_dependency "heroku" s.add_dependency "httparty", ">= 0.6.1" s.add_dependency "RedCloth" - s.add_dependency "inherited_resources", ">= 1.1.2" - s.add_dependency "delayed_job", "2.1.0.pre2" - s.add_dependency "delayed_job_mongoid", "1.0.0.rc" - s.add_dependency "custom_fields", "1.0.0.beta2" + s.add_dependency "delayed_job", "2.1.2" + s.add_dependency "delayed_job_mongoid", "1.0.1" s.add_dependency "rubyzip" - s.add_dependency "will_paginate" + s.add_dependency "jammit-s3" s.files = Dir[ "Gemfile", "{app}/**/*",