fix some bugs about engine startup + add a generator to install assets into the parent app

This commit is contained in:
dinedine 2010-06-03 22:20:53 +02:00
parent 9e7d1d3a08
commit 9f20f56b1d
10 changed files with 58 additions and 51 deletions

View File

@ -12,6 +12,10 @@ h2. Strategy / Development status
We already developed a fully functional prototype in Rails 2.3.2 with both active record / mongomapper and it worked quite well. We are even using it for some client websites. We already developed a fully functional prototype in Rails 2.3.2 with both active record / mongomapper and it worked quite well. We are even using it for some client websites.
Now, our goal is to port our prototype to Rails 3 and migrate from mongomapper to mongoid. Besides, we put a lot of efforts to make it as robust as we can by writing better specs than we wrote for the prototype at first. Now, our goal is to port our prototype to Rails 3 and migrate from mongomapper to mongoid. Besides, we put a lot of efforts to make it as robust as we can by writing better specs than we wrote for the prototype at first.
h2. Installation
TODO
h2. Contact h2. Contact
Feel free to contact me at didier at nocoffee dot fr. Feel free to contact me at didier at nocoffee dot fr.

View File

@ -14,7 +14,16 @@ begin
Jeweler::Tasks.new do |gem| Jeweler::Tasks.new do |gem|
gem.name = "locomotive_cms" gem.name = "locomotive_cms"
gem.summary = "Locomotive cms engine" gem.summary = "Locomotive cms engine"
gem.files = Dir["Gemfile", "{lib}/**/*", "{app}/**/*", "{config}/**/*", gem.author = ['Didier Lafforgue']
gem.email = ["didier@nocoffee.fr"]
gem.date = Date.today
gem.description = "a brand new CMS system with super sexy UI and cool features"
gem.homepage = %q{http://github.com/did/locomotive}
gem.files = Dir[
"Gemfile",
"{lib}/**/*",
"{app}/**/*",
"{config}/**/*",
"{public}/stylesheets/**/*", "{public}/javascripts/**/*", "{public}/images/**/*", "{public}/stylesheets/**/*", "{public}/javascripts/**/*", "{public}/images/**/*",
"{vendor}/**/*"] "{vendor}/**/*"]
# other fields that would normally go in your gemspec # other fields that would normally go in your gemspec

View File

@ -1,3 +1,4 @@
require 'carrierwave'
require 'carrierwave/orm/mongoid' require 'carrierwave/orm/mongoid'
module CarrierWave module CarrierWave

View File

@ -1,3 +1,5 @@
require 'devise'
# Use this hook to configure devise mailer, warden hooks and so forth. The first # Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models. # four configuration values can also be set straight in your models.
Devise.setup do |config| Devise.setup do |config|

View File

@ -1,4 +1,5 @@
Formtastic::SemanticFormHelper.builder = MiscFormBuilder require 'formtastic'
Formtastic::SemanticFormHelper.builder = MiscFormBuilder
Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true

View File

@ -1,3 +1,5 @@
require 'mongoid'
File.open(File.join(Rails.root, 'config/database.yml'), 'r') do |f| File.open(File.join(Rails.root, 'config/database.yml'), 'r') do |f|
@settings = YAML.load(f)[Rails.env] @settings = YAML.load(f)[Rails.env]
end end

View File

@ -1,6 +1,8 @@
# Locomotive::Application.configure do if Rails.env.test?
# config.generators do |g| Locomotive::Application.configure do
# g.integration_tool :rspec config.generators do |g|
# g.test_framework :rspec g.integration_tool :rspec
# end g.test_framework :rspec
# end end
end
end

View File

@ -1,9 +1,11 @@
BOARD: BOARD:
- make an engine: x make an engine:
- move initializers to lib/... x move initializers to lib/...
- write doc about setting up the parent app - write doc about setting up the parent app
x helpers do not work x helpers do not work
- theme assets: disable version if not image
- deploy on Heroku
- refactoring: CustomFields::CustomField => CustomFields::Field - refactoring: CustomFields::CustomField => CustomFields::Field
- new types for custom field - new types for custom field
- file - file
@ -20,7 +22,7 @@ BACKLOG:
- cucumber features for admin pages - cucumber features for admin pages
- refactoring admin crud (pages + layouts + snippets) - refactoring admin crud (pages + layouts + snippets)
- deploy on Heroku - theme assets: disable version if not image
BUGS: BUGS:
- when assigning new layout, disabled parts show up :-( (js problem) - when assigning new layout, disabled parts show up :-( (js problem)

View File

@ -1,4 +1,4 @@
class LocomotiveGenerator < Rails::Generators::NamedBase class LocomotiveGenerator < Rails::Generators::Base
class_option :update, :type => :boolean, :default => false, class_option :update, :type => :boolean, :default => false,
:desc => "Just update public files, do not create seed" :desc => "Just update public files, do not create seed"
@ -11,25 +11,4 @@ class LocomotiveGenerator < Rails::Generators::NamedBase
exit(0) if options.update? exit(0) if options.update?
end end
# def invoke_model
# invoke "model", [name].concat(migration_columns),
# :timestamps => false, :test_framework => false, :migration => options.migration?
# end
#
# def add_model_config
# inject_into_class "app/models/#{file_name}.rb", class_name, <<-CONTENT
# include RailsMetrics::ORM::#{Rails::Generators.options[:rails][:orm].to_s.camelize}
# CONTENT
# end
#
# def add_application_config
# inject_into_class "config/application.rb", "Application", <<-CONTENT
# # Set rails metrics store
# config.rails_metrics.set_store = lambda { ::#{class_name} }
#
# CONTENT
# end
end end

View File

@ -1,11 +1,11 @@
puts "...Locomotive engine loaded" puts "...Locomotive engine loaded"
# require 'liquid' require 'liquid'
# require 'devise' require 'devise'
# require 'carrierwave' require 'carrierwave'
# require 'formtastic' require 'formtastic'
# require 'mongoid' require 'mongoid'
# require 'mongoid_acts_as_tree' require 'mongoid_acts_as_tree'
require File.dirname(__FILE__) + '/../../vendor/plugins/custom_fields/init.rb' require File.dirname(__FILE__) + '/../../vendor/plugins/custom_fields/init.rb'
@ -17,16 +17,21 @@ module Locomotive
ActionController::Base.helpers_path = path ActionController::Base.helpers_path = path
end end
initializer "locomotive.require_dependencies" do # initializer "locomotive.require_dependencies", :after => :initialize_dependency_mechanism do
require 'bundler' # require 'bundler'
gemfile = Bundler::Definition.from_gemfile(root.join('Gemfile')) # gemfile = Bundler::Definition.from_gemfile(root.join('Gemfile'))
specs = gemfile.dependencies.select do |d| #
d.name != 'jeweler' and (d.groups & [:default, :production]).any? # specs = gemfile.dependencies.select do |d|
end # !%w{jeweler rails}.include?(d.name) and (d.groups & [:default, :production]).any?
specs.collect { |s| s.autorequire || [s.name] }.flatten.each do |r| # end
require r # specs.collect { |s| s.autorequire || [s.name] }.flatten.each do |r|
end # puts "requiring #{r}"
end # require r
# end
#
# # gemify it soon
# require File.dirname(__FILE__) + '/../../vendor/plugins/custom_fields/init.rb'
# end
end end
end end