class Draft::LayoutGenerator
Public Instance Methods
generate_layout()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 9 def generate_layout if bootswatch? log :insert, "Adding #{theme_name.capitalize} Bootswatch" else log :insert, "Adding Bootstrap" end log :insert, "Adding Font Awesome" log :insert, "Adding navbar" log :insert, "Adding alerts" log :insert, "Adding sticky footer; you may need to add padding-bottom: 70px to the body of the document." template "layout.html.erb", "app/views/layouts/#{options["layout_file"]}.html.erb" template "_navbar.html.erb", "app/views/shared/_navbar.html.erb" template "_flashes.html.erb", "app/views/shared/_flashes.html.erb" template "_footer.html.erb", "app/views/shared/_footer.html.erb" unless skip_cdn? template "_bootstrapcdn_assets.html.erb", "app/views/shared/_bootstrapcdn_assets.html.erb" end end
Protected Instance Methods
app_resources()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 54 def app_resources models = ApplicationRecord.descendants.reject do |klass| if klass.name == "AdminUser" true else false end end models.collect { |clazz| clazz.name.underscore.pluralize } end
bootswatch?()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 40 def bootswatch? if theme_name.present? theme_name != "none" end end
devise_routes()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 65 def devise_routes route_names.map do |name| /new_(.*)_registration/.match(name) end.compact end
route_names()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 71 def route_names @route_names ||= Rails.application.routes.routes.map(&:name).uniq.compact end
skip_cdn?()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 50 def skip_cdn? options["skip_cdn"] end
theme_name()
click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 46 def theme_name options["theme"].downcase end