cm_page_builder-rails 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/app/models/cm_page_builder/rails/page.rb +1 -1
- data/app/views/cm_page_builder/rails/pages/_form.html.slim +1 -1
- data/lib/cm_page_builder/rails/version.rb +1 -1
- data/lib/generators/cm_page_builder/rails/install_generator.rb +14 -0
- data/lib/generators/cm_page_builder/rails/templates/app/javascripts/components/cm_content_manager/Content.jsx +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e528443d6f1df388159a706b5bcab30e2cf42c06af6628ed763d398a202c263
|
4
|
+
data.tar.gz: 81fc89511291e3320123adfd21971d2064a1891b176b78ea59fed00f07b3c62c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f10ae957d38fa4ba023a078387cbf8dfdc796a16f810111a4eb17a5c3be71f3f6030beca16321f10b0cc2407eba9f2a24ddd76807b08bf2bc6b61266978ecba0
|
7
|
+
data.tar.gz: 3022134f1afda91c279f4e3c955ad486a6ab179f8ff62d3400948f857274b3078dd7eadef2a381b5ca519878643018528a16362063fdae5681317fa92dc9f2fc
|
data/README.md
CHANGED
@@ -7,6 +7,7 @@ This gem's purpose is to allow easy integration between the Commutatus javascrip
|
|
7
7
|
|
8
8
|
* Rails 6+
|
9
9
|
* Webpacker must be enabled in the project
|
10
|
+
* S3 as the image backend storage
|
10
11
|
|
11
12
|
|
12
13
|
## Initial setup:
|
@@ -23,17 +24,24 @@ This gem's purpose is to allow easy integration between the Commutatus javascrip
|
|
23
24
|
* Follow all react-rails installation instructions (https://github.com/reactjs/react-rails)
|
24
25
|
*Important:* ensure that the `hello_world` example successfully works
|
25
26
|
|
26
|
-
*
|
27
|
+
* Install the javascript packages with:
|
28
|
+
```bash
|
29
|
+
yarn add cm-page-builder@1.3.0 -E
|
30
|
+
yarn add babel-runtime@^6.26.0
|
31
|
+
```
|
32
|
+
(the emoji-mart package, a dependency of cm-page-builder, sometimes bugs out during the webpack build process without the babel-runtime)
|
27
33
|
|
28
34
|
* Run `rails cm_page_builder_rails:install:migrations`
|
29
35
|
|
30
|
-
*
|
36
|
+
* Run `rails generate cm_page_builder:rails:install` to install the JSX component. This assumes your webpack folder is inside `app/javascripts`
|
31
37
|
|
32
|
-
*
|
38
|
+
* In `config/routes.rb`, mount the endpoint with the line `mount CmPageBuilder::Rails::Engine => "/cm_page_builder"`
|
33
39
|
|
34
40
|
## Usage
|
35
41
|
This package comes with a concern, `CmPageBuilder::Rails::HasCmContent` `include CmPageBuilder::Rails::HasCmContent`
|
36
|
-
To activate this module, add `include CmPageBuilder::Rails::HasCmContent` on top of any model file that should have an associated
|
42
|
+
To activate this module, add `include CmPageBuilder::Rails::HasCmContent` on top of any model file that should have an associated page builder record.
|
43
|
+
|
44
|
+
The page builder record will be accessible from the model as *page* (`@model.page`). The show path is accessible through the route `cm_page_builder_rails.page_path(@page)`, and the edit path through the route `cm_page_builder_rails.edit_page_path(@page)`
|
37
45
|
|
38
46
|
### Setting up CORS for aws
|
39
47
|
Do this or the direct upload capabilities won't work
|
@@ -43,7 +43,7 @@ module CmPageBuilder::Rails
|
|
43
43
|
attachment_data = {
|
44
44
|
filename: attachment.filename.to_s,
|
45
45
|
filesize: blob.byte_size,
|
46
|
-
url:
|
46
|
+
url: attachment.service_url
|
47
47
|
}
|
48
48
|
if blob.variable?
|
49
49
|
dimensions = blob.metadata
|
@@ -8,6 +8,6 @@
|
|
8
8
|
|
9
9
|
.field
|
10
10
|
input type='hidden' id="content-editor" name="page[components]"
|
11
|
-
= react_component("cm_content_manager/Content", {input: "content-editor", components: @page.components})
|
11
|
+
= react_component("cm_content_manager/Content", { input: "content-editor", components: @page.components, assetBaseUrl: ActiveStorage::Blob.service.bucket.url})
|
12
12
|
|
13
13
|
.actions = f.submit
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CmPageBuilder::Rails
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc "Copy the jsx component"
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
def copy_jsx_component
|
10
|
+
template "app/javascripts/components/cm_content_manager/Content.jsx"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import PropTypes from "prop-types"
|
3
|
+
import PageBuilder from 'cm-page-builder'
|
4
|
+
|
5
|
+
class Content extends React.Component {
|
6
|
+
constructor(props) {
|
7
|
+
super(props)
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
_updatePageComponent = (id, data, type, key) => {}
|
12
|
+
|
13
|
+
|
14
|
+
render () {
|
15
|
+
return (
|
16
|
+
<React.Fragment>
|
17
|
+
<PageBuilder
|
18
|
+
pageComponents={this.props.components}
|
19
|
+
handleUpdate={this._updatePageComponent}
|
20
|
+
updateComponentData={(data) =>
|
21
|
+
{ $(`#${this.props.input}`).val(JSON.stringify(data))}
|
22
|
+
}
|
23
|
+
showTitle={false}
|
24
|
+
showEmoji={false}
|
25
|
+
showPageInfo={false}
|
26
|
+
useDirectStorageUpload={true}
|
27
|
+
assetBaseUrl={ this.props.assetBaseUrl }
|
28
|
+
meta={ {id: "debug"} }
|
29
|
+
status="Edit"
|
30
|
+
/>
|
31
|
+
</React.Fragment>
|
32
|
+
);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
Content.propTypes = {
|
37
|
+
input: PropTypes.string,
|
38
|
+
components: PropTypes.array,
|
39
|
+
assetBaseUrl: PropTypes.string
|
40
|
+
};
|
41
|
+
export default Content
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm_page_builder-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ernesto Forero Junco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -104,6 +104,8 @@ files:
|
|
104
104
|
- lib/cm_page_builder/rails/application_helper.rb
|
105
105
|
- lib/cm_page_builder/rails/engine.rb
|
106
106
|
- lib/cm_page_builder/rails/version.rb
|
107
|
+
- lib/generators/cm_page_builder/rails/install_generator.rb
|
108
|
+
- lib/generators/cm_page_builder/rails/templates/app/javascripts/components/cm_content_manager/Content.jsx
|
107
109
|
- lib/tasks/cm_page_builder/rails_tasks.rake
|
108
110
|
- spec/dummy/Rakefile
|
109
111
|
- spec/dummy/app/assets/config/manifest.js
|