Class: Hobo::AdminSubsiteGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Hobo::AdminSubsiteGenerator
- Includes:
- Generators::HoboSupport::EvalTemplate, classy_module do class_option :invite_only, :aliases => '-i', :type => :boolean, :desc => "Add features for an invite only website" private def invite_only? options[:invite_only] end end, classy_module do include Generatorsclassy_module do include Generators::Hoboclassy_module do include Generators::Hobo::InviteOnly include Generators::Hobo::Taglib # check_class_collision :suffix => 'SiteController' def move_and_generate_files if can_mv_application_to_front_site? say "Renaming app/views/taglibs/application.dryml to app/views/taglibs/front_site.dryml" unless options[:quiet] unless options[:pretend] FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml") copy_file "application.dryml", 'app/views/taglibs/application.dryml' end end template "site.scss.erb", File.join('app/assets/stylesheets', "#{file_name}.scss") copy_file "gitkeep", "app/assets/stylesheets/#{file_name}/.gitkeep" template "site.js.erb", File.join('app/assets/javascripts', "#{file_name}.js") copy_file "gitkeep", "app/assets/javascripts/#{file_name}/.gitkeep" template "controller.rb.erb", File.join('app/controllers', file_name, "#{file_name}_site_controller.rb") application "#" application "config.assets.precompile += %w(#{file_name}.css #{file_name}.js)" application "# Hobo: the #{file_name} subsite loads #{file_name}.css & #{file_name}.js" end private def subsite_name class_name end def can_mv_application_to_front_site? File.exist?('app/views/taglibs/application.dryml') && !File.exist?('app/views/taglibs/front_site.dryml') end end
- Defined in:
- lib/generators/hobo/admin_subsite/admin_subsite_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.banner ⇒ Object
14 15 16 |
# File 'lib/generators/hobo/admin_subsite/admin_subsite_generator.rb', line 14 def self. "rails generate hobo:admin_subsite [NAME=admin] [options]" end |
Instance Method Details
#generate_admin_user_controller ⇒ Object
18 19 20 21 22 23 |
# File 'lib/generators/hobo/admin_subsite/admin_subsite_generator.rb', line 18 def generate_admin_user_controller = {:subsite_controller_is_being_created => 1} .each{|k,v| [k] = v} invoke "hobo:controller", ["#{file_name}/#{[:user_resource_name].pluralize.underscore}"], template "users_index.dryml", "app/views/#{file_name}/#{[:user_resource_name].pluralize.underscore}/index.dryml" if invite_only? end |
#generate_site_taglib ⇒ Object
27 28 29 |
# File 'lib/generators/hobo/admin_subsite/admin_subsite_generator.rb', line 27 def generate_site_taglib invoke 'hobo:subsite_taglib', [name], .merge(:admin => true) end |