locomotivecms_wagon 3.0.0.beta2 → 3.0.0.rc0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/generators/blank/.gitignore +7 -0
- data/generators/blank/Gemfile.tt +0 -2
- data/generators/blank/app/assets/.babelrc +2 -1
- data/generators/blank/app/assets/javascripts/sections/index.js +1 -1
- data/generators/blank/app/assets/webpack.common.js +13 -3
- data/generators/blank/app/assets/webpack.dev.js +5 -1
- data/generators/blank/app/views/pages/layouts/default.liquid +4 -0
- data/generators/blank/config/site.yml.tt +4 -0
- data/generators/blank/{app/assets/package.json.tt → package.json.tt} +10 -9
- data/generators/cloned/Gemfile.tt +0 -2
- data/generators/content_type/app/content_types/%slug%.yml.tt +4 -0
- data/generators/public_form/content_type.yml.tt +53 -0
- data/generators/public_form/page.liquid.tt +75 -0
- data/generators/webpack/app/assets/.babelrc +4 -0
- data/generators/webpack/app/assets/fonts/.empty_directory +1 -0
- data/generators/webpack/app/assets/javascripts/app.js +19 -0
- data/generators/webpack/app/assets/javascripts/sections/_manager.js +94 -0
- data/generators/webpack/app/assets/javascripts/sections/index.js +5 -0
- data/generators/webpack/app/assets/postcss.config.js +6 -0
- data/generators/webpack/app/assets/stylesheets/app.scss +1 -0
- data/generators/webpack/app/assets/webpack.common.js +57 -0
- data/generators/webpack/app/assets/webpack.dev.js +11 -0
- data/generators/webpack/app/assets/webpack.prod.js +12 -0
- data/generators/webpack/package.json.tt +36 -0
- data/lib/locomotive/wagon/cli.rb +21 -4
- data/lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb +1 -1
- data/lib/locomotive/wagon/commands/serve_command.rb +1 -6
- data/lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb +1 -1
- data/lib/locomotive/wagon/generators/public_form.rb +97 -0
- data/lib/locomotive/wagon/generators/site.rb +0 -1
- data/lib/locomotive/wagon/generators/webpack.rb +29 -0
- data/lib/locomotive/wagon/tools/listen.rb +10 -4
- data/lib/locomotive/wagon/version.rb +1 -1
- data/locomotivecms_wagon.gemspec +1 -2
- data/spec/fixtures/cassettes/authenticate.yml +42 -42
- data/spec/fixtures/cassettes/delete.yml +232 -232
- data/spec/fixtures/cassettes/push.yml +1728 -1728
- data/spec/fixtures/cassettes/sync.yml +1999 -1999
- data/spec/unit/decorators/content_entry_decorator_spec.rb +1 -1
- data/spec/unit/decorators/site_decorator_spec.rb +28 -3
- metadata +21 -22
- data/generators/blank/Guardfile +0 -22
- data/generators/cloned/Guardfile +0 -22
- data/lib/locomotive/wagon/generators/site/unzip.rb +0 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be2e4bcabdf447758386d1952580b9d12917117aae509c4f477e3db10debd744
|
4
|
+
data.tar.gz: 586222a4234b54ad585022b81574c53b7e8846bf5b95f62a0522e5de595ac20a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e786b0893b808d9e4eef0402781e0aa489dcf0cbc110ebe48c56dcc93979c2f6484eb77015952f79871ab1e48cffdc860e028234584ffa810f45dd8af33c2ea1
|
7
|
+
data.tar.gz: 06fdd25d3af7dc1c5bf37a8c471705fec58724583bca578be72b617181405b22b4bff160cb666910937547ed94ca4ed9b7bf464d25035a591d6d62282c00be0f
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ gem 'rb-fsevent', '~> 0.9.1'
|
|
8
8
|
# Development
|
9
9
|
# gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '4d1bd56' , require: false
|
10
10
|
# gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: '01a0a32', require: false
|
11
|
-
# gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '
|
11
|
+
# gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'dabf63f67b', require: false
|
12
12
|
# gem 'duktape', github: 'judofyr/duktape.rb', ref: '20ef6a5'
|
13
13
|
|
14
14
|
# Local development
|
data/generators/blank/Gemfile.tt
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
const path = require('path');
|
2
|
+
const Webpack = require('webpack');
|
2
3
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
3
4
|
|
4
5
|
module.exports = {
|
5
|
-
entry: './javascripts/app.js',
|
6
|
+
entry: './app/assets/javascripts/app.js',
|
6
7
|
output: {
|
7
8
|
path: path.resolve(__dirname, '../../public'),
|
8
9
|
filename: 'javascripts/bundle.js'
|
@@ -12,8 +13,12 @@ module.exports = {
|
|
12
13
|
{
|
13
14
|
test: /\.(js|jsx|es6)$/,
|
14
15
|
exclude: /(node_modules|bower_components)/,
|
15
|
-
|
16
|
-
|
16
|
+
use: {
|
17
|
+
loader: 'babel-loader',
|
18
|
+
options: {
|
19
|
+
presets: ['@babel/preset-env']
|
20
|
+
}
|
21
|
+
}
|
17
22
|
},
|
18
23
|
{
|
19
24
|
test: /\.scss$/,
|
@@ -42,6 +47,11 @@ module.exports = {
|
|
42
47
|
]
|
43
48
|
},
|
44
49
|
plugins: [
|
50
|
+
new Webpack.ProvidePlugin({
|
51
|
+
$: 'jquery',
|
52
|
+
jQuery: 'jquery',
|
53
|
+
'window.jQuery': 'jquery'
|
54
|
+
}),
|
45
55
|
new MiniCssExtractPlugin({ filename: 'stylesheets/bundle.css', allChunks: true })
|
46
56
|
]
|
47
57
|
};
|
@@ -1,7 +1,11 @@
|
|
1
1
|
const merge = require('webpack-merge');
|
2
2
|
const common = require('./webpack.common.js');
|
3
|
+
const LiveReloadPlugin = require('webpack-livereload-plugin');
|
3
4
|
|
4
5
|
module.exports = merge(common, {
|
5
6
|
mode: 'development',
|
6
|
-
devtool: 'inline-source-map'
|
7
|
+
devtool: 'inline-source-map',
|
8
|
+
plugins: [
|
9
|
+
new LiveReloadPlugin()
|
10
|
+
]
|
7
11
|
});
|
@@ -4,9 +4,9 @@
|
|
4
4
|
"description": "Assets source for the <%= config[:name] %> website",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
|
-
"start": "webpack --config webpack.dev.js --progress --colors --watch",
|
8
|
-
"build:dev": "webpack --config webpack.dev.js --progress",
|
9
|
-
"build:prod": "NODE_ENV=production webpack --config webpack.prod.js --progress",
|
7
|
+
"start": "webpack --config app/assets/webpack.dev.js --progress --colors --watch",
|
8
|
+
"build:dev": "webpack --config app/assets/webpack.dev.js --progress",
|
9
|
+
"build:prod": "NODE_ENV=production webpack --config app/assets/webpack.prod.js --progress --mode production",
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
11
11
|
},
|
12
12
|
"author": "Wagon",
|
@@ -14,11 +14,13 @@
|
|
14
14
|
"dependencies": {
|
15
15
|
},
|
16
16
|
"devDependencies": {
|
17
|
-
"babel
|
18
|
-
"babel-
|
19
|
-
"babel-
|
20
|
-
"babel
|
17
|
+
"@babel/core": "^7.4.3",
|
18
|
+
"@babel/plugin-proposal-class-properties": "^7.4.0",
|
19
|
+
"babel-loader": "^8.0.5",
|
20
|
+
"@babel/preset-env": "^7.4.3",
|
21
21
|
"css-loader": "^0.28.11",
|
22
|
+
"file-loader": "^1.1.11",
|
23
|
+
"image-webpack-loader": "^4.3.0",
|
22
24
|
"mini-css-extract-plugin": "^0.4.0",
|
23
25
|
"node-sass": "^4.9.0",
|
24
26
|
"optimize-css-assets-webpack-plugin": "^4.0.2",
|
@@ -29,7 +31,6 @@
|
|
29
31
|
"webpack": "^4.20.2",
|
30
32
|
"webpack-cli": "^3.1.1",
|
31
33
|
"webpack-merge": "^4.1.4",
|
32
|
-
"
|
33
|
-
"image-webpack-loader": "^4.3.0"
|
34
|
+
"webpack-livereload-plugin": "^2.2.0"
|
34
35
|
}
|
35
36
|
}
|
@@ -25,6 +25,10 @@ order_by: manually
|
|
25
25
|
# Array of emails to be notified of new entries made with the public API
|
26
26
|
# public_submission_accounts: ['john@example.com']
|
27
27
|
|
28
|
+
# we recommend to require Google Recaptcha when submitting the form
|
29
|
+
# if the public submission attribute is enabled in order to prevent spams
|
30
|
+
# recaptcha_required: true
|
31
|
+
|
28
32
|
# Control the display of the content type in the back-office.
|
29
33
|
# display_settings:
|
30
34
|
# seo: false # display the SEO tab for the content entries
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Human readable name of this type
|
2
|
+
name: <%= config[:name] %>
|
3
|
+
|
4
|
+
# Lowercase, underscored handle used to access this type
|
5
|
+
slug: <%= config[:slug] %>
|
6
|
+
|
7
|
+
# Explanatory text displayed in the back-office
|
8
|
+
description: Public form
|
9
|
+
|
10
|
+
# Slug of field used to identify entries by default, such as the title
|
11
|
+
label_field_name: 'email'
|
12
|
+
|
13
|
+
# Valid values: manually, created_at, updated_at, or the slug of any field
|
14
|
+
order_by: created_at
|
15
|
+
|
16
|
+
# Valid values: asc (ascending) and desc (descending). Set to asc by default.
|
17
|
+
order_direction: desc
|
18
|
+
|
19
|
+
# Activate public 'create' API (e.g for a contact form)
|
20
|
+
public_submission_enabled: true
|
21
|
+
|
22
|
+
# Array of emails to be notified of new entries made with the public API
|
23
|
+
# public_submission_accounts: ['john@example.com']
|
24
|
+
|
25
|
+
# Prevent spams thanks to Google Recaptcha
|
26
|
+
recaptcha_required: true
|
27
|
+
|
28
|
+
# Control the display of the content type in the back-office.
|
29
|
+
display_settings:
|
30
|
+
seo: false # display the SEO tab for the content entries
|
31
|
+
advanced: false # display the Advanced tab for the content entries
|
32
|
+
# position: 1 # position in the sidebar menu
|
33
|
+
# hidden: false # hidden for authors?
|
34
|
+
|
35
|
+
# By default, the back-office displays the _label property (see label_field_name) of the content entry. This can be modified by writing your own Liquid template below:
|
36
|
+
# entry_template: '<a href="{{ link }}">{{ entry._label }}</a>' # The default template
|
37
|
+
|
38
|
+
# A list describing each field
|
39
|
+
fields:
|
40
|
+
- name:
|
41
|
+
label: Name
|
42
|
+
type: string
|
43
|
+
required: true
|
44
|
+
|
45
|
+
- email:
|
46
|
+
label: Email
|
47
|
+
type: email
|
48
|
+
required: true
|
49
|
+
|
50
|
+
- message:
|
51
|
+
label: Message
|
52
|
+
type: text
|
53
|
+
required: true
|
@@ -0,0 +1,75 @@
|
|
1
|
+
---
|
2
|
+
title: <%= config[:title] %>
|
3
|
+
|
4
|
+
# If you want to reference that page in other templates. Ex: {% path_to '<%= config[:handle] %>' %}
|
5
|
+
handle: <%= config[:handle] %>
|
6
|
+
|
7
|
+
# true if the page is included in the menu
|
8
|
+
published: true
|
9
|
+
|
10
|
+
# true if the page is published
|
11
|
+
listed: true
|
12
|
+
|
13
|
+
# position among sibling pages
|
14
|
+
# position: 1
|
15
|
+
---
|
16
|
+
{% extends parent %}
|
17
|
+
|
18
|
+
{% block main %}
|
19
|
+
|
20
|
+
{% model_form '<%= config[:content_type] %>', class: 'form', recaptcha: true %}
|
21
|
+
|
22
|
+
{% if user_message.errors %}
|
23
|
+
<p>Your form has errors</p>
|
24
|
+
{% else %}
|
25
|
+
{% if user_message != nil %}
|
26
|
+
<p>Your form has been posted with success</p>
|
27
|
+
{% endif %}
|
28
|
+
{% endif %}
|
29
|
+
|
30
|
+
<div class="field">
|
31
|
+
<label class="label">Name</label>
|
32
|
+
<div class="control">
|
33
|
+
<input type="text" name="content[name]" placeholder="Your full name" value="{{ <%= config[:content_type].singularize %>.name }}" class="input {% if user_message.errors.name %}is-danger{% endif %}" />
|
34
|
+
{% if user_message.errors.name %}
|
35
|
+
<p class="help is-danger">{{ user_message.errors.name }}</p>
|
36
|
+
{% endif %}
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="field">
|
41
|
+
<label class="label">Email</label>
|
42
|
+
<div class="control">
|
43
|
+
<input type="email" name="content[email]" placeholder="Your email address" value="{{ <%= config[:content_type].singularize %>.email }}" class="input {% if user_message.errors.email %}is-danger{% endif %}" />
|
44
|
+
{% if user_message.errors.email %}
|
45
|
+
<p class="help is-danger">{{ user_message.errors.email }}</p>
|
46
|
+
{% endif %}
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<div class="field">
|
51
|
+
<label class="label">Message</label>
|
52
|
+
<div class="control">
|
53
|
+
<textarea class="textarea" name="content[message]" placeholder="Anything you need">{{ <%= config[:content_type].singularize %>.message }}</textarea>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div class="field ">
|
58
|
+
<div class="control">
|
59
|
+
<button class="button is-link">Submit</button>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
|
63
|
+
{% endmodel_form %}
|
64
|
+
|
65
|
+
<script src="https://www.google.com/recaptcha/api.js?render={{ site.metafields.google.recaptcha_site_key }}"></script>
|
66
|
+
|
67
|
+
<script>
|
68
|
+
grecaptcha.ready(function() {
|
69
|
+
grecaptcha.execute('{{ site.metafields.google.recaptcha_site_key }}', {action: 'register'}).then(function(token) {
|
70
|
+
document.getElementById('g-recaptcha-response').value = token;
|
71
|
+
});
|
72
|
+
});
|
73
|
+
</script>
|
74
|
+
|
75
|
+
{% endblock %}
|
@@ -0,0 +1 @@
|
|
1
|
+
.empty_directory
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// === Wagon main javascript file ===
|
2
|
+
|
3
|
+
// Tell Webpack to load the style
|
4
|
+
import '../stylesheets/app.scss';
|
5
|
+
|
6
|
+
// Import the classes required to handle sections
|
7
|
+
import SectionsManager from './sections/_manager';
|
8
|
+
import * as Sections from './sections';
|
9
|
+
|
10
|
+
document.addEventListener('DOMContentLoaded', event => {
|
11
|
+
|
12
|
+
// Load all the sections
|
13
|
+
const sectionsManager = new SectionsManager();
|
14
|
+
|
15
|
+
// Register sections here. DO NOT REMOVE OR UPDATE THIS LINE
|
16
|
+
|
17
|
+
sectionsManager.start();
|
18
|
+
|
19
|
+
});
|
@@ -0,0 +1,94 @@
|
|
1
|
+
class Manager {
|
2
|
+
|
3
|
+
constructor() {
|
4
|
+
this.sections = {};
|
5
|
+
}
|
6
|
+
|
7
|
+
registerSection(type, actions) {
|
8
|
+
console.log(type, actions);
|
9
|
+
this.sections[type] = actions;
|
10
|
+
}
|
11
|
+
|
12
|
+
start() {
|
13
|
+
this.eachType((type, actions) => {
|
14
|
+
this.queryAll(`.locomotive-section[data-locomotive-section-type="${type}"]`).forEach((section, index) => {
|
15
|
+
this.runAction(actions, 'load', section);
|
16
|
+
});
|
17
|
+
});
|
18
|
+
this.registerEvents();
|
19
|
+
|
20
|
+
window._sectionsManager = this;
|
21
|
+
}
|
22
|
+
|
23
|
+
registerEvents() {
|
24
|
+
const events = {
|
25
|
+
section: ['load', 'unload', 'select', 'deselect', 'reorder'],
|
26
|
+
block: ['select', 'deselect']
|
27
|
+
}
|
28
|
+
|
29
|
+
for (var namespace in events) {
|
30
|
+
events[namespace].forEach(eventType => {
|
31
|
+
const eventName = `locomotive::${namespace}::${eventType}`;
|
32
|
+
const actionName = this.eventTypeToActionName(namespace, eventType);
|
33
|
+
|
34
|
+
document.addEventListener(eventName, event => {
|
35
|
+
this.applyRuleToEvent(actionName, event);
|
36
|
+
});
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
applyRuleToEvent(actionName, event) {
|
42
|
+
const { sectionId, blockId } = event.detail;
|
43
|
+
const section = document.getElementById(`locomotive-section-${sectionId}`);
|
44
|
+
const type = section.getAttribute('data-locomotive-section-type');
|
45
|
+
const block = this.queryOne(`[data-locomotive-block="section-${sectionId}-block-${blockId}"]`, section);
|
46
|
+
|
47
|
+
this.runAction(this.sections[type], actionName, section, block)
|
48
|
+
}
|
49
|
+
|
50
|
+
eventTypeToActionName(namespace, eventType) {
|
51
|
+
if (namespace === 'section')
|
52
|
+
return eventType;
|
53
|
+
else
|
54
|
+
return namespace + eventType.charAt(0).toUpperCase() + eventType.slice(1);
|
55
|
+
}
|
56
|
+
|
57
|
+
runAction(actions, actionName, section, block) {
|
58
|
+
const action = actions[actionName];
|
59
|
+
|
60
|
+
if (action !== undefined)
|
61
|
+
action(section, block);
|
62
|
+
}
|
63
|
+
|
64
|
+
eachType(callback) {
|
65
|
+
for (var type in this.sections) {
|
66
|
+
const actions = this.sections[type];
|
67
|
+
callback(type, actions)
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
queryAll(selector, scope) {
|
72
|
+
scope = scope ? scope : document;
|
73
|
+
return scope.querySelectorAll(selector);
|
74
|
+
}
|
75
|
+
|
76
|
+
queryOne(selector, scope) {
|
77
|
+
scope = scope ? scope : document;
|
78
|
+
return scope.querySelector(selector);
|
79
|
+
}
|
80
|
+
|
81
|
+
testAction(eventType, section, block) {
|
82
|
+
const hasBlock = block !== undefined && block !== null ;
|
83
|
+
const namespace = hasBlock ? 'block' : 'section';
|
84
|
+
const sectionId = section.getAttribute('id').replace('locomotive-section-', '');
|
85
|
+
const blockId = hasBlock ? block.getAttribute('data-locomotive-block').replace(`section-${sectionId}-block-`, '') : null;
|
86
|
+
const detail = { detail: { sectionId, blockId } };
|
87
|
+
const eventName = `locomotive::${namespace}::${eventType}`;
|
88
|
+
|
89
|
+
document.dispatchEvent(new CustomEvent(eventName, detail));
|
90
|
+
}
|
91
|
+
|
92
|
+
}
|
93
|
+
|
94
|
+
export default Manager;
|