Sha256: 0daaad6c1a71c63f2c826618fb030c2ce5d0105bf650b17a6581cbdf1c81985b
Contents?: true
Size: 1.44 KB
Versions: 13
Compression:
Stored size: 1.44 KB
Contents
class LoadbehindGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) IMAGES=["error", "growl_bottom", "growl_repeat", "growl_top", "info"] JAVASCRIPTS=["loadbehind", "jquery.growl", "jquery.ajax.enhance"] def generate_loadbehind view_dir = "app/views/#{plural_name}" JAVASCRIPTS.each do |js| copy_file "#{js}.js", "public/javascripts/#{js}.js" end IMAGES.each do |image| copy_file "images/#{image}.png", "public/images/growl/#{image}.png" end ["index", "show"].each do |act| self.action_name = act template "view.js.haml", "#{view_dir}/#{action_name}.js.haml" end self.action_name = "show" template "view.js.haml", "#{view_dir}/update.js.haml" template "view.js.haml", "#{view_dir}/create.js.haml" ["edit", "new"].each do |act| self.action_name = 'form' template "edit.js.haml", "#{view_dir}/#{act}.js.haml" end ["destroy.js"].each do |file| template "#{file}.haml", "#{view_dir}/#{file}.haml" end puts "Add the following code to your layout..." JAVASCRIPTS.each do |j| puts " = javascript_include_tag \"#{j}.js\"" end puts "**** Remember to add loadbehind.js and jquery.growl.js to the javascript tags, or add it to your own js files. You'll also need to add handling to see that all your events are reconnected each time you reload. " end attr_accessor :action_name end
Version data entries
13 entries across 13 versions & 1 rubygems