Module: Bootstrappers::LayoutActions

Included in:
AppBuilder
Defined in:
lib/bootstrappers/layout_actions.rb

Instance Method Summary collapse

Instance Method Details

#add_bootstrap_jsObject



44
45
46
47
# File 'lib/bootstrappers/layout_actions.rb', line 44

def add_bootstrap_js
  inject_into_file 'app/assets/javascripts/application.js',
    "//= require twitter/bootstrap/alert\n", :before => '//= require_tree .'
end

#add_custom_gemsObject



49
50
51
52
53
54
# File 'lib/bootstrappers/layout_actions.rb', line 49

def add_custom_gems
  additions_path = find_in_source_paths 'Gemfile_additions'
  new_gems = File.open(additions_path).read
  inject_into_file 'Gemfile', "\n#{new_gems}",
  :after => /gem 'jquery-rails'/
end

#create_application_layoutObject



22
23
24
25
26
# File 'lib/bootstrappers/layout_actions.rb', line 22

def create_application_layout
  template 'bootstrappers_layout.html.erb.erb',
    'app/views/layouts/application.html.erb',
    :force => true
end

#create_common_javascriptsObject



28
29
30
31
# File 'lib/bootstrappers/layout_actions.rb', line 28

def create_common_javascripts
  remove_file 'app/assets/javascripts/application.js'
  directory 'javascripts', 'app/assets/javascripts'
end

#create_common_partialObject



38
39
40
# File 'lib/bootstrappers/layout_actions.rb', line 38

def create_common_partial
  directory 'common', 'app/views/common'
end

#create_common_stylesheetsObject



33
34
35
36
# File 'lib/bootstrappers/layout_actions.rb', line 33

def create_common_stylesheets
  remove_file 'app/assets/stylesheets/application.css'
  directory 'stylesheets', 'app/assets/stylesheets'
end

#create_partials_directoryObject



16
17
18
19
20
# File 'lib/bootstrappers/layout_actions.rb', line 16

def create_partials_directory
  empty_directory 'app/views/application'
  empty_directory 'app/views/pages'
  empty_directory 'app/views/common'
end

#customize_error_pagesObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/bootstrappers/layout_actions.rb', line 69

def customize_error_pages
  meta_tags =<<-EOS
  <meta charset='utf-8' />
  <meta name='ROBOTS' content='NOODP' />
  EOS
  style_tags =<<-EOS
  <link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
  EOS
  %w(500 404 422).each do |page|
    inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
    replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
    replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
  end
end

#readmeObject



4
5
6
# File 'lib/bootstrappers/layout_actions.rb', line 4

def readme
  template 'README.md.erb', 'README.md'
end

#remove_public_indexObject



8
9
10
# File 'lib/bootstrappers/layout_actions.rb', line 8

def remove_public_index
  remove_file 'public/index.html'
end

#remove_rails_logo_imageObject



12
13
14
# File 'lib/bootstrappers/layout_actions.rb', line 12

def remove_rails_logo_image
  remove_file 'app/assets/images/rails.png'
end

#setup_root_routeObject



63
64
65
66
# File 'lib/bootstrappers/layout_actions.rb', line 63

def setup_root_route
  template 'welcome.html.erb', 'app/views/pages/welcome.html.erb',:force => true
  route "root :to => 'high_voltage/pages#show', :id => 'welcome'"
end

#setup_stylesheetsObject



57
58
59
60
61
# File 'lib/bootstrappers/layout_actions.rb', line 57

def setup_stylesheets
  copy_file 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.scss'
  remove_file 'app/assets/stylesheets/application.css'
  concat_file 'import_scss_styles', 'app/assets/stylesheets/application.css.scss'
end