Sha256: a2108eefd997fcb6706689df28ff07970ba2b3704f3af1f4a51d0a0e2ed04dc8

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'bundler'

module Georgia
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)

      desc "Installs Georgia CMS:\n
        * Mounts routes\n
        * Copies initializer\n
        * Loads Migration\n
        * Runs Migration\n
        * Creates initial instances"

      def mount_engine
        # Must be in reverse order to keep priorities
        route "get '*request_path', to: 'pages#show', as: :page"
        route "root to: 'pages#show', request_path: 'home'"
        route "resources :messages, only: [:create]"
        route "mount Ckeditor::Engine => '/ckeditor'"
        route "mount Georgia::Engine => '/admin'"
      end

      def run_migrations
        rake "railties:install:migrations"
        rake "db:migrate"
      end

      def create_admin_user
        say("You're almost done. You need an admin user to get started.", :yellow)
        rake "georgia:seed"
      end

      def copy_templates
        copy_file "config/initializers/georgia.rb"
        copy_file "config/initializers/carrierwave.example.rb"
        copy_file "app/controllers/pages_controller.rb"
      end

      def add_default_indexer
        return if defined?(Sunspot)
        if !defined?(Tire)
          say("Adding Tire gem for Elasticsearch", :yellow)
          gem 'tire'
          Bundler.with_clean_env do
            run "bundle install"
          end
        end
        say("Creating elasticsearch indices", :yellow)
        rake "environment tire:import CLASS=Georgia::Page FORCE=true"
        rake "environment tire:import CLASS=Ckeditor::Asset FORCE=true"
        rake "environment tire:import CLASS=Ckeditor::Picture FORCE=true"
      end

      def show_readme
        readme "README"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.7.8 lib/generators/georgia/install/install_generator.rb