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.
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
Feel free to contact me at didier at nocoffee dot fr.

View File

@ -14,7 +14,16 @@ begin
Jeweler::Tasks.new do |gem|
gem.name = "locomotive_cms"
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/**/*",
"{vendor}/**/*"]
# other fields that would normally go in your gemspec

View File

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

View File

@ -1,3 +1,5 @@
require 'devise'
# 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.
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

View File

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

View File

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

View File

@ -1,9 +1,11 @@
BOARD:
- make an engine:
- move initializers to lib/...
x make an engine:
x move initializers to lib/...
- write doc about setting up the parent app
x helpers do not work
- theme assets: disable version if not image
- deploy on Heroku
- refactoring: CustomFields::CustomField => CustomFields::Field
- new types for custom field
- file
@ -20,7 +22,7 @@ BACKLOG:
- cucumber features for admin pages
- refactoring admin crud (pages + layouts + snippets)
- deploy on Heroku
- theme assets: disable version if not image
BUGS:
- 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,
:desc => "Just update public files, do not create seed"
@ -10,26 +10,5 @@ class LocomotiveGenerator < Rails::Generators::NamedBase
directory "../../public", "public", :recursive => true
exit(0) if options.update?
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

View File

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