-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78783cc
commit b2805cd
Showing
27 changed files
with
77 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails/generators/active_record' | ||
|
||
module Occams | ||
module Generators | ||
class CmsGenerator < Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
include Thor::Actions | ||
|
||
source_root File.expand_path('../../../..', __dir__) | ||
|
||
def generate_migration | ||
destination = File.expand_path('db/migrate/01_create_cms.rb', destination_root) | ||
migration_dir = File.dirname(destination) | ||
destination = self.class.migration_exists?(migration_dir, 'create_cms') | ||
|
||
if destination | ||
puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m" | ||
else | ||
migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb' | ||
end | ||
end | ||
|
||
def generate_initializer | ||
copy_file 'config/initializers/occams.rb', | ||
'config/initializers/occams.rb' | ||
end | ||
|
||
def generate_railties_order | ||
application <<~RUBY | ||
# Ensuring that ActiveStorage routes are loaded before Occams's globbing | ||
# route. Without this file serving routes are inaccessible. | ||
config.railties_order = [ActiveStorage::Engine, :main_app, :all] | ||
RUBY | ||
end | ||
|
||
def generate_routing | ||
route_string = <<~RUBY | ||
occams_route :cms_admin, path: "/admin" | ||
# Ensure that this route is defined last | ||
occams_route :cms, path: "/" | ||
RUBY | ||
route route_string | ||
end | ||
|
||
def generate_cms_seeds | ||
directory 'db/cms_seeds', 'db/cms_seeds' | ||
end | ||
|
||
def generate_assets | ||
copy_file 'app/assets/javascripts/occams/admin/cms/custom.js', | ||
'app/assets/javascripts/occams/admin/cms/custom.js' | ||
copy_file 'app/assets/stylesheets/occams/admin/cms/custom.sass', | ||
'app/assets/stylesheets/occams/admin/cms/custom.sass' | ||
end | ||
|
||
def show_readme | ||
readme 'lib/generators/occams/cms/README' | ||
end | ||
|
||
def self.next_migration_number(dirname) | ||
ActiveRecord::Generators::Base.next_migration_number(dirname) | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters