bootstrappers2 4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 871dcf218d1399800dc578b19e85612a8935d786
4
+ data.tar.gz: f909804e7e1fa6ecc5e99a4052477d609e6882c6
5
+ SHA512:
6
+ metadata.gz: cedbfe65ac9d358100ff68fd422e18ec1128d40747f9c7e6e57c597b47cf3567e7a0919c82efc5c7ba24b11f21a7cde1c3020c2eb2a08b30f71ccd463f8afba8
7
+ data.tar.gz: c7f9830ce1d5ec655a501e2505da3211bfecf1c30f8da397ab578643feb471fc1a4d1eafa78002c2443e0f96367c2f8f05133a42fb15c53ac28d3b865c6dd23a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,57 @@
1
+ alpha
2
+
3
+ 0.2.2
4
+
5
+ change code for me .
6
+
7
+ the below code is copied from [xdite](http://github.com/xdite)
8
+
9
+ 0.2.1 (Apr 8, 2013)
10
+
11
+ * add hipchat
12
+ * add auto_facebook
13
+ * add admin?
14
+
15
+ 0.2.0.1 (Jan 25, 2013)
16
+ * fix email_sender
17
+ * upgrade to Rails 3.2.11
18
+
19
+ 0.2.0 (DEC 16, 2012)
20
+ * add lib/tasks
21
+ * fixing typo
22
+ * fixing deploy file
23
+ * update to bootstrap-helper 2.2.0
24
+ * update to bootstrap-helper 2.1.2.1
25
+ * remove newrelic_rpm
26
+ * rvm-capistrano
27
+ * replace devise.email_sender to Setting.email_sender
28
+ * add login_required to application_controller
29
+
30
+ 0.1.0 (Nov 12, 2012)
31
+ * add powder to Gemfile
32
+ * add capistrano-ext to Gemfile
33
+ * customized_error_pages
34
+ * add carrierwave, carrierwave-meta
35
+ * add open_graph_helper
36
+ * add capistrano deploy file
37
+ * add pry, pry-remote
38
+ * add Facebook like in menu bar
39
+ * add .social css & .group self clearfix
40
+
41
+ 0.0.9 (Nov 12, 2012)
42
+ * fix application.css double loading css
43
+ * bootstrap-helper bump to 2.1.2
44
+
45
+ 0.0.8 (Oct 12, 2012)
46
+ * fix db config replace problem
47
+
48
+ 0.0.7 (Oct 10, 2012)
49
+ * fix typo, add more guides
50
+
51
+ 0.0.6 (Oct 10, 2012)
52
+ * will ask your database config password first
53
+
54
+ 0.0.5 (Oct 8, 2012)
55
+ * announce project
56
+
57
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootstrappers.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2012 xdite
2
+ Copyright (c) 2010-2012 Mike Burns and thoughtbot, inc. ( from suspenders)
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,100 @@
1
+ # Bootstrappers
2
+
3
+ Bootstrappers is the base Rails application using Bootstrap template and other goodies.
4
+
5
+ ## Installation
6
+
7
+ First install the bootstrappers gem:
8
+
9
+ gem install bootstrappers
10
+
11
+ Then run:
12
+
13
+ $ bootstrappers project_name
14
+
15
+
16
+ ## Gemfile
17
+
18
+ To see the latest and greatest gems, look at Suspenders' template/Gemfile_additions, which will be appended to the default generated projectname/Gemfile.
19
+
20
+
21
+ It includes application gems like:
22
+
23
+ ### View / SCSS
24
+ * [Bootstrap SCSS](https://github.com/anjlab/bootstrap-rails)
25
+ * [Bootstrap Helper](https://github.com/xdite/bootstrap-helper)
26
+ * [SimpleForm](https://github.com/plataformatec/simple_form)
27
+ * [WillPaginate](https://github.com/mislav/will_paginate/)
28
+ * [Compass](http://compass-style.org/)
29
+
30
+ ### Photo Uplaod
31
+
32
+ * [CarrierWave](https://github.com/jnicklas/carrierwave)
33
+
34
+ ### Social / SEO
35
+
36
+ * [SeoHelper](https://github.com/techbang/seo_helper)
37
+ * [OpenGraphHelper](https://github.com/techbang/open_graph_helper)
38
+
39
+ ### Deploy
40
+
41
+ * [Capistrano](https://github.com/capistrano/capistrano)
42
+ * [Cape](https://github.com/njonsson/cape)
43
+ * [rvm-capistrano](https://github.com/wayneeseguin/rvm-capistrano)
44
+ * [Airbrake](https://github.com/airbrake/airbrake)
45
+ * [NewRelic RPM](https://github.com/newrelic/rpm)
46
+ * [Turbo Sprockets for Rails 3.2.x](https://github.com/ndbroadbent/turbo-sprockets-rails3) Speeds up your Rails 3 rake assets:precompile by only recompiling changed assets
47
+
48
+ ### CommandLine
49
+
50
+ * [Magic encoding](https://github.com/m-ryan/magic_encoding)
51
+ * [Annotate](https://github.com/ctran/annotate_models)
52
+ * [Settingslogic](https://github.com/binarylogic/settingslogic)
53
+ * [Pry](http://pryrepl.org/)
54
+
55
+ ### Dev Enviorments
56
+
57
+ * [Better Errors](https://github.com/charliesome/better_errors)
58
+
59
+ ## Remind
60
+
61
+ config/database.yml default setting:
62
+
63
+ ```
64
+ development: &default
65
+ adapter: mysql2
66
+ encoding: utf8
67
+ database: <%= app_name %>_development
68
+ host: localhost
69
+ username: root
70
+ password: ""
71
+ ```
72
+
73
+ but we still ask for your preferences
74
+
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create new Pull Request
83
+
84
+
85
+ ## Issues
86
+
87
+
88
+ If you have problems, please create a [Github issue](https://github.com/xdite/bootstrappers/issues).
89
+
90
+ ## Credits
91
+
92
+ Bootstrappers is maintained and funded by [@xdite](http://github.com/xdite)
93
+
94
+ some codes of bootstrappers were borrowed from [suspenders](https://github.com/thoughtbot/suspendersus)
95
+
96
+
97
+ License
98
+ -------
99
+
100
+ Bootstrappers is Copyright © 2012 xdite. It is free software, and may be redistributed under the terms specified in the LICENSE file.
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
data/TODO.md ADDED
@@ -0,0 +1,23 @@
1
+ ## TODO
2
+
3
+ * Search
4
+ - ransack
5
+ * Devise
6
+ - Login Form refactor
7
+ * Cancan
8
+ * Testing Tool
9
+ * Social
10
+ - google_plus_one_helper
11
+ * View Turtorial
12
+ - menu
13
+ - ajax
14
+ * <https://speakerdeck.com/ken_c_lo/zurui-design>
15
+ * carrierwave
16
+ - uploader template
17
+ * Capistrano
18
+ - multistage
19
+ * Amazon SES
20
+ * Caching
21
+ - add config.cache_store to dali
22
+ * Refactor Devise Views
23
+ * add admin to menu
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'bootstrappers', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'bootstrappers', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'bootstrappers', 'layout_actions'), File.dirname(__FILE__))
6
+ require File.expand_path(File.join('..', 'lib', 'bootstrappers', 'app_builder'), File.dirname(__FILE__))
7
+
8
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
9
+
10
+ Bootstrappers::AppGenerator.source_root templates_root
11
+ Bootstrappers::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
12
+ Bootstrappers::AppGenerator.start
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bootstrappers/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "bootstrappers2"
8
+ gem.version = Bootstrappers::VERSION
9
+ gem.authors = ["liuhui998"]
10
+ gem.email = ["liuhui998@gmail.com"]
11
+ gem.description = %q{ Bootstrappers is the base Rails application using Bootstrap template and other goodies.(many code copied from xdite) }
12
+ gem.summary = %q{ Bootstrappers is the base Rails application using Bootstrap template and other goodies. }
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'rails', '4.0.0'
21
+ gem.add_dependency 'bundler', '>= 1.1'
22
+ end
@@ -0,0 +1,5 @@
1
+ require "bootstrappers/version"
2
+
3
+ module Bootstrappers
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,35 @@
1
+ module Bootstrappers
2
+ module Actions
3
+ def concat_file(source, destination)
4
+ contents = IO.read(find_in_source_paths(source))
5
+ append_file destination, contents
6
+ end
7
+
8
+ def replace_in_file(relative_path, find, replace)
9
+ path = File.join(destination_root, relative_path)
10
+ contents = IO.read(path)
11
+ unless contents.gsub!(find, replace)
12
+ raise "#{find.inspect} not found in #{relative_path}"
13
+ end
14
+ File.open(path, "w") { |file| file.write(contents) }
15
+ end
16
+
17
+ def action_mailer_host(rails_env, host)
18
+ inject_into_file(
19
+ "config/environments/#{rails_env}.rb",
20
+ "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
21
+ :before => "\nend"
22
+ )
23
+ end
24
+
25
+ def download_file(uri_string, destination)
26
+ uri = URI.parse(uri_string)
27
+ http = Net::HTTP.new(uri.host, uri.port)
28
+ http.use_ssl = true if uri_string =~ /^https/
29
+ request = Net::HTTP::Get.new(uri.path)
30
+ contents = http.request(request).body
31
+ path = File.join(destination_root, destination)
32
+ File.open(path, "w") { |file| file.write(contents) }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,102 @@
1
+ module Bootstrappers
2
+ class AppBuilder < Rails::AppBuilder
3
+
4
+ include Bootstrappers::Actions
5
+ include Bootstrappers::LayoutActions
6
+
7
+
8
+ def raise_delivery_errors
9
+ replace_in_file 'config/environments/development.rb', 'raise_delivery_errors = false', 'raise_delivery_errors = true'
10
+ end
11
+
12
+ def add_common_rake_tasks
13
+ directory 'tasks', 'lib/tasks'
14
+ end
15
+
16
+ def add_devise_gem
17
+ inject_into_file 'Gemfile', "\ngem 'devise',:git => 'git@github.com:plataformatec/devise.git', :branch => 'rails4'",
18
+ :after => /gem 'jquery-rails'/
19
+ end
20
+
21
+ def create_capistrano_files
22
+ template 'capistrano/deploy_rb.erb', 'config/deploy.rb',:force => true
23
+ template 'capistrano/Capfile', 'Capfile',:force => true
24
+ empty_directory 'config/deploy'
25
+ directory 'capistrano/deploy', 'config/deploy'
26
+ end
27
+
28
+ def create_database
29
+ bundle_command 'exec rake db:create'
30
+ end
31
+
32
+ def generate_devise
33
+ generate 'devise:install'
34
+ generate 'devise User'
35
+ end
36
+
37
+ def generate_auto_facebook
38
+ generate 'auto_facebook:user'
39
+ generate 'auto_facebook:install'
40
+ end
41
+
42
+ def insert_admin_method_to_user
43
+ inject_into_file 'app/models/user.rb',
44
+ "\n\n def admin?\n Setting.admin_emails.include?(email)\n end\n", :after => '# attr_accessible :title, :body'
45
+ end
46
+
47
+ def replace_email_sender_for_devise
48
+ replace_in_file 'config/initializers/devise.rb', /config\.mailer_sender = \".+\"/ , "config.mailer_sender = Setting.email_sender"
49
+ end
50
+
51
+ def gitignore_files
52
+ concat_file 'bootstrappers_gitignore', '.gitignore'
53
+ ['app/models',
54
+ 'app/assets/images',
55
+ 'app/views/pages',
56
+ 'db/migrate',
57
+ 'log',
58
+ ].each do |dir|
59
+ empty_directory_with_keep_file dir
60
+ end
61
+ end
62
+
63
+ def init_git
64
+ run "git init"
65
+ end
66
+
67
+
68
+ def build_settings_from_config
69
+
70
+ template 'setting.rb', 'app/models/setting.rb',:force => true
71
+ template 'config_yml.erb', 'config/config.yml',:force => true
72
+ template 'config_yml.erb', 'config/config.yml.example',:force => true
73
+ end
74
+
75
+ def create_initializers
76
+ directory 'initializers', 'config/initializers'
77
+ end
78
+
79
+ def add_common_method_to_application_controller
80
+ template 'application_controller_rb', 'app/controllers/application_controller.rb',:force => true
81
+ end
82
+
83
+
84
+ def remove_routes_comment_lines
85
+ replace_in_file 'config/routes.rb', /Application\.routes\.draw do.*end/m, "Application.routes.draw do\nend"
86
+ end
87
+
88
+ def use_mysql_config_template
89
+ template 'mysql_database.yml.erb', 'config/database.yml',:force => true
90
+ template 'mysql_database.yml.erb', 'config/database.yml.example', :force => true
91
+
92
+ db_user_name = ask("What is your local database user name? [root]")
93
+ db_password = ask("What is your local database password? ['']")
94
+
95
+ replace_in_file 'config/database.yml', 'username: root', "username: #{db_user_name}" if db_user_name.present?
96
+ replace_in_file 'config/database.yml', 'password: ""', "password: '#{db_password}'" if db_password.present?
97
+
98
+ end
99
+
100
+
101
+ end
102
+ end
@@ -0,0 +1,161 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+
5
+ module Bootstrappers
6
+ class AppGenerator < Rails::Generators::AppGenerator
7
+
8
+ class_option :database, :type => :string, :aliases => '-d', :default => 'mysql',
9
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
10
+
11
+ def finish_template
12
+ invoke :bootstrappers_customization
13
+ super
14
+ end
15
+
16
+ def bootstrappers_customization
17
+ invoke :remove_files_we_dont_need
18
+ invoke :setup_development_environment
19
+ invoke :create_bootstrappers_views
20
+ invoke :create_common_partial
21
+ invoke :create_common_javascripts
22
+ invoke :create_common_stylesheets
23
+ invoke :add_common_js_library
24
+ invoke :add_common_rake_tasks
25
+ invoke :customize_gemfile
26
+ invoke :setup_capistrano
27
+ invoke :setup_database
28
+ invoke :configure_app
29
+ invoke :create_initializers
30
+ invoke :remove_routes_comment_lines
31
+ invoke :add_common_method_to_application_controller
32
+ invoke :setup_root_route
33
+ invoke :setup_git
34
+ end
35
+
36
+ def remove_files_we_dont_need
37
+ build :remove_public_index
38
+ build :remove_rails_logo_image
39
+ end
40
+
41
+ def setup_development_environment
42
+ say 'Setting up the development environment'
43
+ build :raise_delivery_errors
44
+ end
45
+
46
+ def create_bootstrappers_views
47
+ say 'Creating bootstrappers views'
48
+ build :create_partials_directory
49
+ build :create_application_layout
50
+ end
51
+
52
+ def create_common_partial
53
+ say 'Pulling in some common partials'
54
+ build :create_common_partial
55
+ end
56
+
57
+ def create_common_javascripts
58
+ say 'Pulling in some common javascripts'
59
+ build :create_common_javascripts
60
+ end
61
+
62
+ def create_common_stylesheets
63
+ say 'Pulling in some common stylesheets'
64
+ build :create_common_stylesheets
65
+ end
66
+
67
+ def add_common_js_library
68
+ say 'Add coomon javascripts to the standard application.js'
69
+ end
70
+
71
+ def add_common_rake_tasks
72
+ say 'Add common rake tasks'
73
+ build :add_common_rake_tasks
74
+ end
75
+
76
+ def customize_gemfile
77
+ build :add_custom_gems
78
+ build :add_devise_gem
79
+ bundle_command 'install'
80
+ end
81
+
82
+ def setup_capistrano
83
+ build :create_capistrano_files
84
+ say 'Setting up capinstrano'
85
+ end
86
+
87
+ def setup_database
88
+ say 'Setting up database'
89
+
90
+ if 'mysql' == options[:database]
91
+ build :use_mysql_config_template
92
+ end
93
+
94
+ build :create_database
95
+ end
96
+
97
+ def configure_app
98
+ say 'Configuring app'
99
+ build :setup_devise
100
+ build :build_auto_facebook
101
+ build :build_settings_from_config
102
+ build :build_admin_method_to_user
103
+ end
104
+
105
+ def create_initializers
106
+ say 'create_initializers'
107
+ build :create_initializers
108
+ end
109
+
110
+ def setup_devise
111
+ build :generate_devise
112
+ build :replace_email_sender_for_devise
113
+ end
114
+
115
+ def build_auto_facebook
116
+ build :generate_auto_facebook
117
+ end
118
+
119
+ def build_admin_method_to_user
120
+ build :insert_admin_method_to_user
121
+ end
122
+
123
+ def customize_error_pages
124
+ say 'Customizing the 500/404/422 pages'
125
+ build :customize_error_pages
126
+ end
127
+
128
+ def remove_routes_comment_lines
129
+ build :remove_routes_comment_lines
130
+ end
131
+
132
+ def add_common_method_to_application_controller
133
+ build :add_common_method_to_application_controller
134
+ end
135
+
136
+ def setup_root_route
137
+ build :setup_root_route
138
+ end
139
+
140
+ def setup_git
141
+ say 'Initializing git'
142
+ invoke :setup_gitignore
143
+ invoke :init_git
144
+ end
145
+
146
+ def setup_gitignore
147
+ build :gitignore_files
148
+ end
149
+
150
+ def init_git
151
+ build :init_git
152
+ end
153
+
154
+ protected
155
+
156
+ def get_builder_class
157
+ Bootstrappers::AppBuilder
158
+ end
159
+
160
+ end
161
+ end