Class: Flexi::Generators::LayoutGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/flexi/layout/layout_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_nameObject (readonly)

Returns the value of attribute app_name.



11
12
13
# File 'lib/generators/flexi/layout/layout_generator.rb', line 11

def app_name
  @app_name
end

#container_classObject (readonly)

Returns the value of attribute container_class.



11
12
13
# File 'lib/generators/flexi/layout/layout_generator.rb', line 11

def container_class
  @container_class
end

Instance Method Details

#add_stylesheetsObject



24
25
26
27
28
29
30
31
32
# File 'lib/generators/flexi/layout/layout_generator.rb', line 24

def add_stylesheets
  copy_file 'layout.css', 'app/assets/stylesheets/layout.css'
  if File.exist?('app/assets/stylesheets/application.css')
    gsub_file "app/assets/stylesheets/application.css", " *= require_tree .\n", ""
    insert_into_file "app/assets/stylesheets/application.css", " *= require layout\n", :after => "bootstrap-theme\n"
  else
    copy_file "application.css", "app/assets/stylesheets/application.css"
  end
end

#copy_additional_filesObject



34
35
36
37
38
39
40
41
# File 'lib/generators/flexi/layout/layout_generator.rb', line 34

def copy_additional_files
  copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'
  copy_file 'error_messages_helper.rb', 'app/helpers/error_messages_helper.rb'
  copy_file '_flash.html.erb', 'app/views/shared/_flash.html.erb'
  template '_sidebar.html.erb', 'app/views/layouts/_sidebar.html.erb'
  template '_navbar.html.erb', 'app/views/layouts/_navbar.html.erb'
  copy_file '_user_dropdown.html.erb', 'app/views/layouts/_user_dropdown.html.erb'
end

#generate_layoutObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/flexi/layout/layout_generator.rb', line 13

def generate_layout
  app = ::Rails.application
  @app_name = app.class.to_s.split("::").first
  remove_file "app/views/layouts/#{layout_name}.html.erb"
  template "layout.html.erb", "app/views/layouts/#{layout_name}.html.erb"
  generate "controller", "#{dashboard_name} index"
  remove_file "app/views/#{dashboard_name}/index.html.erb"
  copy_file "#{dashboard_name}.html.erb", "app/views/dashboard/index.html.erb"
  route "root :to => '#{dashboard_name}#index'"
end