rocket_cms 0.30.0 → 0.33.1
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/Gemfile.lock +81 -81
- data/README.md +7 -2
- data/app/views/{blocks → components}/_counters.html +0 -0
- data/app/views/{blocks → components}/_footer.slim +0 -0
- data/app/views/{blocks → components}/_header.slim +0 -0
- data/app/views/layouts/application.slim +3 -9
- data/app/views/news/index.slim +5 -2
- data/app/views/news/show.slim +5 -3
- data/app/views/shared/_og.slim +2 -2
- data/config/locales/ru.kaminari.yml +8 -2
- data/lib/generators/rocket_cms/layout_generator.rb +5 -3
- data/lib/generators/rocket_cms/templates/.browserlistrc +1 -0
- data/lib/generators/rocket_cms/templates/ability.erb +6 -2
- data/lib/generators/rocket_cms/templates/admin.erb +1 -1
- data/lib/generators/rocket_cms/templates/migration_news.rb +5 -1
- data/lib/generators/rocket_cms/templates/package.json +3 -0
- data/lib/generators/rocket_cms/templates/webpack.config.js +2 -2
- data/lib/generators/rocket_cms/templates/webpack/application.es6 +8 -17
- data/lib/generators/rocket_cms/templates/webpack/components/footer/index.sass +2 -0
- data/lib/generators/rocket_cms/templates/webpack/components/header/index.sass +1 -0
- data/lib/generators/rocket_cms/templates/webpack/{blocks → components}/index.es6 +1 -1
- data/lib/generators/rocket_cms/templates/webpack/flash/index.es6 +12 -8
- data/lib/generators/rocket_cms/templates/webpack/pages/home/index.es6 +1 -1
- data/lib/generators/rocket_cms/webpack_generator.rb +5 -7
- data/lib/rocket_cms.rb +7 -1
- data/lib/rocket_cms/admin.rb +7 -3
- data/lib/rocket_cms/controller.rb +1 -1
- data/lib/rocket_cms/engine.rb +0 -12
- data/lib/rocket_cms/migration.rb +6 -1
- data/lib/rocket_cms/models/active_record/news.rb +6 -2
- data/lib/rocket_cms/models/active_record/seo.rb +5 -1
- data/lib/rocket_cms/models/mongoid/news.rb +7 -3
- data/lib/rocket_cms/models/mongoid/seo.rb +9 -2
- data/lib/rocket_cms/models/news.rb +2 -1
- data/lib/rocket_cms/models/seo.rb +3 -1
- data/lib/rocket_cms/version.rb +1 -1
- data/template.rb +292 -62
- metadata +13 -17
- data/config/locales/ru.devise.yml +0 -65
- data/lib/filename_to_slug.rb +0 -32
- data/lib/generators/rocket_cms/templates/webpack/blocks/footer/index.sass +0 -2
- data/lib/generators/rocket_cms/templates/webpack/blocks/header/index.sass +0 -1
- data/lib/generators/rocket_cms/templates/webpack/errors/errors.pug +0 -7
- data/lib/generators/rocket_cms/templates/webpack/errors/index.es6 +0 -30
- data/lib/generators/rocket_cms/templates/webpack/errors/index.sass +0 -49
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
"private": true,
|
|
6
6
|
"repository": "git@rscz.ru:rocket-science/<%= app_name.downcase %>.git",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@rails/actioncable": "^6.0.0",
|
|
9
|
+
"@rails/ujs": "^6.0.0",
|
|
10
|
+
"turbolinks": "^5.2.0",
|
|
8
11
|
"@babel/core": "^7.0.0",
|
|
9
12
|
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
|
10
13
|
"@babel/plugin-proposal-function-bind": "^7.0.0",
|
|
@@ -8,7 +8,7 @@ var autoprefixer = require('autoprefixer');
|
|
|
8
8
|
var CompressionPlugin = require("compression-webpack-plugin");
|
|
9
9
|
|
|
10
10
|
var host = process.env.HOST || 'localhost'
|
|
11
|
-
var devServerPort =
|
|
11
|
+
var devServerPort = <%= port %>;
|
|
12
12
|
|
|
13
13
|
var production = process.env.NODE_ENV === 'production';
|
|
14
14
|
|
|
@@ -55,7 +55,7 @@ var config = {
|
|
|
55
55
|
{
|
|
56
56
|
loader: ExtractCssChunks.loader,
|
|
57
57
|
options: {
|
|
58
|
-
|
|
58
|
+
hmr: production ? false : true,
|
|
59
59
|
// Force reload all
|
|
60
60
|
//reloadAll: true,
|
|
61
61
|
}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import './fonts';
|
|
2
2
|
import './layout';
|
|
3
3
|
|
|
4
|
-
import Errors from 'errors';
|
|
5
|
-
import 'flash';
|
|
6
|
-
|
|
7
|
-
var errors = new Errors()
|
|
8
|
-
document.addEventListener("DOMContentLoaded", function(event) {
|
|
9
|
-
errors.checkCookie();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
4
|
import Turbolinks from "turbolinks";
|
|
13
5
|
Turbolinks.start()
|
|
14
6
|
|
|
15
|
-
import Rails from 'rails
|
|
7
|
+
import Rails from '@rails/ujs';
|
|
16
8
|
Rails.start();
|
|
17
9
|
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
import "./blocks";
|
|
10
|
+
import "./components";
|
|
21
11
|
import "./pages";
|
|
22
12
|
|
|
23
|
-
import "analytics"
|
|
13
|
+
//import "analytics"
|
|
24
14
|
//import goal from "analytics"
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
axios.defaults.headers.common['X-
|
|
29
|
-
|
|
16
|
+
//import axios from 'axios';
|
|
17
|
+
//document.addEventListener("turbolinks:load", function() {
|
|
18
|
+
//axios.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
|
|
19
|
+
//axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
|
20
|
+
//});
|
|
30
21
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.header
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import './index.sass';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
//document.addEventListener('DOMContentLoaded', function () {
|
|
4
|
+
document.addEventListener("turbolinks:load", function() {
|
|
5
|
+
var close = document.querySelectorAll("a.close_flash");
|
|
6
|
+
close.forEach(function(n) {
|
|
7
|
+
n.addEventListener("click", function() {
|
|
8
|
+
var msg = this.parentNode.parentNode;
|
|
9
|
+
var box = msg.parentNode;
|
|
10
|
+
this.parentNode.parentNode.remove();
|
|
11
|
+
if (box.childNodes.length == 0) {
|
|
12
|
+
box.remove()
|
|
13
|
+
}
|
|
14
|
+
})
|
|
10
15
|
})
|
|
11
16
|
});
|
|
12
|
-
|
|
@@ -1 +1 @@
|
|
|
1
|
-
// import page-specific
|
|
1
|
+
// import page-specific components here
|
|
@@ -12,15 +12,13 @@ module RocketCms
|
|
|
12
12
|
desc 'RocketCMS webpack generator'
|
|
13
13
|
def install
|
|
14
14
|
copy_file ".babelrc", ".babelrc"
|
|
15
|
+
copy_file ".browserlistrc", ".browserlistrc"
|
|
16
|
+
copy_file "postcss.config.js", "postcss.config.js"
|
|
15
17
|
|
|
16
18
|
copy_file "webpack/common/mixins.sass", "webpack/common/mixins.sass"
|
|
17
19
|
copy_file "webpack/common/variables.sass", "webpack/common/variables.sass"
|
|
18
20
|
copy_file "webpack/common/index.sass", "webpack/common/index.sass"
|
|
19
21
|
|
|
20
|
-
copy_file "webpack/errors/errors.pug", "webpack/errors/errors.pug"
|
|
21
|
-
copy_file "webpack/errors/index.es6", "webpack/errors/index.es6"
|
|
22
|
-
copy_file "webpack/errors/index.sass", "webpack/errors/index.sass"
|
|
23
|
-
|
|
24
22
|
copy_file "webpack/flash/index.es6", "webpack/flash/index.es6"
|
|
25
23
|
copy_file "webpack/flash/index.sass", "webpack/flash/index.sass"
|
|
26
24
|
|
|
@@ -32,9 +30,9 @@ module RocketCms
|
|
|
32
30
|
copy_file "webpack/layout/main.sass", "webpack/layout/main.sass"
|
|
33
31
|
copy_file "webpack/layout/typography.sass", "webpack/layout/typography.sass"
|
|
34
32
|
|
|
35
|
-
copy_file "webpack/
|
|
36
|
-
copy_file "webpack/
|
|
37
|
-
copy_file "webpack/
|
|
33
|
+
copy_file "webpack/components/index.es6", "webpack/components/index.es6"
|
|
34
|
+
copy_file "webpack/components/header/index.sass", "webpack/components/header/index.sass"
|
|
35
|
+
copy_file "webpack/components/footer/index.sass", "webpack/components/footer/index.sass"
|
|
38
36
|
|
|
39
37
|
copy_file "webpack/pages/index.es6", "webpack/pages/index.es6"
|
|
40
38
|
copy_file "webpack/pages/home/index.es6", "webpack/pages/home/index.es6"
|
data/lib/rocket_cms.rb
CHANGED
|
@@ -6,7 +6,6 @@ end
|
|
|
6
6
|
require 'rocket_cms/version'
|
|
7
7
|
require 'validates_email_format_of'
|
|
8
8
|
require 'smart_excerpt'
|
|
9
|
-
require 'filename_to_slug'
|
|
10
9
|
|
|
11
10
|
require 'kaminari'
|
|
12
11
|
require 'addressable/uri'
|
|
@@ -42,6 +41,13 @@ module RocketCMS
|
|
|
42
41
|
"#{model_namespace}::#{name}".constantize
|
|
43
42
|
end
|
|
44
43
|
|
|
44
|
+
def shrine?
|
|
45
|
+
defined?(::Shrine)
|
|
46
|
+
end
|
|
47
|
+
def paperclip?
|
|
48
|
+
!shrine? && defined?(::Paperclip)
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
def url_helper
|
|
46
52
|
@@url_helper ||= RocketCMS::UrlHelper.new
|
|
47
53
|
end
|
data/lib/rocket_cms/admin.rb
CHANGED
|
@@ -37,7 +37,11 @@ module RocketCMS
|
|
|
37
37
|
field :robots, :string
|
|
38
38
|
|
|
39
39
|
field :og_title, :string
|
|
40
|
-
|
|
40
|
+
if RocketCMS.shrine?
|
|
41
|
+
field :og_image, :paperclip
|
|
42
|
+
elsif RocketCMS.paperclip?
|
|
43
|
+
field :og_image, :paperclip
|
|
44
|
+
end
|
|
41
45
|
end
|
|
42
46
|
end
|
|
43
47
|
|
|
@@ -60,7 +64,7 @@ module RocketCMS
|
|
|
60
64
|
end
|
|
61
65
|
edit do
|
|
62
66
|
field :name
|
|
63
|
-
field :content, :
|
|
67
|
+
field :content, :ckeditor
|
|
64
68
|
RocketCMS.apply_patches self
|
|
65
69
|
group :menu do
|
|
66
70
|
label I18n.t('rs.menu')
|
|
@@ -143,7 +147,7 @@ module RocketCMS
|
|
|
143
147
|
end
|
|
144
148
|
|
|
145
149
|
edit do
|
|
146
|
-
field :content, :
|
|
150
|
+
field :content, :ckeditor
|
|
147
151
|
RocketCMS.apply_patches self
|
|
148
152
|
group :seo, &RocketCMS.seo_config
|
|
149
153
|
end
|
data/lib/rocket_cms/engine.rb
CHANGED
|
@@ -4,18 +4,6 @@ module RocketCMS
|
|
|
4
4
|
require File.expand_path('../tasks', __FILE__)
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
initializer 'rocket_cms.paperclip' do
|
|
8
|
-
require 'paperclip/style'
|
|
9
|
-
module ::Paperclip
|
|
10
|
-
class Style
|
|
11
|
-
alias_method :processor_options_without_auto_orient, :processor_options
|
|
12
|
-
def processor_options
|
|
13
|
-
processor_options_without_auto_orient.merge(auto_orient: false)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
7
|
config.after_initialize do
|
|
20
8
|
# trigger autoload so models are registered in Mongoid::Elasticearch
|
|
21
9
|
RocketCMS.config.search_models.map(&:constantize)
|
data/lib/rocket_cms/migration.rb
CHANGED
|
@@ -4,8 +4,12 @@ module RocketCMS
|
|
|
4
4
|
module News
|
|
5
5
|
extend ActiveSupport::Concern
|
|
6
6
|
included do
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
if !RocketCMS.config.news_image_styles.nil?
|
|
8
|
+
if RocketCMS.shrine?
|
|
9
|
+
include NewsUploader.attachment(:image)
|
|
10
|
+
elsif RocketCMS.paperclip?
|
|
11
|
+
has_attached_file :image, styles: RocketCMS.config.news_image_styles
|
|
12
|
+
end
|
|
9
13
|
end
|
|
10
14
|
|
|
11
15
|
has_paper_trail if respond_to?(:has_paper_trail)
|
|
@@ -4,7 +4,11 @@ module RocketCMS
|
|
|
4
4
|
module Seo
|
|
5
5
|
extend ActiveSupport::Concern
|
|
6
6
|
included do
|
|
7
|
-
|
|
7
|
+
if RocketCMS.shrine?
|
|
8
|
+
include OgImageUploader.attachment(:og_image)
|
|
9
|
+
elsif RocketCMS.paperclip?
|
|
10
|
+
has_attached_file :og_image, styles: {thumb: "800x600>"}
|
|
11
|
+
end
|
|
8
12
|
if RocketCMS.config.localize
|
|
9
13
|
translates :h1, :title, :keywords, :description, :og_title
|
|
10
14
|
end
|
|
@@ -3,13 +3,17 @@ module RocketCMS
|
|
|
3
3
|
module Mongoid
|
|
4
4
|
module News
|
|
5
5
|
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
if !RocketCMS.config.news_image_styles.nil?
|
|
7
|
+
if RocketCMS.shrine?
|
|
8
|
+
include ImageUploader::Attachment(:image)
|
|
9
|
+
elsif RocketCMS.paperclip?
|
|
10
|
+
include ::Mongoid::Paperclip
|
|
11
|
+
end
|
|
8
12
|
end
|
|
9
13
|
included do
|
|
10
14
|
field :time, type: Time
|
|
11
15
|
index({enabled: 1, time: 1})
|
|
12
|
-
|
|
16
|
+
if RocketCMS.paperclip? && RocketCMS.config.news_image_styles.nil?
|
|
13
17
|
has_mongoid_attached_file :image, styles: RocketCMS.config.news_image_styles
|
|
14
18
|
end
|
|
15
19
|
field :name, type: String, localize: RocketCMS.config.localize
|
|
@@ -3,7 +3,11 @@ module RocketCMS
|
|
|
3
3
|
module Mongoid
|
|
4
4
|
module Seo
|
|
5
5
|
extend ActiveSupport::Concern
|
|
6
|
-
|
|
6
|
+
if RocketCMS.shrine?
|
|
7
|
+
include ImageUploader::Attachment(:og_image)
|
|
8
|
+
elsif RocketCMS.paperclip?
|
|
9
|
+
include ::Mongoid::Paperclip
|
|
10
|
+
end
|
|
7
11
|
included do
|
|
8
12
|
field :name, type: String, localize: RocketCMS.config.localize
|
|
9
13
|
field :h1, type: String, localize: RocketCMS.config.localize
|
|
@@ -14,7 +18,10 @@ module RocketCMS
|
|
|
14
18
|
field :robots, type: String, localize: RocketCMS.config.localize
|
|
15
19
|
|
|
16
20
|
field :og_title, type: String, localize: RocketCMS.config.localize
|
|
17
|
-
|
|
21
|
+
|
|
22
|
+
if RocketCMS.paperclip?
|
|
23
|
+
has_mongoid_attached_file :og_image, styles: {thumb: "800x600>"}
|
|
24
|
+
end
|
|
18
25
|
end
|
|
19
26
|
end
|
|
20
27
|
end
|
|
@@ -13,7 +13,8 @@ module RocketCMS
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
included do
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
if RocketCMS.paperclip? && !RocketCMS.config.news_image_styles.nil?
|
|
17
18
|
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
|
18
19
|
end
|
|
19
20
|
|
|
@@ -9,7 +9,9 @@ module RocketCMS
|
|
|
9
9
|
|
|
10
10
|
included do
|
|
11
11
|
RocketCMS.apply_patches self
|
|
12
|
-
|
|
12
|
+
if RocketCMS.paperclip?
|
|
13
|
+
validates_attachment_content_type :og_image, content_type: /\Aimage\/.*\Z/, if: :og_image?
|
|
14
|
+
end
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
end
|
data/lib/rocket_cms/version.rb
CHANGED
data/template.rb
CHANGED
|
@@ -3,10 +3,13 @@ version = rails_spec.version.to_s
|
|
|
3
3
|
|
|
4
4
|
mongoid = options[:skip_active_record]
|
|
5
5
|
yarn = !options[:skip_yarn]
|
|
6
|
-
|
|
6
|
+
is_dev = !options[:template].start_with?("http")
|
|
7
7
|
spring = !options[:skip_spring]
|
|
8
|
+
if is_dev
|
|
9
|
+
rocket_cms_path = File.realpath(options[:template] + "/..")
|
|
10
|
+
end
|
|
8
11
|
|
|
9
|
-
if Gem::Version.new(version) < Gem::Version.new('
|
|
12
|
+
if Gem::Version.new(version) < Gem::Version.new('6.0.0')
|
|
10
13
|
puts "You are using an old version of Rails (#{version})"
|
|
11
14
|
puts "Please update"
|
|
12
15
|
puts "Stopping"
|
|
@@ -24,25 +27,26 @@ git_source(:github) do |repo_name|
|
|
|
24
27
|
"https://github.com/#{repo_name}.git"
|
|
25
28
|
end
|
|
26
29
|
'}
|
|
27
|
-
gem 'rails', '
|
|
30
|
+
gem 'rails', '6.0.1'
|
|
31
|
+
gem 'rails-i18n'
|
|
28
32
|
#{if mongoid then "gem 'mongoid', '~> 6.1.0'" else "gem 'pg', '>= 0.18', '< 2.0'" end}
|
|
29
33
|
gem 'turbolinks' #required for redirects even if using via webpack
|
|
30
34
|
|
|
31
|
-
gem 'sass'
|
|
32
|
-
|
|
33
35
|
#{
|
|
34
|
-
"#{if mongoid then "gem 'rocket_cms_mongoid', path: '
|
|
35
|
-
gem 'rocket_cms', path: '
|
|
36
|
-
#{"#{if mongoid then "gem 'rocket_cms_mongoid'" else "gem 'rocket_cms_activerecord'" end}" if
|
|
36
|
+
"#{if mongoid then "gem 'rocket_cms_mongoid', path: '#{rocket_cms_path}'" else "gem 'rocket_cms_activerecord', path: '#{rocket_cms_path}'" end}
|
|
37
|
+
gem 'rocket_cms', path: '#{rocket_cms_path}'" if is_dev}
|
|
38
|
+
#{"#{if mongoid then "gem 'rocket_cms_mongoid'" else "gem 'rocket_cms_activerecord'" end}" if !is_dev}
|
|
39
|
+
|
|
40
|
+
gem 'glebtv-ckeditor'
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
# wait for https://github.com/sferik/rails_admin/pull/3207
|
|
43
|
+
gem 'rails_admin', github: "sferik/rails_admin"
|
|
40
44
|
|
|
41
45
|
gem 'slim'
|
|
42
|
-
gem 'haml'
|
|
43
46
|
|
|
44
|
-
gem 'sass
|
|
45
|
-
gem '
|
|
47
|
+
#gem 'sass'
|
|
48
|
+
#gem 'sass-rails'
|
|
49
|
+
gem 'rs-webpack-rails'
|
|
46
50
|
|
|
47
51
|
gem 'devise'
|
|
48
52
|
gem 'devise-i18n'
|
|
@@ -54,9 +58,13 @@ gem 'puma'
|
|
|
54
58
|
|
|
55
59
|
gem 'sentry-raven'
|
|
56
60
|
|
|
57
|
-
gem '
|
|
61
|
+
gem 'shrine'
|
|
62
|
+
#{"gem 'shrine-mongoid'" if mongoid}
|
|
63
|
+
gem 'image_processing'
|
|
58
64
|
|
|
59
|
-
gem '
|
|
65
|
+
#gem 'uglifier'
|
|
66
|
+
|
|
67
|
+
#gem 'rs_russian'
|
|
60
68
|
#gem 'enumerize'
|
|
61
69
|
#gem 'active_model_serializers'
|
|
62
70
|
|
|
@@ -65,6 +73,7 @@ gem 'tzinfo-data' if Gem.win_platform?
|
|
|
65
73
|
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
|
|
66
74
|
|
|
67
75
|
gem 'bootsnap', require: false
|
|
76
|
+
gem 'irb'
|
|
68
77
|
|
|
69
78
|
group :development do
|
|
70
79
|
#gem 'binding_of_caller'
|
|
@@ -80,16 +89,21 @@ group :development do
|
|
|
80
89
|
gem 'capistrano-rails', require: false
|
|
81
90
|
end
|
|
82
91
|
|
|
83
|
-
group :test do
|
|
92
|
+
group :development, :test do
|
|
93
|
+
gem "factory_bot_rails"
|
|
84
94
|
gem 'rspec-rails'
|
|
85
|
-
gem 'email_spec'
|
|
86
95
|
#{if mongoid then " gem 'mongoid-rspec'" else "" end}
|
|
87
|
-
gem 'ffaker'
|
|
88
|
-
gem 'factory_bot_rails'
|
|
89
|
-
|
|
90
96
|
gem 'capybara'
|
|
91
|
-
|
|
97
|
+
# https://github.com/mattheworiordan/capybara-screenshot/issues/243
|
|
98
|
+
gem 'capybara-screenshot'
|
|
99
|
+
gem 'selenium-webdriver'
|
|
100
|
+
gem 'webdrivers'
|
|
92
101
|
gem 'database_cleaner'
|
|
102
|
+
#{if mongoid then " gem 'database_cleaner-mongoid'" else "" end}
|
|
103
|
+
#gem 'database_cleaner-redis'
|
|
104
|
+
gem 'ffaker'
|
|
105
|
+
gem 'timecop'
|
|
106
|
+
gem "pry-rails"
|
|
93
107
|
gem 'childprocess'
|
|
94
108
|
end
|
|
95
109
|
|
|
@@ -150,20 +164,20 @@ ORM: #{if mongoid then 'Mongoid' else 'ActiveRecord' end}
|
|
|
150
164
|
|
|
151
165
|
To run (windows):
|
|
152
166
|
```
|
|
153
|
-
|
|
167
|
+
yarn start
|
|
154
168
|
bundle exec rails s webrick
|
|
155
169
|
```
|
|
156
170
|
|
|
157
171
|
|
|
158
172
|
To run (nix/mac):
|
|
159
173
|
```
|
|
160
|
-
|
|
174
|
+
yarn start
|
|
161
175
|
puma
|
|
162
176
|
```
|
|
163
177
|
|
|
164
178
|
"
|
|
165
179
|
|
|
166
|
-
#create_file '.ruby-version', "2.5
|
|
180
|
+
#create_file '.ruby-version', "2.6.5\n"
|
|
167
181
|
#create_file '.ruby-gemset', "#{app_name}\n"
|
|
168
182
|
|
|
169
183
|
run 'bundle install --without production'
|
|
@@ -233,10 +247,11 @@ gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at'
|
|
|
233
247
|
end
|
|
234
248
|
|
|
235
249
|
if mongoid
|
|
236
|
-
generate "ckeditor:install", "--orm=mongoid", "--backend=
|
|
250
|
+
generate "ckeditor:install", "--orm=mongoid", "--backend=shrine"
|
|
237
251
|
else
|
|
238
|
-
generate "ckeditor:install", "--orm-active_record", "--backend=
|
|
252
|
+
generate "ckeditor:install", "--orm-active_record", "--backend=shrine"
|
|
239
253
|
end
|
|
254
|
+
remove_file 'config/initializers/ckeditor_shrine.rb'
|
|
240
255
|
|
|
241
256
|
unless mongoid
|
|
242
257
|
generate "rocket_cms:migration"
|
|
@@ -279,14 +294,6 @@ end
|
|
|
279
294
|
|
|
280
295
|
create_file 'config/locales/ru.yml' do <<-TEXT
|
|
281
296
|
ru:
|
|
282
|
-
attributes:
|
|
283
|
-
is_default: По умолчанию
|
|
284
|
-
mongoid:
|
|
285
|
-
models:
|
|
286
|
-
item: Товар
|
|
287
|
-
attributes:
|
|
288
|
-
item:
|
|
289
|
-
price: Цена
|
|
290
297
|
TEXT
|
|
291
298
|
end
|
|
292
299
|
|
|
@@ -301,36 +308,205 @@ User.create!(email: 'admin@#{app_name.dasherize.downcase}.ru', password: admin_p
|
|
|
301
308
|
|
|
302
309
|
Page.destroy_all
|
|
303
310
|
Menu.destroy_all
|
|
311
|
+
News.destroy_all
|
|
312
|
+
|
|
304
313
|
h = Menu.create(name: 'Главное', text_slug: 'main').id
|
|
305
|
-
|
|
306
|
-
Page.create!(name: 'Прайс лист', fullpath: '/price', menu_ids: [h])
|
|
307
|
-
Page.create!(name: 'Галерея', fullpath: '/galleries', menu_ids: [h])
|
|
308
|
-
c = Page.create!(name: 'О компании', fullpath: '/company', menu_ids: [h], content: 'О Компании')
|
|
314
|
+
Page.create!(name: 'О компании', fullpath: '/company', menu_ids: [h], content: 'О Компании')
|
|
309
315
|
Page.create!(name: 'Новости', fullpath: '/news', menu_ids: [h])
|
|
310
316
|
Page.create!(name: 'Контакты', fullpath: '/contacts', menu_ids: [h], content: 'Текст стр контакты')
|
|
311
317
|
|
|
318
|
+
3.times do |i|
|
|
319
|
+
News.create!(name: "test " + i.to_s, content: "test", time: i.days.ago)
|
|
320
|
+
end
|
|
321
|
+
|
|
312
322
|
TEXT
|
|
313
323
|
end
|
|
314
324
|
|
|
315
|
-
create_file '
|
|
316
|
-
|
|
325
|
+
create_file 'app/uploaders/news_uploader.rb' do <<-TEXT
|
|
326
|
+
class NewsUploader < Shrine
|
|
327
|
+
plugin :determine_mime_type
|
|
328
|
+
plugin :validation_helpers
|
|
329
|
+
plugin :derivatives
|
|
330
|
+
|
|
331
|
+
Attacher.validate do
|
|
332
|
+
validate_mime_type_inclusion %w[image/jpeg image/gif image/png]
|
|
333
|
+
validate_max_size 2.megabytes
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
Attacher.derivatives do |original|
|
|
337
|
+
magick = ImageProcessing::MiniMagick.source(original)
|
|
338
|
+
|
|
339
|
+
{
|
|
340
|
+
main: magick.resize_to_limit!(800, 800),
|
|
341
|
+
thumb: magick.resize_to_limit!(300, 300)
|
|
342
|
+
}
|
|
343
|
+
end
|
|
344
|
+
end
|
|
345
|
+
TEXT
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
create_file 'app/uploaders/og_image_uploader.rb' do <<-TEXT
|
|
349
|
+
class OgImageUploader < Shrine
|
|
350
|
+
plugin :determine_mime_type
|
|
351
|
+
plugin :validation_helpers
|
|
352
|
+
|
|
353
|
+
Attacher.validate do
|
|
354
|
+
validate_mime_type_inclusion %w[image/jpeg image/gif image/png]
|
|
355
|
+
validate_max_size 2.megabytes
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
TEXT
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
create_file 'extra/shrine/plugins/custom_pretty_location.rb' do <<-TEXT
|
|
362
|
+
require 'shrine/plugins/pretty_location'
|
|
363
|
+
|
|
364
|
+
class Shrine
|
|
365
|
+
module Plugins
|
|
366
|
+
module CustomPrettyLocation
|
|
367
|
+
def self.configure(uploader, **opts)
|
|
368
|
+
uploader.opts[:custom_pretty_location] ||= { identifier: :id }
|
|
369
|
+
uploader.opts[:custom_pretty_location].merge!(opts)
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
module InstanceMethods
|
|
373
|
+
def generate_location(io, **options)
|
|
374
|
+
custom_pretty_location(io, **options)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def custom_pretty_location(io, name: nil, record: nil, version: nil, derivative: nil, identifier: nil, metadata: {}, **)
|
|
378
|
+
if record
|
|
379
|
+
namespace = record_namespace(record)
|
|
380
|
+
identifier ||= record_identifier(record)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
basename = basic_location(io, metadata: metadata)
|
|
384
|
+
basename = [*(version || derivative), basename].join("-")
|
|
317
385
|
|
|
318
|
-
|
|
319
|
-
module Rack
|
|
320
|
-
class CommonLogger
|
|
321
|
-
alias_method :log_without_assets, :log
|
|
322
|
-
#{'ASSETS_PREFIX = "/#{Rails.application.config.assets.prefix[/\A\/?(.*?)\/?\z/, 1]}/"'}
|
|
323
|
-
def log(env, status, header, began_at)
|
|
324
|
-
unless env['REQUEST_PATH'].start_with?(ASSETS_PREFIX) || env['REQUEST_PATH'].start_with?('/uploads') || env['REQUEST_PATH'].start_with?('/system')
|
|
325
|
-
log_without_assets(env, status, header, began_at)
|
|
386
|
+
[*namespace, *identifier, *name, basename].join("/")
|
|
326
387
|
end
|
|
388
|
+
|
|
389
|
+
private
|
|
390
|
+
|
|
391
|
+
def record_identifier(record)
|
|
392
|
+
id = record.public_send(opts[:custom_pretty_location][:identifier])
|
|
393
|
+
case id
|
|
394
|
+
when Integer
|
|
395
|
+
str_id = "%09d".freeze % id
|
|
396
|
+
str_id.scan(/\\d{3}/).join("/".freeze)
|
|
397
|
+
when String
|
|
398
|
+
id.scan(/.{3}/).first(3).join("/".freeze)
|
|
399
|
+
else
|
|
400
|
+
# NOTE: 'raise' cannot be used. It fails on save.
|
|
401
|
+
nil
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def transform_class_name(class_name)
|
|
406
|
+
if opts[:custom_pretty_location][:class_underscore]
|
|
407
|
+
class_name.gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').gsub(/([a-z])([A-Z])/, '\\1_\\2').downcase
|
|
408
|
+
else
|
|
409
|
+
class_name.downcase
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
def record_namespace(record)
|
|
414
|
+
class_name = record.class.name or return
|
|
415
|
+
parts = transform_class_name(class_name).split("::")
|
|
416
|
+
|
|
417
|
+
if separator = opts[:custom_pretty_location][:namespace]
|
|
418
|
+
parts.join(separator)
|
|
419
|
+
else
|
|
420
|
+
parts.last
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
327
424
|
end
|
|
328
425
|
end
|
|
426
|
+
register_plugin(:custom_pretty_location, CustomPrettyLocation)
|
|
329
427
|
end
|
|
330
428
|
end
|
|
331
429
|
TEXT
|
|
332
430
|
end
|
|
333
431
|
|
|
432
|
+
remove_file 'app/assets/config/manifest.js'
|
|
433
|
+
create_file 'app/assets/config/manifest.js' do <<-TEXT
|
|
434
|
+
//= link_tree ../images
|
|
435
|
+
//= link_directory ../stylesheets .css
|
|
436
|
+
//= link ckcontent.css
|
|
437
|
+
//= link ckeditor/application.css
|
|
438
|
+
//= link ckeditor/application.js
|
|
439
|
+
TEXT
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
remove_file 'config/initializers/assets.rb'
|
|
443
|
+
create_file 'config/initializers/assets.rb' do <<-TEXT
|
|
444
|
+
# Be sure to restart your server when you modify this file.
|
|
445
|
+
|
|
446
|
+
# Version of your assets, change this if you want to expire all your assets.
|
|
447
|
+
Rails.application.config.assets.version = '1.0'
|
|
448
|
+
|
|
449
|
+
# Add additional assets to the asset load path.
|
|
450
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
|
451
|
+
# Add Yarn node_modules folder to the asset load path.
|
|
452
|
+
#Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
|
453
|
+
|
|
454
|
+
# Precompile additional assets.
|
|
455
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
|
456
|
+
# folder are already added.
|
|
457
|
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
|
458
|
+
|
|
459
|
+
TEXT
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
create_file 'config/initializers/shrine.rb' do <<-TEXT
|
|
463
|
+
require "shrine"
|
|
464
|
+
require "shrine/storage/file_system"
|
|
465
|
+
|
|
466
|
+
Shrine.logger = Rails.logger
|
|
467
|
+
|
|
468
|
+
# Choose your favorite image processor
|
|
469
|
+
require 'image_processing/mini_magick'
|
|
470
|
+
SHRINE_PICTURE_PROCESSOR = ImageProcessing::MiniMagick
|
|
471
|
+
|
|
472
|
+
Shrine.storages = {
|
|
473
|
+
# temporary
|
|
474
|
+
cache: Shrine::Storage::FileSystem.new(
|
|
475
|
+
"public",
|
|
476
|
+
prefix: "uploads/cache"
|
|
477
|
+
),
|
|
478
|
+
# permanent
|
|
479
|
+
store: Shrine::Storage::FileSystem.new(
|
|
480
|
+
"public",
|
|
481
|
+
prefix: "uploads"
|
|
482
|
+
),
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
Shrine.plugin :upload_options, cache: { move: true }, store: { move: true }
|
|
486
|
+
|
|
487
|
+
Shrine.plugin :custom_pretty_location, class_underscore: :true
|
|
488
|
+
|
|
489
|
+
Shrine.plugin :determine_mime_type
|
|
490
|
+
#{"Shrine.plugin :mongoid" if mongoid}
|
|
491
|
+
Shrine.plugin :instrumentation
|
|
492
|
+
|
|
493
|
+
Shrine.plugin :activerecord # loads Active Record integration
|
|
494
|
+
Shrine.plugin :cached_attachment_data # enables retaining cached file across form redisplays
|
|
495
|
+
Shrine.plugin :restore_cached_data # extracts metadata for assigned cached files
|
|
496
|
+
|
|
497
|
+
Shrine.plugin :validation_helpers
|
|
498
|
+
Shrine.plugin :derivatives
|
|
499
|
+
|
|
500
|
+
require 'ckeditor/backend/shrine'
|
|
501
|
+
TEXT
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
create_file 'config/initializers/rack.rb' do <<-TEXT
|
|
506
|
+
Rack::Utils.multipart_part_limit = 0
|
|
507
|
+
TEXT
|
|
508
|
+
end
|
|
509
|
+
|
|
334
510
|
create_file 'app/assets/stylesheets/rails_admin/custom/theming.sass' do <<-TEXT
|
|
335
511
|
TEXT
|
|
336
512
|
end
|
|
@@ -431,6 +607,9 @@ Bundler.require(*Rails.groups)
|
|
|
431
607
|
|
|
432
608
|
module #{app_name.camelize}
|
|
433
609
|
class Application < Rails::Application
|
|
610
|
+
# Initialize configuration defaults for originally generated Rails version.
|
|
611
|
+
config.load_defaults 6.0
|
|
612
|
+
|
|
434
613
|
config.generators do |g|
|
|
435
614
|
g.test_framework :rspec
|
|
436
615
|
g.view_specs false
|
|
@@ -472,11 +651,17 @@ create_file 'app/assets/javascripts/application.js' do <<-TEXT
|
|
|
472
651
|
TEXT
|
|
473
652
|
end
|
|
474
653
|
|
|
475
|
-
remove_file 'app/assets/
|
|
476
|
-
create_file 'app/assets/
|
|
654
|
+
remove_file 'app/assets/stylesheets/application.css'
|
|
655
|
+
create_file 'app/assets/stylesheets/application.css' do <<-TEXT
|
|
477
656
|
TEXT
|
|
478
657
|
end
|
|
479
658
|
|
|
659
|
+
create_file 'app/assets/stylesheets/ckcontent.css' do <<-TEXT
|
|
660
|
+
div.red {
|
|
661
|
+
color: red;
|
|
662
|
+
}
|
|
663
|
+
TEXT
|
|
664
|
+
end
|
|
480
665
|
|
|
481
666
|
if mongoid
|
|
482
667
|
FileUtils.cp(Pathname.new(destination_root).join('config', 'mongoid.yml').to_s, Pathname.new(destination_root).join('config', 'mongoid.yml.example').to_s)
|
|
@@ -631,18 +816,57 @@ TEXT
|
|
|
631
816
|
end
|
|
632
817
|
|
|
633
818
|
create_file "spec/support/capybara.rb" do <<-TEXT
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
819
|
+
if ENV['CI']
|
|
820
|
+
Selenium::WebDriver::Chrome.path = '/usr/bin/google-chrome-stable'
|
|
821
|
+
else
|
|
822
|
+
begin
|
|
823
|
+
Selenium::WebDriver::Chrome.path = '/usr/bin/chromium'
|
|
824
|
+
rescue Selenium::WebDriver::Error::WebDriverError
|
|
825
|
+
end
|
|
826
|
+
end
|
|
827
|
+
|
|
828
|
+
Capybara.register_driver :chrome_root do |app|
|
|
829
|
+
service = ::Selenium::WebDriver::Service.chrome#(args: { verbose: true, log_path: 'chromedriver.log' })
|
|
830
|
+
options = ::Selenium::WebDriver::Chrome::Options.new
|
|
831
|
+
options.args << '--headless' unless ENV['NO_HEADLESS']
|
|
832
|
+
options.args << '--no-sandbox'
|
|
833
|
+
options.args << '--window-size=1280,1024'
|
|
834
|
+
|
|
835
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, service: service)
|
|
836
|
+
end
|
|
837
|
+
# не работает, установлено выше
|
|
838
|
+
# Capybara::Screenshot.webkit_options = { width: 1280, height: 1024 }
|
|
839
|
+
|
|
840
|
+
if ENV['CHROME_VISIBLE']
|
|
841
|
+
Capybara.javascript_driver = :selenium_chrome
|
|
842
|
+
else
|
|
843
|
+
Capybara.javascript_driver = :chrome_root
|
|
844
|
+
end
|
|
845
|
+
Capybara.default_driver = :rack_test
|
|
846
|
+
Capybara.default_max_wait_time = 15
|
|
847
|
+
Capybara.register_server :puma do |app, port, host|
|
|
848
|
+
require 'rack/handler/puma'
|
|
849
|
+
Rack::Handler::Puma.run(app, Host: host, Port: port, Threads: "1:1")
|
|
850
|
+
end
|
|
851
|
+
|
|
852
|
+
Capybara.configure do |config|
|
|
853
|
+
config.app_host = "http://\#{Rails.application.secrets.host}"
|
|
854
|
+
config.server = :puma
|
|
855
|
+
config.server_port = 9332
|
|
856
|
+
config.run_server = true
|
|
857
|
+
config.always_include_port = true
|
|
858
|
+
end
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
Capybara::Screenshot.register_driver(:selenium_chrome) do |driver, path|
|
|
862
|
+
driver.browser.save_screenshot(path)
|
|
863
|
+
end
|
|
864
|
+
Capybara::Screenshot.register_driver(:chrome_root) do |driver, path|
|
|
865
|
+
driver.browser.save_screenshot(path)
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
Capybara::Screenshot.autosave_on_failure = true
|
|
869
|
+
|
|
646
870
|
TEXT
|
|
647
871
|
end
|
|
648
872
|
|
|
@@ -745,3 +969,9 @@ end
|
|
|
745
969
|
|
|
746
970
|
git add: "."
|
|
747
971
|
git commit: %Q{ -m 'Initial commit' }
|
|
972
|
+
|
|
973
|
+
unless mongoid
|
|
974
|
+
rake "db:migrate"
|
|
975
|
+
end
|
|
976
|
+
|
|
977
|
+
rake 'db:seed'
|