Class: Shoestrap::CmsGenerator
Instance Method Summary
collapse
shoestrap_logger, #source_paths
Instance Method Details
#add_controller ⇒ Object
54
55
56
57
|
# File 'lib/generators/shoestrap/cms_generator.rb', line 54
def add_controller
generate 'controller', controller_name, " --controller-specs=no --view-specs=no"
gsub_file "app/controllers/#{controller_name}_controller.rb", 'ApplicationController', 'Shoestrap::BaseController'
end
|
#add_model_and_migration ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/generators/shoestrap/cms_generator.rb', line 30
def add_model_and_migration
generate 'model', model_name, ARGV[1..-1].join(' ')
inject_into_file "app/models/#{model_name}.rb", before: 'class' do
"require 'shoestrap/cms_model'\n\n"
end
inject_into_file "app/models/#{model_name}.rb", before: 'end' do
<<-eos.gsub(/^ {8}/, '').chomp
include Shoestrap::CMSModel
# TODO: Define what attributes are shown in the form and permitted by strong parameters
editable_attributes #{attribute_keys_as_string}
# TODO: Define what attributes are shown in the index view
index_attributes #{attribute_keys_as_string}
eos
end
end
|
#add_navigation_link ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/generators/shoestrap/cms_generator.rb', line 22
def add_navigation_link
if kuhsaft_is_installed?
inject_into_file 'config/cms_navigation.rb', :before => 'primary.dom_class = \'nav\'' do
"primary.item :#{model_name}_nav, t('cms.#{plural_name}.navigation_title'), #{route_name}_path\n "
end
end
end
|
#add_resource_translations ⇒ Object
50
51
52
|
# File 'lib/generators/shoestrap/cms_generator.rb', line 50
def add_resource_translations
template 'translations/resource.yml.erb', "config/locales/de/#{model_name}.yml"
end
|
#add_route ⇒ Object
18
19
20
|
# File 'lib/generators/shoestrap/cms_generator.rb', line 18
def add_route
generate 'resource_route', resource_route_name
end
|
#set_up_shoestrap_cms ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/generators/shoestrap/cms_generator.rb', line 9
def set_up_shoestrap_cms
unless shoestrap_cms_already_installed?
setup_base_controller
setup_base_views
setup_navigation
setup_translation_file
end
end
|