chr 0.3.5 → 0.4.9
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.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.gitignore +6 -1
- data/.ruby-version +1 -0
- data/.travis.yml +18 -0
- data/README.md +4 -0
- data/Rakefile +17 -2
- data/app/assets/javascripts/chr.coffee +13 -26
- data/app/assets/javascripts/chr/{core/chr.coffee → chr.coffee} +4 -1
- data/app/assets/javascripts/chr/{core/chr_router.coffee → chr_router.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/item.coffee → item.coffee} +2 -1
- data/app/assets/javascripts/chr/{core/list.coffee → list.coffee} +1 -1
- data/app/assets/javascripts/chr/{core/list_config.coffee → list_config.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/list_pagination.coffee → list_pagination.coffee} +15 -4
- data/app/assets/javascripts/chr/{core/list_reorder.coffee → list_reorder.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/list_search.coffee → list_search.coffee} +1 -1
- data/app/assets/javascripts/chr/{core/module.coffee → module.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/utils.coffee → utils.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/view.coffee → view.coffee} +21 -9
- data/app/assets/javascripts/chr/{core/view_local-storage.coffee → view_local-storage.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/array-store.coffee → stores/array.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/object-store.coffee → stores/object.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/rails-array-store.coffee → stores/rails-array.coffee} +0 -0
- data/app/assets/javascripts/{chr/store → stores}/rails-form-object-parser.coffee +4 -1
- data/app/assets/javascripts/{chr/store/rails-object-store.coffee → stores/rails-object.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/rest-array-store.coffee → stores/rest-array.coffee} +5 -2
- data/app/assets/javascripts/{chr/store/rest-object-store.coffee → stores/rest-object.coffee} +0 -0
- data/app/assets/stylesheets/{_chr.scss → chr.scss} +2 -7
- data/app/assets/stylesheets/chr/{_icons.scss → icons.scss} +0 -0
- data/app/assets/stylesheets/chr/{_main.scss → main.scss} +10 -3
- data/app/assets/stylesheets/chr/{_mixins.scss → mixins.scss} +0 -77
- data/app/assets/stylesheets/chr/{_settings.scss → settings.scss} +1 -1
- data/bin/chr +13 -0
- data/bin/rake +16 -0
- data/bin/setup +13 -0
- data/chr.gemspec +41 -21
- data/docs/tests.md +64 -0
- data/lib/chr.rb +10 -2
- data/lib/chr/app_builder.rb +385 -0
- data/lib/chr/generators/app_generator.rb +213 -0
- data/lib/chr/version.rb +3 -1
- data/lib/generators/chr/controller_generator.rb +18 -0
- data/templates/Gemfile.erb +38 -0
- data/templates/Procfile +1 -0
- data/templates/README.md.erb +45 -0
- data/templates/_analytics.html.erb +9 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +12 -0
- data/templates/application.coffee +2 -0
- data/templates/application.scss +1 -0
- data/templates/application.yml +6 -0
- data/templates/application_gitignore +14 -0
- data/templates/application_layout.html.erb.erb +29 -0
- data/templates/asset_sync.rb +28 -0
- data/templates/bin_setup.erb +36 -0
- data/templates/body_class_helper.rb +19 -0
- data/templates/bundler_audit.rake +12 -0
- data/templates/carrierwave.rb +23 -0
- data/templates/character_admin.coffee.erb +28 -0
- data/templates/character_admin.scss +3 -0
- data/templates/character_admin_index.html.erb +2 -0
- data/templates/character_admin_layout.html.erb +21 -0
- data/templates/character_base_controller.rb +16 -0
- data/templates/development_seeds.rb +12 -0
- data/templates/devise_overrides_passwords_controller.rb +10 -0
- data/templates/devise_overrides_passwords_edit.html.erb +30 -0
- data/templates/devise_overrides_passwords_new.html.erb +21 -0
- data/templates/devise_overrides_sessions_controller.rb +12 -0
- data/templates/devise_overrides_sessions_new.html.erb +31 -0
- data/templates/errors.rb +34 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/newrelic.yml.erb +34 -0
- data/templates/puma.rb +18 -0
- data/templates/routes.rb +90 -0
- data/templates/sample.env +6 -0
- data/templates/secrets.yml +14 -0
- data/templates/smtp.rb +9 -0
- data/templates/staging.rb +5 -0
- data/test/factories/article_factory.rb +19 -0
- data/test/files/test.jpg +0 -0
- data/test/integration/article_fullsize_test.rb +33 -0
- data/test/integration/article_test.rb +33 -0
- data/test/integration/magazine_article_test.rb +33 -0
- data/test/integration/restricted_article_test.rb +33 -0
- data/test/integration/sport_article_test.rb +34 -0
- data/test/rails_app/Rakefile +6 -0
- data/test/rails_app/app/assets/javascripts/admin.coffee +137 -0
- data/test/rails_app/app/assets/javascripts/application.js +1 -0
- data/test/rails_app/app/assets/stylesheets/admin.scss +1 -0
- data/test/rails_app/app/assets/stylesheets/application.css +1 -0
- data/test/rails_app/app/controllers/admin/articles_controller.rb +7 -0
- data/test/rails_app/app/controllers/admin/base_controller.rb +8 -0
- data/test/rails_app/app/controllers/application_controller.rb +5 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/models/article.rb +46 -0
- data/test/rails_app/app/uploaders/article_image_uploader.rb +16 -0
- data/test/rails_app/app/views/admin/index.html.erb +4 -0
- data/test/rails_app/app/views/layouts/admin.html.erb +17 -0
- data/test/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +8 -0
- data/test/rails_app/bin/rake +8 -0
- data/test/rails_app/bin/setup +29 -0
- data/test/rails_app/bin/spring +15 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +36 -0
- data/test/rails_app/config/boot.rb +3 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +38 -0
- data/test/rails_app/config/environments/production.rb +76 -0
- data/test/rails_app/config/environments/test.rb +46 -0
- data/test/rails_app/config/initializers/assets.rb +12 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/carrierwave.rb +5 -0
- data/test/rails_app/config/initializers/cookies_serializer.rb +3 -0
- data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app/config/initializers/inflections.rb +16 -0
- data/test/rails_app/config/initializers/mime_types.rb +4 -0
- data/test/rails_app/config/initializers/session_store.rb +3 -0
- data/test/rails_app/config/initializers/wrap_parameters.rb +9 -0
- data/test/rails_app/config/locales/en.yml +23 -0
- data/test/rails_app/config/mongoid.yml +9 -0
- data/test/rails_app/config/routes.rb +8 -0
- data/test/rails_app/config/secrets.yml +22 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/rails_app/public/404.html +67 -0
- data/test/rails_app/public/422.html +67 -0
- data/test/rails_app/public/500.html +66 -0
- data/{app/assets/javascripts/form/input-date.coffee → test/rails_app/public/favicon.ico} +0 -0
- data/test/rails_app/public/robots.txt +5 -0
- data/test/support/character_front_end.rb +196 -0
- data/test/support/chr/item.rb +32 -0
- data/test/support/chr/list.rb +31 -0
- data/test/support/chr/list_pagination.rb +163 -0
- data/test/support/chr/list_reorder.rb +46 -0
- data/test/support/chr/list_search.rb +41 -0
- data/test/support/chr/view.rb +112 -0
- data/test/support/stores/array.rb +20 -0
- data/test/support/stores/rest-array.rb +34 -0
- data/test/test_helper.rb +68 -0
- metadata +373 -80
- data/Gruntfile.coffee +0 -101
- data/app/assets/javascripts/form/expandable-group.coffee +0 -30
- data/app/assets/javascripts/form/form.coffee +0 -221
- data/app/assets/javascripts/form/input-checkbox.coffee +0 -83
- data/app/assets/javascripts/form/input-color.coffee +0 -55
- data/app/assets/javascripts/form/input-file.coffee +0 -144
- data/app/assets/javascripts/form/input-form.coffee +0 -171
- data/app/assets/javascripts/form/input-form_reorder.coffee +0 -67
- data/app/assets/javascripts/form/input-hidden.coffee +0 -57
- data/app/assets/javascripts/form/input-list.coffee +0 -154
- data/app/assets/javascripts/form/input-list_reorder.coffee +0 -39
- data/app/assets/javascripts/form/input-list_typeahead.coffee +0 -55
- data/app/assets/javascripts/form/input-password.coffee +0 -32
- data/app/assets/javascripts/form/input-select.coffee +0 -84
- data/app/assets/javascripts/form/input-select2.coffee +0 -33
- data/app/assets/javascripts/form/input-string.coffee +0 -160
- data/app/assets/javascripts/form/input-text.coffee +0 -43
- data/app/assets/javascripts/input-html.coffee +0 -81
- data/app/assets/javascripts/input-markdown.coffee +0 -93
- data/app/assets/javascripts/input-redactor.coffee +0 -1
- data/app/assets/javascripts/redactor/input-redactor.coffee +0 -53
- data/app/assets/javascripts/redactor/input-redactor_character.coffee +0 -83
- data/app/assets/javascripts/redactor/input-redactor_images.coffee +0 -166
- data/app/assets/javascripts/vendor/ace.js +0 -18280
- data/app/assets/javascripts/vendor/jquery.scrollparent.js +0 -14
- data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +0 -55
- data/app/assets/javascripts/vendor/jquery.typeahead.js +0 -1782
- data/app/assets/javascripts/vendor/marked.js +0 -1272
- data/app/assets/javascripts/vendor/mode-html.js +0 -2436
- data/app/assets/javascripts/vendor/mode-markdown.js +0 -2820
- data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +0 -107
- data/app/assets/javascripts/vendor/select2.js +0 -5274
- data/app/assets/stylesheets/_input-redactor.scss +0 -35
- data/app/assets/stylesheets/form/_expandable-group.scss +0 -16
- data/app/assets/stylesheets/form/_input-select2.scss +0 -94
- data/app/assets/stylesheets/form/_main.scss +0 -180
- data/app/assets/stylesheets/vendor/select2.css +0 -258
- data/bower.json +0 -38
- data/dist/chr.js +0 -5949
- data/dist/input-ace.js +0 -24946
- data/dist/input-redactor.js +0 -1
- data/lib/mongoid/character.rb +0 -30
- data/package.json +0 -10
|
@@ -8,7 +8,7 @@ $contrastColor: rgb(230,230,230) !default;
|
|
|
8
8
|
$white: rgb(255,255,255) !default;
|
|
9
9
|
$black: #333 !default;
|
|
10
10
|
|
|
11
|
-
$fontFamily: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
|
|
11
|
+
$fontFamily: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif !default;
|
|
12
12
|
|
|
13
13
|
/* Layouts ----------------------------------------------------------------- */
|
|
14
14
|
$tablet: "screen and (min-width:768px)";
|
data/bin/chr
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'pathname'
|
|
3
|
+
|
|
4
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
|
5
|
+
$LOAD_PATH << source_path
|
|
6
|
+
|
|
7
|
+
require 'chr'
|
|
8
|
+
|
|
9
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
|
10
|
+
Chr::AppGenerator.source_root templates_root
|
|
11
|
+
Chr::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
|
12
|
+
|
|
13
|
+
Chr::AppGenerator.start
|
data/bin/rake
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
# Run this script immediately after cloning the codebase.
|
|
4
|
+
|
|
5
|
+
# Exit if any subcommand fails
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Set up Ruby dependencies via Bundler
|
|
9
|
+
bundle install
|
|
10
|
+
|
|
11
|
+
# Add binstubs to PATH in ~/.zshenv like this:
|
|
12
|
+
# export PATH=".git/safe/../../bin:$PATH"
|
|
13
|
+
# mkdir -p .git/safe
|
data/chr.gemspec
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
2
|
$:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
require 'chr/version'
|
|
4
|
+
require 'date'
|
|
4
5
|
|
|
5
6
|
Gem::Specification.new do |s|
|
|
6
|
-
s.
|
|
7
|
-
|
|
8
|
-
s.
|
|
9
|
-
s.
|
|
10
|
-
s.
|
|
11
|
-
|
|
12
|
-
s.homepage = 'http://slatestudio.com'
|
|
13
|
-
s.summary = 'Powerful responsive javascript CMS for apps'
|
|
7
|
+
s.required_ruby_version = ">= #{Chr::RUBY_VERSION}"
|
|
8
|
+
|
|
9
|
+
s.authors = [ 'Alexander Kravets', 'Denis Popov', 'Roman Brazhnyk' ]
|
|
10
|
+
s.email = 'alex@slatestudio.com'
|
|
11
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
|
12
|
+
|
|
14
13
|
s.description = <<-DESC
|
|
15
14
|
Character is a library written in CoffeeScript with a help of jQuery that allows to
|
|
16
15
|
build data management web applications in a fast and flexible way, e.g. CMS, news reader,
|
|
17
16
|
email client etc. It's responsive by default and designed to be data source independent.
|
|
18
17
|
DESC
|
|
19
18
|
|
|
20
|
-
s.
|
|
21
|
-
|
|
19
|
+
s.name = 'chr'
|
|
20
|
+
s.summary = 'Powerful responsive javascript CMS for apps.'
|
|
21
|
+
s.homepage = 'http://github.com/slate-studio/chr'
|
|
22
|
+
s.license = 'MIT'
|
|
22
23
|
s.files = `git ls-files`.split("\n")
|
|
23
|
-
s.
|
|
24
|
-
|
|
25
|
-
s.
|
|
26
|
-
s.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
s.executables = [ 'chr' ]
|
|
25
|
+
s.require_paths = [ 'lib' ]
|
|
26
|
+
s.version = Chr::VERSION
|
|
27
|
+
s.platform = Gem::Platform::RUBY
|
|
28
|
+
|
|
29
|
+
s.add_dependency 'rails', Chr::RAILS_VERSION
|
|
30
|
+
s.add_dependency 'coffee-rails', '>= 4.0'
|
|
31
|
+
s.add_dependency 'jquery-rails'
|
|
32
|
+
s.add_dependency 'sass-rails'
|
|
33
|
+
s.add_dependency 'normalize-rails', '>= 3.0'
|
|
34
|
+
s.add_dependency 'bourbon', '>= 3.2'
|
|
35
|
+
s.add_dependency 'formagic', '>= 0.2.6'
|
|
36
|
+
|
|
37
|
+
# tests
|
|
38
|
+
s.add_development_dependency 'mongosteen', '~> 0.1.8'
|
|
39
|
+
s.add_development_dependency 'ants', '~> 0.2.1'
|
|
40
|
+
s.add_development_dependency 'loft', '~> 0.2.3'
|
|
41
|
+
|
|
42
|
+
s.add_development_dependency 'faker'
|
|
43
|
+
s.add_development_dependency 'coveralls'
|
|
44
|
+
s.add_development_dependency 'uglifier', '>= 1.3.0'
|
|
45
|
+
s.add_development_dependency 'database_cleaner', '1.0.1'
|
|
46
|
+
s.add_development_dependency 'factory_girl_rails'
|
|
47
|
+
s.add_development_dependency 'capybara-webkit'
|
|
48
|
+
s.add_development_dependency 'capybara-screenshot'
|
|
49
|
+
s.add_development_dependency 'selenium-webdriver'
|
|
50
|
+
s.add_development_dependency 'minitest-reporters'
|
|
51
|
+
|
|
52
|
+
end
|
data/docs/tests.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## Running Tests
|
|
2
|
+
|
|
3
|
+
rake test
|
|
4
|
+
|
|
5
|
+
#### Covered configs:
|
|
6
|
+
|
|
7
|
+
# disableNewItems: - do not show new item button in list header
|
|
8
|
+
# showWithParent: - show list on a aside from parent
|
|
9
|
+
# disableFormCache: - do disable cache
|
|
10
|
+
# searchable: - add search button
|
|
11
|
+
# reorderable: - permit reorder items
|
|
12
|
+
# disableDelete: - do not add delete button below the form
|
|
13
|
+
# disableSave: - do not add save button in header
|
|
14
|
+
# fullsizeView: - use fullsize layout in desktop mode
|
|
15
|
+
# urlParams: Article.sport_articles - additional parameter to be included into request
|
|
16
|
+
# sortReverse: - reverse objects sorting (descending order), default: false
|
|
17
|
+
# pagination: - add this, if there are many objects (add extra test)
|
|
18
|
+
|
|
19
|
+
# uploaderImage: - run tests, for checking uploader
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#### Tests structure:
|
|
23
|
+
|
|
24
|
+
`test/integration/..` - Each file it's presentation of Module with different config, for test all functionallity
|
|
25
|
+
`test/support/character_front_end` - Main module with logic and helper methods, depending of config running appropriate set of tests.
|
|
26
|
+
|
|
27
|
+
**Modules with tests:**
|
|
28
|
+
|
|
29
|
+
test/support/chr/...
|
|
30
|
+
test/support/stores/...
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#### Tests functions:
|
|
34
|
+
|
|
35
|
+
`show_item(factory_name, list_of_modules)` Generate module, item and item_form
|
|
36
|
+
`chage_title(factory_name, class_name, list_of_modules)` Change fileds of items, also changing Model
|
|
37
|
+
`add_item(factory_name, class_name, list_of_modules)` Create new object
|
|
38
|
+
`delete_item(factory_name, class_name, list_of_modules)` Delete object
|
|
39
|
+
`open_item_and_close(factory_name, list_of_modules)` Render item_form and close it
|
|
40
|
+
`search(factory_name, list_of_modules)` Generate search request, and check result
|
|
41
|
+
`search_and_close(factory_name, class_name, list_of_modules)` Generate search result, and reset it (check, that all items visible again)
|
|
42
|
+
`reorder(factory_name, class_name, list_of_modules)` Reorder objects by drag and drop (check that _position change, and rendering correct)
|
|
43
|
+
`show_with_parent(factory_name, list_of_modules)` Open item with showWithParent: true, check, that there are items and parent render on one page
|
|
44
|
+
`disable_new_item(factory_name, list_of_modules)` Render list without button "+"
|
|
45
|
+
`disable_delete(factory_name, list_of_modules)` Render View without button "delete"
|
|
46
|
+
`disable_save(factory_name, list_of_modules)` Render View without button "save"
|
|
47
|
+
`fullsize_view(factory_name, list_of_modules)` Render View with fullsizeView: true
|
|
48
|
+
`add_class_active(factory_name, list_of_modules)` Checking, that class active adding correctly.
|
|
49
|
+
`pagination(factory_name, class_name, list_of_modules)` Render list with many items, and scrolling to the buttom (checking for coreect download new pages)
|
|
50
|
+
`pagination_and_reorder(factory_name, class_name, list_of_modules)` Render list with many items, scrolling and reorder item on each page
|
|
51
|
+
`click_back(factory_name, list_of_modules)` Render last one of compound modules, click button "back"
|
|
52
|
+
**Checking Pagination:**
|
|
53
|
+
|
|
54
|
+
chage_position_to_end_and_check_pagination(factory_name, class_name, list_of_modules
|
|
55
|
+
chage_position_to_begin_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
56
|
+
chage_position_to_middle_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
57
|
+
create_first_item_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
58
|
+
create_last_item_on_page_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
59
|
+
|
|
60
|
+
`urlParams(factory_name, class_name, list_of_modules, config)` Checking, that in generated list only items from scope (urlParams:true)
|
|
61
|
+
`remove_from_scope(factory_name, class_name, list_of_modules, config)` Remove item from scope (urlParams:true)
|
|
62
|
+
`sortReverse_by_position(factory_name, class_name, list_of_modules)` Checking, that list render in reverse order
|
|
63
|
+
`add_image(factory_name, list_of_modules)` Upload image
|
|
64
|
+
`remove_image(factory_name, list_of_modules)` Remove image
|
data/lib/chr.rb
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'chr/version'
|
|
2
|
+
require 'chr/generators/app_generator'
|
|
3
|
+
require 'chr/app_builder'
|
|
4
|
+
|
|
5
|
+
require 'rails'
|
|
2
6
|
require 'bourbon'
|
|
7
|
+
require 'formagic'
|
|
8
|
+
require 'jquery-rails'
|
|
9
|
+
require 'coffee-rails'
|
|
10
|
+
require 'sass-rails'
|
|
11
|
+
require 'normalize-rails'
|
|
3
12
|
|
|
4
13
|
module Chr
|
|
5
14
|
if defined?(Rails) && defined?(Rails::Engine)
|
|
6
15
|
class Engine < ::Rails::Engine
|
|
7
16
|
require 'chr/engine'
|
|
8
|
-
require 'mongoid/character'
|
|
9
17
|
end
|
|
10
18
|
end
|
|
11
19
|
end
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
module Chr
|
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
|
3
|
+
|
|
4
|
+
def readme
|
|
5
|
+
template 'README.md.erb', 'README.md'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def replace_gemfile
|
|
10
|
+
remove_file 'Gemfile'
|
|
11
|
+
template 'Gemfile.erb', 'Gemfile'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def set_ruby_to_version_being_used
|
|
16
|
+
create_file '.ruby-version', "#{Chr::RUBY_VERSION}\n"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def raise_on_delivery_errors
|
|
21
|
+
replace_in_file 'config/environments/development.rb',
|
|
22
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def raise_on_unpermitted_parameters
|
|
27
|
+
config = <<-RUBY
|
|
28
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
|
29
|
+
RUBY
|
|
30
|
+
|
|
31
|
+
inject_into_class "config/application.rb", "Application", config
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def provide_setup_script
|
|
36
|
+
template "bin_setup.erb", "bin/setup", port_number: port, force: true
|
|
37
|
+
run "chmod a+x bin/setup"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def provide_dev_prime_task
|
|
42
|
+
copy_file 'development_seeds.rb', 'lib/tasks/development_seeds.rake'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def configure_generators
|
|
47
|
+
config = <<-RUBY
|
|
48
|
+
|
|
49
|
+
config.generators do |generate|
|
|
50
|
+
generate.helper false
|
|
51
|
+
generate.javascript_engine false
|
|
52
|
+
generate.stylesheets false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
RUBY
|
|
56
|
+
|
|
57
|
+
inject_into_class 'config/application.rb', 'Application', config
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def configure_newrelic
|
|
62
|
+
template 'newrelic.yml.erb', 'config/newrelic.yml'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def configure_smtp
|
|
67
|
+
copy_file 'smtp.rb', 'config/smtp.rb'
|
|
68
|
+
|
|
69
|
+
prepend_file 'config/environments/production.rb',
|
|
70
|
+
%{require Rails.root.join("config/smtp")\n}
|
|
71
|
+
|
|
72
|
+
config = <<-RUBY
|
|
73
|
+
|
|
74
|
+
config.action_mailer.delivery_method = :smtp
|
|
75
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
|
76
|
+
RUBY
|
|
77
|
+
|
|
78
|
+
inject_into_file 'config/environments/production.rb', config,
|
|
79
|
+
:after => 'config.action_mailer.raise_delivery_errors = false'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def configure_rack_timeout
|
|
84
|
+
rack_timeout_config = <<-RUBY
|
|
85
|
+
Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
|
|
86
|
+
RUBY
|
|
87
|
+
|
|
88
|
+
append_file "config/environments/production.rb", rack_timeout_config
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def enable_rack_canonical_host
|
|
93
|
+
config = <<-RUBY
|
|
94
|
+
|
|
95
|
+
# Ensure requests are only served from one, canonical host name
|
|
96
|
+
config.middleware.use Rack::CanonicalHost, ENV.fetch("HOST")
|
|
97
|
+
RUBY
|
|
98
|
+
|
|
99
|
+
inject_into_file(
|
|
100
|
+
"config/environments/production.rb",
|
|
101
|
+
config,
|
|
102
|
+
after: serve_static_files_line
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def enable_rack_deflater
|
|
107
|
+
config = <<-RUBY
|
|
108
|
+
|
|
109
|
+
# Enable deflate / gzip compression of controller-generated responses
|
|
110
|
+
config.middleware.use Rack::Deflater
|
|
111
|
+
RUBY
|
|
112
|
+
|
|
113
|
+
inject_into_file(
|
|
114
|
+
"config/environments/production.rb",
|
|
115
|
+
config,
|
|
116
|
+
after: serve_static_files_line
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def setup_asset_host
|
|
122
|
+
replace_in_file 'config/environments/production.rb',
|
|
123
|
+
"# config.action_controller.asset_host = 'http://assets.example.com'",
|
|
124
|
+
'config.action_controller.asset_host = ENV.fetch("ASSET_HOST")'
|
|
125
|
+
|
|
126
|
+
replace_in_file 'config/initializers/assets.rb',
|
|
127
|
+
"config.assets.version = '1.0'",
|
|
128
|
+
'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
|
|
129
|
+
|
|
130
|
+
inject_into_file(
|
|
131
|
+
"config/environments/production.rb",
|
|
132
|
+
' config.static_cache_control = "public, max-age=#{1.year.to_i}"',
|
|
133
|
+
after: serve_static_files_line
|
|
134
|
+
)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def setup_asset_sync
|
|
139
|
+
copy_file 'asset_sync.rb', 'config/initializers/asset_sync.rb'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def setup_staging_environment
|
|
144
|
+
staging_file = 'config/environments/staging.rb'
|
|
145
|
+
copy_file 'staging.rb', staging_file
|
|
146
|
+
|
|
147
|
+
config = <<-RUBY
|
|
148
|
+
|
|
149
|
+
Rails.application.configure do
|
|
150
|
+
# ...
|
|
151
|
+
end
|
|
152
|
+
RUBY
|
|
153
|
+
|
|
154
|
+
append_file staging_file, config
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def setup_secret_token
|
|
159
|
+
template 'secrets.yml', 'config/secrets.yml', force: true
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def create_partials_directory
|
|
164
|
+
empty_directory 'app/views/application'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def create_shared_analytics
|
|
169
|
+
copy_file '_analytics.html.erb', 'app/views/application/_analytics.html.erb'
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def create_shared_flashes
|
|
174
|
+
copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def create_shared_javascripts
|
|
179
|
+
copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def create_application_layout
|
|
184
|
+
template 'application_layout.html.erb.erb',
|
|
185
|
+
'app/views/layouts/application.html.erb',
|
|
186
|
+
force: true
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def create_body_class_helper
|
|
191
|
+
copy_file 'body_class_helper.rb', 'app/helpers/body_class_helper.rb'
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def configure_action_mailer
|
|
196
|
+
action_mailer_host "development", %{"localhost:#{ port }"}
|
|
197
|
+
action_mailer_host "test", %{ "www.example.com" }
|
|
198
|
+
action_mailer_host "staging", %{ ENV.fetch("HOST") }
|
|
199
|
+
action_mailer_host "production", %{ ENV.fetch("HOST") }
|
|
200
|
+
|
|
201
|
+
configure_environment "production", 'config.action_mailer.asset_host = "http://#{ ENV.fetch("ASSET_HOST") }"'
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def configure_puma
|
|
206
|
+
copy_file "puma.rb", "config/puma.rb"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def setup_foreman
|
|
211
|
+
copy_file 'sample.env', '.sample.env'
|
|
212
|
+
copy_file 'Procfile', 'Procfile'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def setup_stylesheets
|
|
217
|
+
remove_file "app/assets/javascripts/application.js"
|
|
218
|
+
copy_file "application.coffee",
|
|
219
|
+
"app/assets/javascripts/application.coffee"
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def setup_javascripts
|
|
224
|
+
remove_file "app/assets/stylesheets/application.css"
|
|
225
|
+
copy_file "application.scss",
|
|
226
|
+
"app/assets/stylesheets/application.scss"
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def copy_miscellaneous_files
|
|
231
|
+
copy_file "errors.rb", "config/initializers/errors.rb"
|
|
232
|
+
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def customize_error_pages
|
|
237
|
+
meta_tags =<<-EOS
|
|
238
|
+
<meta charset="utf-8" />
|
|
239
|
+
<meta name="ROBOTS" content="NOODP" />
|
|
240
|
+
<meta name="viewport" content="initial-scale=1" />
|
|
241
|
+
EOS
|
|
242
|
+
|
|
243
|
+
%w(500 404 422).each do |page|
|
|
244
|
+
inject_into_file "public/#{page}.html", meta_tags, after: "<head>\n"
|
|
245
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def setup_devise
|
|
251
|
+
generate 'devise:install'
|
|
252
|
+
|
|
253
|
+
replace_in_file 'config/initializers/devise.rb',
|
|
254
|
+
'# config.scoped_views = false',
|
|
255
|
+
'config.scoped_views = true'
|
|
256
|
+
|
|
257
|
+
replace_in_file 'config/initializers/devise.rb',
|
|
258
|
+
'# config.sign_out_all_scopes = true',
|
|
259
|
+
'config.sign_out_all_scopes = false'
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def setup_character_routes
|
|
264
|
+
remove_file 'config/routes.rb'
|
|
265
|
+
copy_file 'routes.rb', 'config/routes.rb'
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def setup_character_base_controller
|
|
270
|
+
copy_file 'character_base_controller.rb', 'app/controllers/admin/base_controller.rb'
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def configure_devise_for_character
|
|
275
|
+
copy_file 'devise_overrides_passwords_controller.rb', 'app/controllers/admin/devise_overrides/passwords_controller.rb'
|
|
276
|
+
copy_file 'devise_overrides_sessions_controller.rb', 'app/controllers/admin/devise_overrides/sessions_controller.rb'
|
|
277
|
+
|
|
278
|
+
copy_file 'devise_overrides_passwords_edit.html.erb', 'app/views/admin/devise_overrides/passwords/edit.html.erb'
|
|
279
|
+
copy_file 'devise_overrides_passwords_new.html.erb', 'app/views/admin/devise_overrides/passwords/new.html.erb'
|
|
280
|
+
copy_file 'devise_overrides_sessions_new.html.erb', 'app/views/admin/devise_overrides/sessions/new.html.erb'
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def setup_character_views
|
|
285
|
+
copy_file 'character_admin_layout.html.erb', 'app/views/layouts/admin.html.erb'
|
|
286
|
+
copy_file 'character_admin_index.html.erb', 'app/views/admin/index.html.erb'
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def setup_character_stylesheets
|
|
291
|
+
template 'character_admin.coffee.erb', 'app/assets/javascripts/admin.coffee'
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def setup_character_javascripts
|
|
296
|
+
copy_file 'character_admin.scss', 'app/assets/stylesheets/admin.scss'
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def setup_character_assets
|
|
301
|
+
replace_in_file 'config/initializers/assets.rb',
|
|
302
|
+
"# Rails.application.config.assets.precompile += %w( search.js )",
|
|
303
|
+
'Rails.application.config.assets.precompile += %w( admin.js admin.css )'
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def setup_carrierwave
|
|
308
|
+
copy_file "carrierwave.rb", "config/initializers/carrierwave.rb"
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def init_git
|
|
313
|
+
run 'git init'
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def gitignore_files
|
|
318
|
+
remove_file '.gitignore'
|
|
319
|
+
template 'application_gitignore', '.gitignore'
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def initialize_mongoid
|
|
324
|
+
generate 'mongoid:config'
|
|
325
|
+
append_file "config/mongoid.yml", """\nproduction:
|
|
326
|
+
sessions:
|
|
327
|
+
default:
|
|
328
|
+
uri: <%= ENV['MONGODB_URI'] %>"""
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def setup_bundler_audit
|
|
333
|
+
copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
|
|
334
|
+
append_file "Rakefile", %{\ntask default: "bundler:audit"\n}
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def setup_spring
|
|
339
|
+
bundle_command "exec spring binstub --all"
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
private
|
|
344
|
+
|
|
345
|
+
def port
|
|
346
|
+
3000
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def serve_static_files_line
|
|
351
|
+
"config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def replace_in_file(relative_path, find, replace)
|
|
356
|
+
path = File.join(destination_root, relative_path)
|
|
357
|
+
contents = IO.read(path)
|
|
358
|
+
|
|
359
|
+
unless contents.gsub!(find, replace)
|
|
360
|
+
raise "#{ find.inspect } not found in #{ relative_path }"
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
File.open(path, "w") { |file| file.write(contents) }
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def action_mailer_host(rails_env, host)
|
|
368
|
+
config = "config.action_mailer.default_url_options = { host: #{host} }"
|
|
369
|
+
configure_environment(rails_env, config)
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def configure_environment(rails_env, config)
|
|
374
|
+
inject_into_file(
|
|
375
|
+
"config/environments/#{rails_env}.rb",
|
|
376
|
+
"\n\n #{config}",
|
|
377
|
+
before: "\nend"
|
|
378
|
+
)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|