lib/abstract_interface.rb in crystal-ext-0.0.1 vs lib/abstract_interface.rb in crystal-ext-0.0.2
- old
+ new
@@ -1,59 +1,57 @@
+raise 'fuc'
+
+require 'abstract_interface/support'
require 'abstract_interface/haml_builder'
-require 'abstract_interface/model_stub'
+require 'abstract_interface/view_builder'
require 'abstract_interface/view_helper'
-require 'abstract_interface/support'
-ActionController::Base.class_eval do
- include AbstractInterface::ControllerHelper
- helper AbstractInterface::ViewHelper
-
- helper_method :themed_partial_exist?, :themed_partial, :current_theme
-end
+Crystal::TemplateContext.send :include, AbstractInterface::ViewHelper
-ActionView::Base.field_error_proc = lambda do |html_tag, instance|
- html_tag
-end
+# TODO2
+# ActionView::Base.field_error_proc = lambda do |html_tag, instance|
+# html_tag
+# end
module AbstractInterface
class << self
+ inject :logger => :logger, :config => :config
+
attr_accessor :plugin_name
attr_accessor :layout_configurations_dir
def generate_helper_methods *args
AbstractInterface::ViewBuilder.generate_helper_methods *args
end
def available_themes; @available_themes ||= [] end
-
- # Templates that should be wrapped if it doesn't defined for current theme
- # def dont_wrap_into_placeholder; @dont_wrap_into_placeholder ||= Set.new end
-
- # TODO 3 don't cache it becouse there's a lots of text data that will be reside in memory.
+
def theme_metadata theme
+ logger.warn "Complex calculation (AbstractInterface.theme_metadata) called in production!" if config.production?
+
metadata = {}
- fname = "#{AbstractInterface.themes_dir}/#{theme}/metadata.rb"
- if File.exist? fname
+
+ name = "#{dir}/#{Crystal::Template::DIRECTORY_NAME}/#{theme}/metadata.rb"
+ if Crystal::Environment.file_exist? name
+ fname = Crystal::Environment.find_file name
code = File.read fname
metadata = eval code
metadata.should! :be_a, Hash
end
+
metadata.to_openobject
end
- cache_with_params! :theme_metadata unless Rails.development?
- def themes_dir
- "#{RAILS_ROOT}/vendor/plugins/#{AbstractInterface.plugin_name.should_not_be!(:blank)}/app/views/themes"
- end
-
def layouts_defined?
!!layout_configurations_dir
end
def layout_definitions theme
- fname = "#{layout_configurations_dir.should_not_be!(:empty)}/#{theme}.yml"
- File.should! :exist?, fname
+ name = "#{layout_configurations_dir.should_not_be!(:empty)}/#{theme}.yml"
+ raise "File '#{name}' not exist!" unless Crystal::Environment.file_exist? name
+
+ fname = Crystal::Environment.find_file name
lds = YAML.load_file(fname)
validate_layout_definition!(lds, theme)
lds
end
cache_with_params! :layout_definitions unless Rails.development?
@@ -73,6 +71,7 @@
end
end
end
-Rails.development{RailsExt.create_public_symlinks!} # rails_ext.css, rails_ext.js in development mode
+# TODO1
+# Rails.development{RailsExt.create_public_symlinks!} # rails_ext.css, rails_ext.js in development mode
\ No newline at end of file