OSDN Git Service

fix deploy
authoryasushiito <yas@pen-chan.jp>
Sat, 10 May 2014 10:24:00 +0000 (19:24 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 10 May 2014 10:24:00 +0000 (19:24 +0900)
app/controllers/system_controller.rb
config/application.rb
config/environment.rb
config/environments/production.rb
lib/manifest.rb
lib/manifest/manifest.rb
lib/peta/content.rb
lib/peta/element.rb
lib/peta/element_nestable_content.rb
lib/peta/item.rb
lib/peta/leaf.rb

index 59224a4..be48d47 100644 (file)
@@ -17,6 +17,8 @@ class SystemController < ApplicationController
     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
index 346cb0d..1fe4db4 100644 (file)
@@ -8,14 +8,13 @@ require "active_resource/railtie"
 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'
index 8edac06..559e03d 100644 (file)
@@ -9,14 +9,16 @@ require 'ar_helper'
 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
index cf85708..e359770 100644 (file)
@@ -1,6 +1,6 @@
 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
@@ -10,7 +10,7 @@ Pettanr::Application.configure do
   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
index 0319140..05262e7 100644 (file)
@@ -6,4 +6,4 @@ require_dependency "manifest/model"
 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"
index 12dce06..035a6e2 100644 (file)
@@ -19,14 +19,14 @@ module Manifest
       @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
index b6f094d..5ded097 100644 (file)
@@ -4,38 +4,23 @@ module Peta
     
     # 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
index 7f24d98..114cddd 100644 (file)
@@ -6,6 +6,7 @@ module Peta
     
     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 
index 3e58d09..2399998 100644 (file)
@@ -6,6 +6,7 @@ module Peta
     
     def self.load_manifest
       super
+      return nil if self._skip_load?
       # Class Methods
       # Instance Methods
       define_method("element_items") do |element_model|
@@ -35,7 +36,11 @@ module Peta
       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
index 7b991bb..938437d 100644 (file)
@@ -5,13 +5,22 @@ module Peta
     
     # 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
@@ -33,10 +42,12 @@ module Peta
     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
     
index 8510af5..ae16445 100644 (file)
@@ -6,6 +6,7 @@ module Peta
     
     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