Sha256: 7d74934c55af452b087e0e69491c955989bc533c5b660a36beba2293c8964244
Contents?: true
Size: 1.92 KB
Versions: 8
Compression:
Stored size: 1.92 KB
Contents
require 'edifice/helper' require 'edifice/form_model' require 'edifice/responder' module Edifice require 'edifice/railtie' if defined?(Rails) def self.install_js_files install_dir = ::Rails.application.paths.public.javascripts.first edifice_js_dir = File.join(File.dirname(__FILE__), 'public', 'javascripts', 'edifice') FileUtils.rm_r File.join(install_dir, 'edifice') FileUtils.cp_r edifice_js_dir, install_dir end module Controller def self.included(controller) controller.helper_method(:view_path, :view_path_normalized, :view_name, :view_name_normalized, :layout_name) unless (controller == ActionMailer::Base) controller.after_filter(:write_edifice_headers) controller.alias_method_chain(:_render_template, :edifice) end controller.class_eval do def self.responder Edifice::Responder end end end def _render_template_with_edifice(options) @view_path = options[:prefix] @view_name = options[:template] @layout = options[:layout] ? File.split(options[:layout]).last : nil _render_template_without_edifice(options) end def write_edifice_headers response.headers['x-edifice-view_path'] = view_path_normalized response.headers['x-edifice-view_name'] = view_name_normalized response.headers['x-edifice-layout'] = layout_name end def view_path (@view_path || 'no_controller').gsub('/', '_') end def view_path_normalized view_path.camelcase(:lower) end def view_name @view_name || 'no_view' end def view_name_normalized view_name.camelcase(:lower) end def layout_name @layout || 'no_layout' end end end ActionController::Base.send :include, Edifice::Controller # ActionMailer::Base.send :include, Edifice::Controller ActionView::Base.send :include, Edifice::Helper
Version data entries
8 entries across 8 versions & 1 rubygems