rocket_cms 0.24.0 → 0.25.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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/app/views/blocks/_counters.html +6 -0
  4. data/app/views/blocks/_footer.slim +1 -1
  5. data/app/views/blocks/_header.slim +1 -1
  6. data/app/views/contact_mailer/{new_message_email.html.haml → new_message_email.html.slim} +8 -8
  7. data/app/views/contacts/{new.html.haml → new.slim} +1 -0
  8. data/app/views/contacts/sent.slim +4 -0
  9. data/app/views/errors/_base.slim +3 -0
  10. data/app/views/errors/{error_403.html.haml → error_403.slim} +0 -0
  11. data/app/views/errors/{error_404.html.haml → error_404.slim} +0 -0
  12. data/app/views/errors/{error_500.html.haml → error_500.slim} +0 -0
  13. data/app/views/home/index.slim +1 -0
  14. data/app/views/layouts/application.slim +39 -0
  15. data/app/views/news/{index.html.haml → index.slim} +2 -2
  16. data/app/views/news/show.slim +11 -0
  17. data/app/views/pages/{show.html.haml → show.slim} +0 -0
  18. data/app/views/rails_admin/main/_check_boxes.html.haml +1 -1
  19. data/app/views/search/index.html.haml +8 -8
  20. data/app/views/shared/{_admin_link.html.haml → _admin_link.slim} +1 -1
  21. data/app/views/shared/{_messages.html.haml → _messages.slim} +2 -2
  22. data/app/views/shared/{_meta.html.haml → _meta.slim} +3 -3
  23. data/app/views/shared/{_obj.html.haml → _obj.slim} +1 -1
  24. data/app/views/shared/_og.slim +8 -0
  25. data/lib/generators/rocket_cms/layout_generator.rb +5 -2
  26. data/lib/generators/rocket_cms/templates/.babelrc +6 -3
  27. data/lib/generators/rocket_cms/templates/Capfile +3 -2
  28. data/lib/generators/rocket_cms/templates/admin.erb +4 -4
  29. data/lib/generators/rocket_cms/templates/deploy.erb +2 -35
  30. data/lib/generators/rocket_cms/templates/package.json +21 -15
  31. data/lib/generators/rocket_cms/templates/webpack.config.js +87 -53
  32. data/lib/generators/rocket_cms/templates/webpack/analytics.es6 +29 -0
  33. data/lib/generators/rocket_cms/templates/webpack/application.es6 +23 -13
  34. data/lib/generators/rocket_cms/templates/webpack/blocks/footer/index.sass +2 -0
  35. data/lib/generators/rocket_cms/templates/webpack/blocks/header/index.sass +1 -0
  36. data/lib/generators/rocket_cms/templates/webpack/blocks/index.es6 +4 -0
  37. data/lib/generators/rocket_cms/templates/webpack/common/index.sass +2 -0
  38. data/lib/generators/rocket_cms/templates/webpack/common/mixins.sass +5 -0
  39. data/lib/generators/rocket_cms/templates/webpack/common/variables.sass +1 -0
  40. data/lib/generators/rocket_cms/templates/webpack/errors/errors.pug +7 -0
  41. data/lib/generators/rocket_cms/templates/webpack/errors/index.es6 +1 -1
  42. data/lib/generators/rocket_cms/templates/webpack/fonts/index.sass +6 -0
  43. data/lib/generators/rocket_cms/templates/webpack/fonts/mixin.sass +25 -0
  44. data/lib/generators/rocket_cms/templates/webpack/layout/buttons.sass +23 -0
  45. data/lib/generators/rocket_cms/templates/webpack/layout/index.sass +5 -0
  46. data/lib/generators/rocket_cms/templates/webpack/layout/main.sass +20 -0
  47. data/lib/generators/rocket_cms/templates/webpack/layout/typography.sass +4 -0
  48. data/lib/generators/rocket_cms/templates/webpack/pages/home/index.es6 +1 -0
  49. data/lib/generators/rocket_cms/templates/webpack/pages/index.es6 +2 -0
  50. data/lib/generators/rocket_cms/webpack_generator.rb +26 -4
  51. data/lib/rocket_cms/version.rb +1 -1
  52. data/template.rb +65 -111
  53. metadata +36 -21
  54. data/app/views/contacts/sent.html.haml +0 -4
  55. data/app/views/errors/_base.html.haml +0 -3
  56. data/app/views/home/index.html.haml +0 -1
  57. data/app/views/layouts/application.html.slim +0 -33
  58. data/app/views/news/show.html.haml +0 -8
  59. data/app/views/shared/_og.html.haml +0 -8
  60. data/lib/generators/rocket_cms/templates/webpack/application.sass +0 -6
  61. data/lib/generators/rocket_cms/templates/webpack/errors/errors.handlebars +0 -9
@@ -2,36 +2,39 @@
2
2
 
3
3
  var path = require('path');
4
4
  var webpack = require('webpack');
5
- var functions = require('postcss-functions');
6
- var StatsPlugin = require('stats-webpack-plugin');
5
+ var ManifestPlugin = require('webpack-manifest-plugin');
7
6
 
8
7
  var ExtractTextPlugin = require("extract-text-webpack-plugin");
9
-
10
8
  var autoprefixer = require('autoprefixer');
11
9
  var CompressionPlugin = require("compression-webpack-plugin");
12
10
 
13
11
  var host = process.env.HOST || 'localhost'
14
- var devServerPort = 3808;
12
+ var devServerPort = <%= port %>;
15
13
 
16
14
  var production = process.env.NODE_ENV === 'production';
17
15
 
18
16
  const extractSass = new ExtractTextPlugin({
19
- filename: production ? "[name].[contenthash].css" : "[name].css",
17
+ filename: production ? "[name]-[chunkhash].css" : "[name].css",
20
18
  });
21
19
 
22
- //console.log("dir:", __dirname)
23
-
24
20
  var sassExtractor = () => {
25
- return ['css-hot-loader'].concat(extractSass.extract({
21
+ return ['extracted-loader'].concat(extractSass.extract({
26
22
  use: [{
23
+ loader: "babel-loader",
24
+ options: {
25
+ cacheDirectory: true
26
+ }
27
+ }, {
27
28
  loader: "css-loader",
28
29
  options: {
29
- sourceMap: true
30
+ minimize: !production,
31
+ sourceMap: !production,
30
32
  }
31
33
  }, {
32
34
  loader: "sass-loader",
33
35
  options: {
34
- sourceMap: true
36
+ sourceMap: !production,
37
+ includePaths: [path.resolve(__dirname, "..", "webpack")]
35
38
  }
36
39
  }],
37
40
  fallback: "style-loader"
@@ -39,29 +42,52 @@ var sassExtractor = () => {
39
42
  }
40
43
 
41
44
  var config = {
45
+ mode: production ? "production" : "development",
42
46
  entry: {
43
- // Sources are expected to live in $app_root/webpack
44
- vendor: [
45
- 'babel-polyfill',
46
- 'axios',
47
- 'jquery',
48
- 'lodash',
49
- ],
50
- application: 'application.es6'
47
+ // Sources are expected to live in $app_root
48
+ //vendor: [],
49
+ application: 'application.es6',
51
50
  },
52
51
 
53
52
  module: {
54
53
  rules: [
55
- { test: /\.es6/, use: "babel-loader" },
56
- { test: /\.handlebars$/, use: "handlebars-loader" },
57
- { test: /\.(jpe?g|png|gif)$/i, use: "file-loader" },
58
54
  {
59
- test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
60
- use: production ? 'file-loader' : 'url-loader'
55
+ test: /(\.es6)$/,
56
+ use: {
57
+ loader: "babel-loader",
58
+ options: {
59
+ cacheDirectory: true
60
+ }
61
+ }
62
+ },
63
+ {
64
+ test: /(\.pug)$/,
65
+ loader: "pug-loader",
66
+ query: {}
67
+ },
68
+ {
69
+ test: /\.vue/,
70
+ use: {
71
+ loader: "vue-loader",
72
+ }
73
+ },
74
+ {
75
+ test: /\.(jpe?g|png|gif)$/i,
76
+ use: "file-loader"
77
+ },
78
+ {
79
+ test: /\.svg$/i,
80
+ exclude: /inline/i,
81
+ use: "file-loader"
82
+ },
83
+ {
84
+ test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.otf($|\?)|\.eot($|\?)/,
85
+ use: 'file-loader'
86
+ },
87
+ {
88
+ test: /\.(s?css|sass)$/i,
89
+ use: sassExtractor()
61
90
  },
62
- { test: /\.sass$/, use: sassExtractor() },
63
- { test: /\.scss$/, use: sassExtractor() },
64
- { test: /\.css$/, use: sassExtractor() }
65
91
  ]
66
92
  },
67
93
 
@@ -70,51 +96,58 @@ var config = {
70
96
  // that all webpacked assets start with webpack/
71
97
 
72
98
  // must match config.webpack.output_dir
73
- path: path.join(__dirname, '..', 'public', 'webpack'),
99
+ path: path.join(__dirname, "..", "public", "webpack"),
74
100
  publicPath: '/webpack/',
75
101
 
76
- filename: production ? '[name]-[chunkhash].js' : '[name].js'
102
+ filename: production ? '[name]-[chunkhash].js' : '[name].js',
103
+ chunkFilename: production ? '[name]-[chunkhash].js' : '[name].js',
77
104
  },
78
105
 
79
106
  resolve: {
80
- modules: [path.resolve(__dirname, "..", "webpack"), path.resolve(__dirname, "..", "node_modules")],
81
- extensions: [".js", ".es6", ".css", ".sass", ".scss"],
107
+ modules: [
108
+ path.resolve(__dirname, "..", "webpack"),
109
+ path.resolve(__dirname, "..", "node_modules"),
110
+ ],
111
+ extensions: [".es6", ".vue", ".sass", ".css", ".js"],
112
+ alias: {
113
+ '~': path.resolve(__dirname, "..", "webpack"),
114
+ }
82
115
  },
83
116
 
84
117
  plugins: [
85
118
  extractSass,
86
- new StatsPlugin('manifest.json', {
87
- chunkModules: false,
88
- source: false,
89
- chunks: false,
90
- modules: false,
91
- assets: true
119
+ new ManifestPlugin({
120
+ writeToFileEmit: true,
121
+ publicPath: production ? "/webpack/" : 'http://' + host + ':' + devServerPort + '/webpack/',
92
122
  }),
93
123
  new webpack.ProvidePlugin({
94
- $: "jquery/dist/jquery",
95
- jQuery: "jquery/dist/jquery",
96
- "window.jQuery": "jquery/dist/jquery",
97
- //Tether: "tether",
98
- //"window.Tether": "tether",
99
- "_": "lodash",
100
- "window._": "lodash",
101
- //Alert: "exports-loader?Alert!bootstrap/js/dist/alert",
102
- //Button: "exports-loader?Button!bootstrap/js/dist/button",
124
+ $: "jquery",
125
+ jQuery: "jquery",
126
+ "window.jQuery": "jquery",
103
127
  })
104
- ]
128
+ ],
129
+ optimization: {
130
+ runtimeChunk: { name: 'vendor' },
131
+ splitChunks: {
132
+ chunks: "initial",
133
+ cacheGroups: {
134
+ default: false,
135
+ vendors: {
136
+ chunks: "initial",
137
+ test: /[\\/]node_modules[\\/]/,
138
+ priority: -10,
139
+ name: "vendor",
140
+ },
141
+ },
142
+ },
143
+ },
105
144
  };
106
145
 
107
146
  if (production) {
108
147
  config.plugins.push(
109
- new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor-[chunkhash].js'}),
110
- new webpack.optimize.UglifyJsPlugin({
111
- compressor: { warnings: false },
112
- sourceMap: false
113
- }),
114
148
  new webpack.DefinePlugin({ // <--key to reduce React's size
115
149
  'process.env': { NODE_ENV: JSON.stringify('production') }
116
150
  }),
117
- new webpack.optimize.ModuleConcatenationPlugin(),
118
151
  new CompressionPlugin({
119
152
  asset: "[path].gz",
120
153
  algorithm: "gzip",
@@ -123,9 +156,9 @@ if (production) {
123
156
  minRatio: 0.8
124
157
  })
125
158
  );
159
+ config.output.publicPath = '/webpack/';
126
160
  } else {
127
161
  config.plugins.push(
128
- new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js'}),
129
162
  new webpack.NamedModulesPlugin()
130
163
  )
131
164
 
@@ -135,6 +168,7 @@ if (production) {
135
168
  headers: { 'Access-Control-Allow-Origin': '*' },
136
169
  };
137
170
  config.output.publicPath = 'http://' + host + ':' + devServerPort + '/webpack/';
171
+ // Source maps
138
172
  config.devtool = 'source-map';
139
173
  }
140
174
 
@@ -0,0 +1,29 @@
1
+ var old_url = window.location.href;
2
+
3
+ document.addEventListener("turbolinks:load", function() {
4
+ //console.log("analytics load");
5
+
6
+ if (window[metrika]) {
7
+ window[metrika].hit(window.location.href, document.title, old_url)
8
+ }
9
+ old_url = window.location.href
10
+
11
+ if (window.gtag) {
12
+ gtag('event', 'page_view');
13
+ // gtag('event', 'page_view', { 'send_to': 'YOUR_ID_HERE' });
14
+ }
15
+ });
16
+
17
+ export default function(name) {
18
+ if (window[metrika] && window[metrika].reachGoal) {
19
+ window[metrika].reachGoal(name);
20
+ } else {
21
+ if (window.console) {
22
+ console.log('unable to send event - no metrika');
23
+ }
24
+ }
25
+
26
+ //if (window.gtag) {
27
+ //gtag('event', name);
28
+ //}
29
+ };
@@ -1,20 +1,30 @@
1
- //import 'font-awesome/css/font-awesome.css';
2
- import 'application.sass';
3
- import 'rails-ujs';
1
+ import './fonts';
2
+ import './layout';
3
+
4
4
  import Errors from 'errors';
5
5
  import 'flash';
6
- //import 'bootstrap';
7
-
8
- window.A = {}
9
- A.errors = new Errors()
10
6
 
11
- $(function() {
12
- A.errors.checkCookie();
7
+ var errors = new Errors()
8
+ document.addEventListener("DOMContentLoaded", function(event) {
9
+ errors.checkCookie();
13
10
  });
14
11
 
15
- //import Turbolinks from "turbolinks";
16
- //Turbolinks.start()
12
+ import Turbolinks from "turbolinks";
13
+ Turbolinks.start()
14
+
15
+ import Rails from 'rails-ujs';
16
+ Rails.start();
17
+
18
+ import axios from 'axios';
17
19
 
18
- //document.addEventListener("turbolinks:load", function() {
19
- //})
20
+ import "./blocks";
21
+ import "./pages";
22
+
23
+ import "analytics"
24
+ //import goal from "analytics"
25
+
26
+ document.addEventListener("turbolinks:load", function() {
27
+ axios.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
28
+ axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
29
+ });
20
30
 
@@ -0,0 +1,4 @@
1
+ // import your blocks here
2
+ import "./header";
3
+ import "./footer";
4
+
@@ -0,0 +1,2 @@
1
+ @import './mixins'
2
+ @import './variables'
@@ -0,0 +1,5 @@
1
+ =clearfix
2
+ &:after
3
+ content: ''
4
+ display: table
5
+ clear: both
@@ -0,0 +1,7 @@
1
+ .errors
2
+ .errors-inner
3
+ h3= title
4
+ a(target="_blank" href=link)
5
+ = anchor
6
+ = message
7
+
@@ -1,6 +1,6 @@
1
1
  import './index.sass';
2
2
  import Cookies from 'js-cookie';
3
- import template from './errors.handlebars';
3
+ import template from './errors.pug';
4
4
 
5
5
  const COOKIE_ERROR = {
6
6
  title: 'В вашем броузере отключены Cookies',
@@ -0,0 +1,6 @@
1
+ @import '~common'
2
+ @import 'mixin'
3
+
4
+ // +font-face('Circe', './Circe/Circe-Light', 300)
5
+ // +font-face('Circe', './Circe/Circe-Bold', 700)
6
+ // +font-face('Circe', './Circe/Circe-ExtraBold', 800)
@@ -0,0 +1,25 @@
1
+ @function str-replace($string, $search, $replace: "")
2
+ $index: str-index($string, $search)
3
+
4
+ @if $index
5
+ @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace)
6
+ @return $string
7
+
8
+ =font-face($name, $path, $weight: null, $style: null, $exts: woff2 woff ttf)
9
+ $src: null
10
+
11
+ //$extmods: (eot: "?", svg: "#" + str-replace($name, " ", "_"))
12
+ $extmods: ()
13
+
14
+ $formats: (otf: "opentype", ttf: "truetype")
15
+
16
+ @each $ext in $exts
17
+ $extmod: if(map-has-key($extmods, $ext), $ext + map-get($extmods, $ext), $ext)
18
+ $format: if(map-has-key($formats, $ext), map-get($formats, $ext), $ext)
19
+ $src: append($src, url(quote($path + "." + $extmod)) format(quote($format)), comma)
20
+
21
+ @font-face
22
+ font-family: quote($name)
23
+ font-style: $style
24
+ font-weight: $weight
25
+ src: $src
@@ -0,0 +1,23 @@
1
+ .btn
2
+ padding-left: 30px
3
+ padding-right: 30px
4
+ padding-top: 11px
5
+ padding-bottom: 11px
6
+ font-family: Raleway, sans-serif
7
+ font-size: 14px
8
+ text-decoration: none
9
+ text-transform: uppercase
10
+ font-weight: 700
11
+ line-height: 20px
12
+ letter-spacing: 1px
13
+ cursor: pointer
14
+ display: inline-block
15
+
16
+ &-primary
17
+ background-color: #e14b4b
18
+ border: 1px solid #e14b4b
19
+ color: #ffffff
20
+ transition: background-color 0.3s ease, border 0.3s ease
21
+ &:hover
22
+ background-color: darken(#e14b4b, 20%)
23
+ border: 1px solid darken(#e14b4b, 20%)
@@ -0,0 +1,5 @@
1
+ @import "~common"
2
+
3
+ @import "./main"
4
+ @import "./typography"
5
+ @import "./buttons"
@@ -0,0 +1,20 @@
1
+ *
2
+ box-sizing: border-box
3
+
4
+ html, body
5
+ height: 100%
6
+
7
+ html
8
+ font-size: 14px
9
+ text-rendering: optimizeLegibility
10
+ -webkit-font-smoothing: antialiased
11
+ -moz-osx-font-smoothing: grayscale
12
+ overflow-y: scroll
13
+
14
+ body
15
+ width: 100%
16
+ margin: 0
17
+ padding: 0
18
+ font-family: sans-serif
19
+
20
+
@@ -0,0 +1,4 @@
1
+ h1
2
+ font-size: 40px
3
+ h2
4
+ font-size: 30px
@@ -0,0 +1 @@
1
+ // import page-specific blocks here
@@ -0,0 +1,2 @@
1
+ // import your pages here
2
+ import "./home"
@@ -2,6 +2,8 @@ require 'rails/generators'
2
2
 
3
3
  module RocketCms
4
4
  class WebpackGenerator < Rails::Generators::Base
5
+ argument :port, type: :string
6
+
5
7
  source_root File.expand_path('../templates', __FILE__)
6
8
  def app_name
7
9
  Rails.application.class.name.split("::")[0]
@@ -10,20 +12,40 @@ module RocketCms
10
12
  desc 'RocketCMS webpack generator'
11
13
  def install
12
14
  copy_file ".babelrc", ".babelrc"
13
- copy_file "webpack.config.js", "config/webpack.config.js"
14
15
 
15
- copy_file "webpack/application.es6", "webpack/application.es6"
16
- copy_file "webpack/application.sass", "webpack/application.sass"
16
+ copy_file "webpack/common/mixins.sass", "webpack/common/mixins.sass"
17
+ copy_file "webpack/common/variables.sass", "webpack/common/variables.sass"
18
+ copy_file "webpack/common/index.sass", "webpack/common/index.sass"
17
19
 
20
+ copy_file "webpack/errors/errors.pug", "webpack/errors/errors.pug"
18
21
  copy_file "webpack/errors/index.es6", "webpack/errors/index.es6"
19
22
  copy_file "webpack/errors/index.sass", "webpack/errors/index.sass"
20
- copy_file "webpack/errors/errors.handlebars", "webpack/errors/errors.handlebars"
21
23
 
22
24
  copy_file "webpack/flash/index.es6", "webpack/flash/index.es6"
23
25
  copy_file "webpack/flash/index.sass", "webpack/flash/index.sass"
24
26
 
27
+ copy_file "webpack/fonts/index.sass", "webpack/fonts/index.sass"
28
+ copy_file "webpack/fonts/mixin.sass", "webpack/fonts/mixin.sass"
29
+
30
+ copy_file "webpack/layout/buttons.sass", "webpack/layout/buttons.sass"
31
+ copy_file "webpack/layout/index.sass", "webpack/layout/index.sass"
32
+ copy_file "webpack/layout/main.sass", "webpack/layout/main.sass"
33
+ copy_file "webpack/layout/typography.sass", "webpack/layout/typography.sass"
34
+
35
+ copy_file "webpack/blocks/index.es6", "webpack/blocks/index.es6"
36
+ copy_file "webpack/blocks/header/index.sass", "webpack/blocks/header/index.sass"
37
+ copy_file "webpack/blocks/footer/index.sass", "webpack/blocks/footer/index.sass"
38
+
39
+ copy_file "webpack/pages/index.es6", "webpack/pages/index.es6"
40
+ copy_file "webpack/pages/home/index.es6", "webpack/pages/home/index.es6"
41
+
42
+ copy_file "webpack/analytics.es6", "webpack/analytics.es6"
43
+ copy_file "webpack/application.es6", "webpack/application.es6"
44
+
25
45
  remove_file "package.json"
46
+
26
47
  template "package.json", "package.json"
48
+ template "webpack.config.js", "config/webpack.config.js"
27
49
  end
28
50
  end
29
51
  end