Manifest.manifest.init
LocalManifest::load JSON.parse(open(Rails.root + 'public/local_manifest.json').read)
LocalManifest.manifest.init
+ Manifest.manifest.init_after_load_manifest
+ Manifest.manifest.load_models_manifest
respond_to do |format|
format.html { redirect_to({:action => :index}) }
end
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require 'digest/md5'
-
+$: << './lib'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
-require 'manifest'
module Pettanr
VERSION = '0.6.2'
require 'operator'
require 'import_result'
require 'common'
+# define Peta::Item before load model.
require_dependency 'peta'
+# load Manifest(SystemResource.engine_resource) before config route
+require_dependency 'manifest'
# Initialize the rails application
+Manifest.manifest.init
Pettanr::Application.initialize!
-require_dependency 'manifest'
require_dependency 'local_manifest'
require_dependency 'locmare'
require_dependency 'editor'
-Manifest.manifest.init
LocalManifest.manifest.init
Manifest.manifest.init_after_load_manifest
Manifest.manifest.load_models_manifest
Pettanr::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
-#config.assets.precompile += %w( *.js )
+config.assets.precompile += %w( *.css *.js )
# Code is not reloaded between requests
config.cache_classes = true
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
- config.serve_static_assets = false
+config.serve_static_assets = true # false
# Compress JavaScripts and CSS
config.assets.compress = true
require_dependency "manifest/system_resource"
Manifest::load JSON.parse(open(File.expand_path('../../public/manifest.json', __FILE__)).read)
-Manifest.manifest.init
+Manifest.manifest.init if Rails.env == "development"
@items = ManifestBase.load_type_name_args(self, @global_json, 'items', ItemFactory)
@controllers = Controller.load(self, @global_json, 'controllers')
@models = Model.load(self, @global_json, 'models')
- #
- @items.each do |name, peta_manifest|
- peta_manifest.init_after_load_manifest
- end
end
def init_after_load_manifest
@system_resources.init
+ #
+ @items.each do |name, peta_manifest|
+ peta_manifest.init_after_load_manifest
+ end
end
def load_models_manifest
# Dynamic Methods
- def self._content?
- self.my_manifest.content_model
- end
-
- def self._owner_type
- self.my_manifest.owner_type
- end
-
- def self._owner_model
- self.parent_model
- end
-
- def self._owner_column
- self._owner_type.to_s + '_id'
- end
-
def self.load_manifest
super
+ return nil if self._skip_load?
# Class Methods
- ct = self._content?
+ ct = self.my_manifest.content_model
define_singleton_method("content?") do
ct
end
- ot = self._owner_type
+ ot = self.my_manifest.owner_type
define_singleton_method("owner_type") do
ot
end
- om = self._owner_model
+ om = self.parent_model
define_singleton_method("owner_model") do
om
end
- oc = self._owner_column
+ oc = self.owner_type.to_s + '_id'
define_singleton_method("owner_column") do
oc
end
def self.load_manifest
super
+ return nil if self._skip_load?
# Class Methods
pm = Manifest.manifest.models[self.my_peta.parent_model_name].classify
define_singleton_method("parent_model") do
def self.load_manifest
super
+ return nil if self._skip_load?
# Class Methods
# Instance Methods
define_method("element_items") do |element_model|
self.class.child_models.each do |element_model|
name = self.class.my_manifest.associations.child_element_name(element_model) + '_attributes'
hash[name] ||= {}
- self.element_items(element_model).each do |element|
+ e= self.class.child_models.map {|element_model|
+ self.element_items element_model
+ }.flatten
+
+ e.each do |element|
hash[name][element.post_attribute_key] = element.post_attributes opt
end
end
# Dynamic ClassMethods
- def self._valid_encode_columns
- self.my_manifest.valid_encode_columns
+ def self._dev?
+ Rails.env == "development"
+ end
+
+ def self._skip_load?
+ if self._dev?
+ return true unless self.my_manifest
+ return true unless Manifest.manifest.items
+ return true unless Manifest.manifest.models
+ end
+ false
end
def self.load_manifest
- return nil unless self.my_manifest
- vc = self._valid_encode_columns
+ return nil if self._skip_load?
+ vc = self.my_manifest.valid_encode_columns
define_singleton_method("valid_encode_columns") do
vc
end
before_validation :valid_encode
def self.my_peta
+ return nil unless Manifest.manifest.items
Manifest.manifest.items[self.item_name]
end
def self.my_manifest
+ return nil unless Manifest.manifest.models
Manifest.manifest.models[self.item_name]
end
def self.load_manifest
super
+ return nil if self._skip_load?
# Class Methods
pm = Manifest.manifest.models[self.my_peta.parent_model_name].classify
define_singleton_method("parent_model") do