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"

  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 52
def app_resources
  route_names.reject { |name| /^rails_info.*/.match(name) || /^rails_mailers.*/.match(name) || name.pluralize != name }
end
bootswatch?() click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 38
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 56
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 62
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 48
def skip_cdn?
  options["skip_cdn"]
end
theme_name() click to toggle source
# File lib/generators/draft/layout/layout_generator.rb, line 44
def theme_name
  options["theme"].downcase
end