Class: Fullstack::Cms::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Fullstack::Cms::InstallGenerator
- Defined in:
- lib/generators/fullstack/cms/install_generator.rb
Instance Method Summary collapse
- #assets ⇒ Object
- #home_page_helper ⇒ Object
- #install_fullstack_admin ⇒ Object
- #install_libraries ⇒ Object
- #install_migrations ⇒ Object
- #install_settings ⇒ Object
- #routes_rb ⇒ Object
- #set_localization ⇒ Object
- #templates_tree ⇒ Object
Instance Method Details
#assets ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 36 def assets append_to_file "config/assets.yml" do "\n- site/site.css\n- site/site.js \n" end end |
#home_page_helper ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 95 def home_page_helper append_to_file "app/helpers/application_helper.rb", :after => "ApplicationHelper" do %q{ def home_page? controller_name == "site" && action_name == "home" end } end end |
#install_fullstack_admin ⇒ Object
12 13 14 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 12 def install_fullstack_admin generate "fullstack:admin:install --host='#{host}' --user='#{user}' --title='#{title}' --slogan='#{slogan}'" end |
#install_libraries ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 16 def install_libraries generate "ars_permalink:install" generate "has_attached:install" generate "acts_as_taggable_on:migration" end |
#install_migrations ⇒ Object
109 110 111 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 109 def install_migrations generate "migration:from link menu page_part page redirect setting attachment photo text_page_part text_with_title_page_part" end |
#install_settings ⇒ Object
114 115 116 117 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 114 def install_settings append_to_file "config/settings.yml", "\n copyright: \"#{Date.today.year} - #{title}\"" end |
#routes_rb ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 47 def routes_rb src = ''' constraints(:host => /^#{Regexp.escape(Settings.app.domain)}/) do root :to => redirect("http://www.#{Settings.app.domain}") match "/*path", :to => redirect {|params, request| query_part = request.query_string.present? ? "?#{request.query_string}" : "" "http://www.#{Settings.app.domain}/#{params[:path]}#{query_part}" } end ''' if localize src << ''' # root :to => redirect("/#{I18n.default_locale}/") ''' end src << ''' # namespace :site, :path => "/" do # mount_controller "site" # end ''' route src end |
#set_localization ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 74 def set_localization if !localize inject_into_file "config/initializers/fullstack.rb", :after => "Fullstack::Cms.configure do |config|" do %q{ config.localized = false } end else inject_into_file "config/initializers/fullstack.rb", :after => "Fullstack::Cms.configure do |config|" do %q{ # config.localized = false } end end end |
#templates_tree ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/fullstack/cms/install_generator.rb', line 24 def templates_tree remove_file "public" remove_file "app/assets/javascripts/application.js" remove_file "app/assets/javascripts/application.css" remove_file "app/views/layouts/application.html.erb" remove_file "public/404.html" remove_file "public/robots.txt" remove_file "config/styles.yml" directory "rails", Rails.root end |