bootstrappers2 4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +57 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +23 -0
  6. data/README.md +100 -0
  7. data/Rakefile +2 -0
  8. data/TODO.md +23 -0
  9. data/bin/bootstrappers +12 -0
  10. data/bootstrapers.gemspec +22 -0
  11. data/lib/bootstrapers.rb +5 -0
  12. data/lib/bootstrappers/actions.rb +35 -0
  13. data/lib/bootstrappers/app_builder.rb +102 -0
  14. data/lib/bootstrappers/generators/app_generator.rb +161 -0
  15. data/lib/bootstrappers/layout_actions.rb +88 -0
  16. data/lib/bootstrappers/version.rb +3 -0
  17. data/templates/Gemfile_additions +47 -0
  18. data/templates/README.md.erb +14 -0
  19. data/templates/application_controller_rb +28 -0
  20. data/templates/bootstrappers_gitignore +7 -0
  21. data/templates/bootstrappers_layout.html.erb.erb +53 -0
  22. data/templates/capistrano/Capfile +5 -0
  23. data/templates/capistrano/deploy/assets.rb +30 -0
  24. data/templates/capistrano/deploy_rb.erb +80 -0
  25. data/templates/common/_bootstrap_modal.html.erb +4 -0
  26. data/templates/common/_facebook_js.erb +9 -0
  27. data/templates/common/_footer.html.erb +10 -0
  28. data/templates/common/_google_analytics.html.erb +13 -0
  29. data/templates/common/_menu.html.erb +32 -0
  30. data/templates/common/_not_logined.js.erb +4 -0
  31. data/templates/common/_search_form.html.erb +5 -0
  32. data/templates/common/_user_nav.html.erb +27 -0
  33. data/templates/config_yml.erb +21 -0
  34. data/templates/initializers/seo_helper.rb +11 -0
  35. data/templates/javascripts/README +0 -0
  36. data/templates/javascripts/application.js +5 -0
  37. data/templates/mysql_database.yml.erb +12 -0
  38. data/templates/setting.rb +5 -0
  39. data/templates/stylesheets/application.css.scss +2 -0
  40. data/templates/stylesheets/bootstrap-override.css.scss +11 -0
  41. data/templates/stylesheets/bootstrap-setting.css.scss +3 -0
  42. data/templates/stylesheets/common.css.scss +29 -0
  43. data/templates/tasks/dev.rake +10 -0
  44. data/templates/welcome.html.erb +3 -0
  45. metadata +117 -0
@@ -0,0 +1,88 @@
1
+ module Bootstrappers
2
+ module LayoutActions
3
+
4
+ def readme
5
+ template 'README.md.erb', 'README.md'
6
+ end
7
+
8
+ def remove_public_index
9
+ remove_file 'public/index.html'
10
+ end
11
+
12
+ def remove_rails_logo_image
13
+ remove_file 'app/assets/images/rails.png'
14
+ end
15
+
16
+ def create_partials_directory
17
+ empty_directory 'app/views/application'
18
+ empty_directory 'app/views/pages'
19
+ empty_directory 'app/views/common'
20
+ end
21
+
22
+ def create_application_layout
23
+ template 'bootstrappers_layout.html.erb.erb',
24
+ 'app/views/layouts/application.html.erb',
25
+ :force => true
26
+ end
27
+
28
+ def create_common_javascripts
29
+ remove_file 'app/assets/javascripts/application.js'
30
+ directory 'javascripts', 'app/assets/javascripts'
31
+ end
32
+
33
+ def create_common_stylesheets
34
+ remove_file 'app/assets/stylesheets/application.css'
35
+ directory 'stylesheets', 'app/assets/stylesheets'
36
+ end
37
+
38
+ def create_common_partial
39
+ directory 'common', 'app/views/common'
40
+ end
41
+
42
+ def add_jquery_ui
43
+ inject_into_file 'app/assets/javascripts/application.js',
44
+ "//= require jquery-ui\n", :before => '//= require_tree .'
45
+ end
46
+
47
+ def add_bootstrap_js
48
+ inject_into_file 'app/assets/javascripts/application.js',
49
+ "//= require twitter/bootstrap/alert\n", :before => '//= require_tree .'
50
+ end
51
+
52
+ def add_custom_gems
53
+ additions_path = find_in_source_paths 'Gemfile_additions'
54
+ new_gems = File.open(additions_path).read
55
+ inject_into_file 'Gemfile', "\n#{new_gems}",
56
+ :after => /gem 'jquery-rails'/
57
+ end
58
+
59
+
60
+ def setup_stylesheets
61
+ copy_file 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.scss'
62
+ remove_file 'app/assets/stylesheets/application.css'
63
+ concat_file 'import_scss_styles', 'app/assets/stylesheets/application.css.scss'
64
+ end
65
+
66
+ def setup_root_route
67
+ template 'welcome.html.erb', 'app/views/pages/welcome.html.erb',:force => true
68
+ route "root :to => 'high_voltage/pages#show', :id => 'welcome'"
69
+ end
70
+
71
+
72
+ def customize_error_pages
73
+ meta_tags =<<-EOS
74
+ <meta charset='utf-8' />
75
+ <meta name='ROBOTS' content='NOODP' />
76
+ EOS
77
+ style_tags =<<-EOS
78
+ <link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
79
+ EOS
80
+ %w(500 404 422).each do |page|
81
+ inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
82
+ replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
83
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
84
+ end
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,3 @@
1
+ module Bootstrappers
2
+ VERSION = "4.0"
3
+ end
@@ -0,0 +1,47 @@
1
+ gem "seo_helper", "~> 1.0"
2
+ gem "open_graph_helper"
3
+
4
+ gem "rmagick"
5
+ gem "carrierwave"
6
+ gem "carrierwave-meta"
7
+
8
+ gem "settingslogic"
9
+
10
+ gem "anjlab-bootstrap-rails", ">= 2.2.2", :require => "bootstrap-rails"
11
+ gem "bootstrap_helper", ">= 4.2.2.1"
12
+ gem "simple_form", "~> 3.0.0.beta1"
13
+ gem "will_paginate", "3.0.3"
14
+
15
+ gem "high_voltage"
16
+
17
+ gem "airbrake"
18
+
19
+ gem "rvm-capistrano"
20
+
21
+ gem "omniauth"
22
+ gem "omniauth-facebook"
23
+ gem "auto-facebook", "0.1.rails4"
24
+
25
+
26
+ gem "hipchat"
27
+
28
+ # Cache
29
+ gem "dalli"
30
+
31
+ group :assets do
32
+ gem "compass-rails", :git => "git@github.com:Compass/compass-rails.git", :branch => "rails4"
33
+ end
34
+
35
+ group :development do
36
+ gem "capistrano"
37
+ gem "capistrano-ext"
38
+ gem "cape"
39
+ gem "binding_of_caller"
40
+ gem "better_errors"
41
+ gem "magic_encoding"
42
+ gem "annotate"
43
+ gem "powder"
44
+ gem "pry-nav"
45
+ gem "pry-remote"
46
+ end
47
+
@@ -0,0 +1,14 @@
1
+
2
+ ### Style Guides
3
+
4
+ * [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide)
5
+ * [Rails Style Guide](https://github.com/bbatsov/rails-style-guide)
6
+ * [Better Specs](http://betterspecs.org/)
7
+ * [Rails Best Practices](http://rails-bestpractices.com/)
8
+
9
+ ### Speedup Tips
10
+
11
+ * [Speed up the Rails Asset Pipeline precompile process](http://stackoverflow.com/questions/11390447/how-can-you-speed-up-the-rails-asset-pipeline-precompile-process/11390454#11390454)
12
+
13
+
14
+
@@ -0,0 +1,28 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def login_required
5
+ if current_user.blank?
6
+ respond_to do |format|
7
+ format.html {
8
+ authenticate_user!
9
+ }
10
+ format.js{
11
+ render :partial => "common/not_logined"
12
+ }
13
+ format.all {
14
+ head(:unauthorized)
15
+ }
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+
22
+ def require_is_admin
23
+ unless (current_user && current_user.admin?)
24
+ redirect_to root_path, :flash => { :error => "no permission" }
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,7 @@
1
+ *.DS_Store
2
+ *.swp
3
+ .env
4
+ public/uploads
5
+ vendor/bundler_gems
6
+ config/database.yml
7
+ config/config.yml
@@ -0,0 +1,53 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <%%= render_page_title_tag %>
5
+ <%%= render_page_description_meta_tag %>
6
+ <%%= render_page_keywords_meta_tag %>
7
+ <%%= render_page_image_link_tag %>
8
+ <%%= csrf_meta_tag %>
9
+
10
+ <%%= stylesheet_link_tag "application" %>
11
+
12
+ <%%= yield :stylesheets %>
13
+
14
+ <meta property="og:title" content="<%%= page_title || SeoHelper.configuration.site_name %>"/>
15
+ <meta property="og:description" content="<%%= page_description || SeoHelper.configuration.default_page_description %>"/>
16
+ <meta property="og:image:url" content="<%%= page_image || SeoHelper.configuration.default_page_image %>"/>
17
+
18
+ </head>
19
+
20
+ <%%= render_body_tag %>
21
+
22
+ <%%= render :partial => "common/menu" %>
23
+
24
+ <div class="container">
25
+
26
+ <%%= notice_message %>
27
+
28
+ <div class="content">
29
+ <div class="row">
30
+ <%%= yield %>
31
+ <%%= yield (:sidebar) %>
32
+ </div>
33
+
34
+ </div>
35
+
36
+ <%%= render :partial => "common/footer" %>
37
+ </div>
38
+
39
+
40
+
41
+
42
+
43
+ <%%= render :partial => "common/bootstrap_modal" %>
44
+ <%%= render :partial => "common/facebook_js" %>
45
+ <%%= render :partial => "common/google_analytics" %>
46
+
47
+ <%%= javascript_include_tag "application" %>
48
+
49
+ <%%= yield :javascripts %>
50
+
51
+
52
+ </body>
53
+ </html>
@@ -0,0 +1,5 @@
1
+ load 'deploy'
2
+ # Uncomment if you are using Rails' asset pipeline
3
+ load 'deploy/assets'
4
+ load 'config/deploy'
5
+ # load 'config/deploy/assets'
@@ -0,0 +1,30 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ # from https://github.com/AF83/capistrano-af83/blob/master/lib/capistrano/af83/deploy/assets.rb
4
+ set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
5
+
6
+ namespace :deploy do
7
+ namespace :assets do
8
+
9
+ desc <<-DESC
10
+ Run the asset precompilation rake task. You can specify the full path \
11
+ to the rake executable by setting the rake variable. You can also \
12
+ specify additional environment variables to pass to rake via the \
13
+ asset_env variable. The defaults are:
14
+
15
+ set :rake, "rake"
16
+ set :rails_env, "production"
17
+ set :asset_env, "RAILS_GROUPS=assets"
18
+ set :assets_dependencies, fetch(:assets_dependencies) + %w(config/locales/js)
19
+ DESC
20
+ task :precompile, :roles => :web, :except => { :no_release => true } do
21
+ from = source.next_revision(current_revision)
22
+ if capture("cd #{latest_release} && #{source.local.diff(from)} #{assets_dependencies.join ' '} | wc -l").to_i > 0
23
+ run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
24
+ else
25
+ logger.info "Skipping asset pre-compilation because there were no asset changes"
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,80 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ raw_config = File.read("config/config.yml")
4
+ APP_CONFIG = YAML.load(raw_config)
5
+
6
+ require "./config/boot"
7
+ require "bundler/capistrano"
8
+ require "rvm-capistrano"
9
+
10
+ default_environment["PATH"] = "/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin"
11
+
12
+ set :application, "<%= app_name %>"
13
+ set :repository, "git@github.com:example/#{application}.git"
14
+ set :deploy_to, "/home/apps/#{application}"
15
+
16
+ set :branch, "master"
17
+ set :scm, :git
18
+
19
+ set :user, "apps"
20
+ set :group, "apps"
21
+
22
+ set :deploy_to, "/home/apps/#{application}"
23
+ set :runner, "apps"
24
+ set :deploy_via, :remote_cache
25
+ set :git_shallow_clone, 1
26
+ set :use_sudo, false
27
+ set :rvm_ruby_string, '1.9.3'
28
+
29
+ set :hipchat_token, APP_CONFIG["production"]["hipchat_token"]
30
+ set :hipchat_room_name, APP_CONFIG["production"]["hipchat_room_name"]
31
+ set :hipchat_announce, false # notify users?
32
+
33
+ role :web, "<%= app_name %>.com" # Your HTTP server, Apache/etc
34
+ role :app, "<%= app_name %>.com" # This may be the same as your `Web` server
35
+ role :db, "<%= app_name %>.com" , :primary => true # This is where Rails migrations will run
36
+
37
+ set :deploy_env, "production"
38
+ set :rails_env, "production"
39
+ set :scm_verbose, true
40
+ set :use_sudo, false
41
+
42
+
43
+ namespace :deploy do
44
+
45
+ desc "Restart passenger process"
46
+ task :restart, :roles => [:web], :except => { :no_release => true } do
47
+ run "touch #{current_path}/tmp/restart.txt"
48
+ end
49
+ end
50
+
51
+
52
+ namespace :my_tasks do
53
+ task :symlink, :roles => [:web] do
54
+ run "mkdir -p #{deploy_to}/shared/log"
55
+ run "mkdir -p #{deploy_to}/shared/pids"
56
+
57
+ symlink_hash = {
58
+ "#{shared_path}/config/database.yml" => "#{release_path}/config/database.yml",
59
+ "#{shared_path}/config/s3.yml" => "#{release_path}/config/s3.yml",
60
+ "#{shared_path}/uploads" => "#{release_path}/public/uploads",
61
+ }
62
+
63
+ symlink_hash.each do |source, target|
64
+ run "ln -sf #{source} #{target}"
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+
71
+
72
+ namespace :remote_rake do
73
+ desc "Run a task on remote servers, ex: cap staging rake:invoke task=cache:clear"
74
+ task :invoke do
75
+ run "cd #{deploy_to}/current; RAILS_ENV=#{rails_env} bundle exec rake #{ENV['task']}"
76
+ end
77
+ end
78
+
79
+ after "deploy:finalize_update", "my_tasks:symlink"
80
+
@@ -0,0 +1,4 @@
1
+
2
+ <div id="modal-from-dom" class="modal hide fade">
3
+
4
+ </div>
@@ -0,0 +1,9 @@
1
+
2
+ <div id="fb-root"></div>
3
+ <script>(function(d, s, id) {
4
+ var js, fjs = d.getElementsByTagName(s)[0];
5
+ if (d.getElementById(id)) {return;}
6
+ js = d.createElement(s); js.id = id;
7
+ js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=<%= Setting.facebook_app_id%>";
8
+ fjs.parentNode.insertBefore(js, fjs);
9
+ }(document, 'script', 'facebook-jssdk'));</script>
@@ -0,0 +1,10 @@
1
+ <footer class="footer">
2
+ <%= render_list :class => "nav nav-pills pull-right" do |li|
3
+ #li << link_to( "Link1", "#")
4
+ #li << link_to( "Link2", "#")
5
+ #li << link_to( "Link3", "#")
6
+ #li << link_to( "Link4", "#")
7
+ end %>
8
+ <p class="copyright">Copyright @2012 <%= Setting.app_name %> All rights reserved.</p>
9
+
10
+ </footer>
@@ -0,0 +1,13 @@
1
+ <script type="text/javascript">
2
+
3
+ var _gaq = _gaq || [];
4
+ _gaq.push(['_setAccount', '<%= Setting.google_analytics_key %>']);
5
+ _gaq.push(['_trackPageview']);
6
+
7
+ (function() {
8
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
9
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
10
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
11
+ })();
12
+
13
+ </script>
@@ -0,0 +1,32 @@
1
+ <div class="navbar navbar-fixed-top ">
2
+ <div class="navbar-inner top ">
3
+ <div class="container">
4
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
5
+ <span class="icon-bar"></span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ </a>
9
+
10
+ <%= link_to(Setting.app_name, Setting.domain , :class => "brand" )%>
11
+
12
+ <%= render :partial => "common/search_form" %>
13
+
14
+
15
+
16
+ <div class="nav-collapse">
17
+
18
+ <%= render_list :class => "nav" do |li|
19
+ li << link_to("Link-1","#")
20
+ li << link_to("Link-2","#")
21
+ li << link_to("Link-3","#")
22
+ end %>
23
+
24
+ <%= render :partial => "common/user_nav"%>
25
+
26
+ </div>
27
+ </div>
28
+ </div>
29
+
30
+ <%= yield :submenu %>
31
+
32
+ </div>
@@ -0,0 +1,4 @@
1
+ if (confirm("Please login first, proceed?") )
2
+ {
3
+ window.location = "/users/sign_in";
4
+ }