cm_page_builder-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +32 -0
- data/app/assets/config/cm_page_builder_rails_manifest.js +1 -0
- data/app/assets/stylesheets/cm_page_builder/rails/application.css +15 -0
- data/app/assets/stylesheets/cm_page_builder/rails/page_components.css +4 -0
- data/app/assets/stylesheets/cm_page_builder/rails/pages.css +4 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/cm_page_builder/rails/application_controller.rb +14 -0
- data/app/controllers/cm_page_builder/rails/page_components_controller.rb +62 -0
- data/app/controllers/cm_page_builder/rails/pages_controller.rb +65 -0
- data/app/helpers/cm_page_builder/rails/application_helper.rb +6 -0
- data/app/helpers/cm_page_builder/rails/page_components_helper.rb +4 -0
- data/app/helpers/cm_page_builder/rails/pages_helper.rb +4 -0
- data/app/jobs/cm_page_builder/rails/application_job.rb +6 -0
- data/app/mailers/cm_page_builder/rails/application_mailer.rb +8 -0
- data/app/models/cm_page_builder/rails/application_record.rb +7 -0
- data/app/models/cm_page_builder/rails/page.rb +25 -0
- data/app/models/cm_page_builder/rails/page_component.rb +5 -0
- data/app/models/concerns/cm_page_builder/rails/has_cm_content.rb +20 -0
- data/app/views/cm_page_builder/rails/page_components/_form.html.slim +24 -0
- data/app/views/cm_page_builder/rails/page_components/edit.html.slim +8 -0
- data/app/views/cm_page_builder/rails/page_components/index.html.slim +29 -0
- data/app/views/cm_page_builder/rails/page_components/new.html.slim +5 -0
- data/app/views/cm_page_builder/rails/page_components/show.html.slim +21 -0
- data/app/views/cm_page_builder/rails/pages/_form.html.slim +14 -0
- data/app/views/cm_page_builder/rails/pages/edit.html.slim +8 -0
- data/app/views/cm_page_builder/rails/pages/index.html.slim +21 -0
- data/app/views/cm_page_builder/rails/pages/new.html.slim +5 -0
- data/app/views/cm_page_builder/rails/pages/show.html.slim +9 -0
- data/app/views/layouts/cm_page_builder/rails/application.html.erb +15 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20190816103148_create_cm_page_builder_rails_pages.rb +9 -0
- data/db/migrate/20190816105056_create_cm_page_builder_rails_page_components.rb +13 -0
- data/lib/cm_page_builder/rails/application_helper.rb +33 -0
- data/lib/cm_page_builder/rails/engine.rb +21 -0
- data/lib/cm_page_builder/rails/version.rb +5 -0
- data/lib/cm_page_builder/rails.rb +8 -0
- data/lib/tasks/cm_page_builder/rails_tasks.rake +4 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 658618c90bd048b3dbf923697641340e5e2230bb1060ad24d0ffacb8e60da832
|
4
|
+
data.tar.gz: 628fd865f7ddb5b685646278de7efbedc2aa47ed81adf691ee7c4eb5ef21b80a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de13dd220f6c5723daee54449ba5bb145553a3be6d81e5a88706212f61fa4dcf43d9ddc253c4668e5e3a39ec5fdefa9e95404b527fc79313041d209d3e0871d1
|
7
|
+
data.tar.gz: 49a982ff69e5e313e206b16e5e5638498ad9b8dd5f738f8a3ddf52e541a4e360008896ad4ada1097dd2fe8470ea27523d63e378153c4121188ad11ae0826a957
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Camilo Ernesto Forero Junco
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# CmPageBuilder::Rails
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'cm_page_builder-rails'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install cm_page_builder-rails
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CmPageBuilder::Rails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/cm_page_builder/rails .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,80 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #fff;
|
3
|
+
color: #333;
|
4
|
+
margin: 33px;
|
5
|
+
}
|
6
|
+
|
7
|
+
body, p, ol, ul, td {
|
8
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
9
|
+
font-size: 13px;
|
10
|
+
line-height: 18px;
|
11
|
+
}
|
12
|
+
|
13
|
+
pre {
|
14
|
+
background-color: #eee;
|
15
|
+
padding: 10px;
|
16
|
+
font-size: 11px;
|
17
|
+
}
|
18
|
+
|
19
|
+
a {
|
20
|
+
color: #000;
|
21
|
+
}
|
22
|
+
|
23
|
+
a:visited {
|
24
|
+
color: #666;
|
25
|
+
}
|
26
|
+
|
27
|
+
a:hover {
|
28
|
+
color: #fff;
|
29
|
+
background-color: #000;
|
30
|
+
}
|
31
|
+
|
32
|
+
th {
|
33
|
+
padding-bottom: 5px;
|
34
|
+
}
|
35
|
+
|
36
|
+
td {
|
37
|
+
padding: 0 5px 7px;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.field,
|
41
|
+
div.actions {
|
42
|
+
margin-bottom: 10px;
|
43
|
+
}
|
44
|
+
|
45
|
+
#notice {
|
46
|
+
color: green;
|
47
|
+
}
|
48
|
+
|
49
|
+
.field_with_errors {
|
50
|
+
padding: 2px;
|
51
|
+
background-color: red;
|
52
|
+
display: table;
|
53
|
+
}
|
54
|
+
|
55
|
+
#error_explanation {
|
56
|
+
width: 450px;
|
57
|
+
border: 2px solid red;
|
58
|
+
padding: 7px 7px 0;
|
59
|
+
margin-bottom: 20px;
|
60
|
+
background-color: #f0f0f0;
|
61
|
+
}
|
62
|
+
|
63
|
+
#error_explanation h2 {
|
64
|
+
text-align: left;
|
65
|
+
font-weight: bold;
|
66
|
+
padding: 5px 5px 5px 15px;
|
67
|
+
font-size: 12px;
|
68
|
+
margin: -7px -7px 0;
|
69
|
+
background-color: #c00;
|
70
|
+
color: #fff;
|
71
|
+
}
|
72
|
+
|
73
|
+
#error_explanation ul li {
|
74
|
+
font-size: 12px;
|
75
|
+
list-style: square;
|
76
|
+
}
|
77
|
+
|
78
|
+
label {
|
79
|
+
display: block;
|
80
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CmPageBuilder
|
2
|
+
module Rails
|
3
|
+
class ApplicationController < ::ApplicationController
|
4
|
+
protect_from_forgery with: :exception
|
5
|
+
layout CmPageBuilder::Rails.layout_template
|
6
|
+
#helper ::Rails.application.routes.url_helpers
|
7
|
+
#helper CmPageBuilder::Rails::ApplicationHelper
|
8
|
+
|
9
|
+
def current_user
|
10
|
+
main_app.scope.request.env['warden'].user
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_dependency "cm_page_builder/rails/application_controller"
|
2
|
+
|
3
|
+
module CmPageBuilder::Rails
|
4
|
+
class PageComponentsController < ApplicationController
|
5
|
+
before_action :set_page_component, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /page_components
|
8
|
+
def index
|
9
|
+
@page_components = PageComponent.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /page_components/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /page_components/new
|
17
|
+
def new
|
18
|
+
@page_component = PageComponent.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /page_components/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /page_components
|
26
|
+
def create
|
27
|
+
@page_component = PageComponent.new(page_component_params)
|
28
|
+
|
29
|
+
if @page_component.save
|
30
|
+
redirect_to @page_component, notice: 'Page component was successfully created.'
|
31
|
+
else
|
32
|
+
render :new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# PATCH/PUT /page_components/1
|
37
|
+
def update
|
38
|
+
if @page_component.update(page_component_params)
|
39
|
+
redirect_to @page_component, notice: 'Page component was successfully updated.'
|
40
|
+
else
|
41
|
+
render :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# DELETE /page_components/1
|
46
|
+
def destroy
|
47
|
+
@page_component.destroy
|
48
|
+
redirect_to page_components_url, notice: 'Page component was successfully destroyed.'
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
53
|
+
def set_page_component
|
54
|
+
@page_component = PageComponent.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
58
|
+
def page_component_params
|
59
|
+
params.require(:page_component).permit(:page_id, :content, :position, :component_type, :id)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_dependency "cm_page_builder/rails/application_controller"
|
2
|
+
|
3
|
+
module CmPageBuilder::Rails
|
4
|
+
class PagesController < ApplicationController
|
5
|
+
before_action :set_page, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /pages
|
8
|
+
def index
|
9
|
+
@pages = Page.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /pages/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /pages/new
|
17
|
+
def new
|
18
|
+
@page = Page.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /pages/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /pages
|
26
|
+
def create
|
27
|
+
components = page_params.delete('components')
|
28
|
+
@page = Page.new(page_params)
|
29
|
+
|
30
|
+
if @page.save
|
31
|
+
@page.save_content(components)
|
32
|
+
redirect_to @page, notice: 'Page was successfully created.'
|
33
|
+
else
|
34
|
+
render :new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# PATCH/PUT /pages/1
|
39
|
+
def update
|
40
|
+
components = page_params.delete(:components)
|
41
|
+
if @page.save_content(components)
|
42
|
+
redirect_to @page, notice: 'Page was successfully updated.'
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /pages/1
|
49
|
+
def destroy
|
50
|
+
@page.destroy
|
51
|
+
redirect_to pages_url, notice: 'Page was successfully destroyed.'
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
# Use callbacks to share common setup or constraints between actions.
|
56
|
+
def set_page
|
57
|
+
@page = Page.find(params[:id])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Only allow a trusted parameter "white list" through.
|
61
|
+
def page_params
|
62
|
+
params.require(:page).permit(:container_id, :container_type, :components)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CmPageBuilder::Rails
|
2
|
+
class Page < ApplicationRecord
|
3
|
+
belongs_to :container, polymorphic: true
|
4
|
+
has_many :page_components, dependent: :destroy
|
5
|
+
|
6
|
+
accepts_nested_attributes_for :page_components, allow_destroy: true
|
7
|
+
|
8
|
+
def save_content(component_json)
|
9
|
+
components = JSON.parse component_json
|
10
|
+
deleted_components = self.page_components.where.not(
|
11
|
+
id: components.map {|c| c["id"] } )
|
12
|
+
deleted_components.delete_all
|
13
|
+
components.each do |component|
|
14
|
+
self.page_components
|
15
|
+
.find_or_initialize_by(id: component["id"])
|
16
|
+
.update!(
|
17
|
+
content: component["content"],
|
18
|
+
position: component["position"],
|
19
|
+
component_type: component["componentType"]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CmPageBuilder
|
2
|
+
module Rails
|
3
|
+
module HasCmContent
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
has_one :page, as: :container, dependent: :destroy, class_name:"CmPageBuilder::Rails::Page"
|
8
|
+
has_many :page_components, through: :page
|
9
|
+
|
10
|
+
delegate :save_content, to: :page
|
11
|
+
|
12
|
+
|
13
|
+
after_find do
|
14
|
+
self.create_page! unless self.page
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
= form_for @page_component do |f|
|
2
|
+
- if @page_component.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
h2 = "#{pluralize(@page_component.errors.count, "error")} prohibited this page_component from being saved:"
|
5
|
+
ul
|
6
|
+
- @page_component.errors.full_messages.each do |message|
|
7
|
+
li = message
|
8
|
+
|
9
|
+
.field
|
10
|
+
= f.label :page
|
11
|
+
= f.text_field :page
|
12
|
+
.field
|
13
|
+
= f.label :content
|
14
|
+
= f.text_field :content
|
15
|
+
.field
|
16
|
+
= f.label :position
|
17
|
+
= f.number_field :position
|
18
|
+
.field
|
19
|
+
= f.label :component_type
|
20
|
+
= f.text_field :component_type
|
21
|
+
.field
|
22
|
+
= f.label :id
|
23
|
+
= f.text_field :id
|
24
|
+
.actions = f.submit
|
@@ -0,0 +1,29 @@
|
|
1
|
+
h1 Listing page_components
|
2
|
+
|
3
|
+
table
|
4
|
+
thead
|
5
|
+
tr
|
6
|
+
th Page
|
7
|
+
th Content
|
8
|
+
th Position
|
9
|
+
th Component type
|
10
|
+
th Id
|
11
|
+
th
|
12
|
+
th
|
13
|
+
th
|
14
|
+
|
15
|
+
tbody
|
16
|
+
- @page_components.each do |page_component|
|
17
|
+
tr
|
18
|
+
td = page_component.page
|
19
|
+
td = page_component.content
|
20
|
+
td = page_component.position
|
21
|
+
td = page_component.component_type
|
22
|
+
td = page_component.id
|
23
|
+
td = link_to 'Show', page_component
|
24
|
+
td = link_to 'Edit', edit_page_component_path(page_component)
|
25
|
+
td = link_to 'Destroy', page_component, data: { confirm: 'Are you sure?' }, method: :delete
|
26
|
+
|
27
|
+
br
|
28
|
+
|
29
|
+
= link_to 'New Page component', new_page_component_path
|
@@ -0,0 +1,21 @@
|
|
1
|
+
p#notice = notice
|
2
|
+
|
3
|
+
p
|
4
|
+
strong Page:
|
5
|
+
= @page_component.page
|
6
|
+
p
|
7
|
+
strong Content:
|
8
|
+
= @page_component.content
|
9
|
+
p
|
10
|
+
strong Position:
|
11
|
+
= @page_component.position
|
12
|
+
p
|
13
|
+
strong Component type:
|
14
|
+
= @page_component.component_type
|
15
|
+
p
|
16
|
+
strong Id:
|
17
|
+
= @page_component.id
|
18
|
+
|
19
|
+
=> link_to 'Edit', edit_page_component_path(@page_component)
|
20
|
+
'|
|
21
|
+
=< link_to 'Back', page_components_path
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= form_for @page do |f|
|
2
|
+
- if @page.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
h2 = "#{pluralize(@page.errors.count, "error")} prohibited this page from being saved:"
|
5
|
+
ul
|
6
|
+
- @page.errors.full_messages.each do |message|
|
7
|
+
li = message
|
8
|
+
|
9
|
+
.field
|
10
|
+
input type='hidden' id="content-editor" name="page[components]"
|
11
|
+
- components = @page.page_components.select(:id, :component_type, :position, :content).map { |component| component.as_json.transform_keys! {|key| key.camelize(:lower)} }
|
12
|
+
= react_component("cm_content_manager/Content", {input: "content-editor", components: components})
|
13
|
+
|
14
|
+
.actions = f.submit
|
@@ -0,0 +1,21 @@
|
|
1
|
+
h1 Listing pages
|
2
|
+
|
3
|
+
table
|
4
|
+
thead
|
5
|
+
tr
|
6
|
+
th Container
|
7
|
+
th
|
8
|
+
th
|
9
|
+
th
|
10
|
+
|
11
|
+
tbody
|
12
|
+
- @pages.each do |page|
|
13
|
+
tr
|
14
|
+
td = page.container
|
15
|
+
td = link_to 'Show', page
|
16
|
+
td = link_to 'Edit', edit_page_path(page)
|
17
|
+
td = link_to 'Destroy', page, data: { confirm: 'Are you sure?' }, method: :delete
|
18
|
+
|
19
|
+
br
|
20
|
+
|
21
|
+
= link_to 'New Page', new_page_path
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Cm page builder rails</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag "cm_page_builder/rails/application", media: "all" %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
class CreateCmPageBuilderRailsPages < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :cm_page_builder_rails_pages do |t|
|
4
|
+
t.references :container, polymorphic: true, null: false, index: { name: 'container_composite_index' }
|
5
|
+
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
class CreateCmPageBuilderRailsPageComponents < ActiveRecord::Migration[6.0]
|
3
|
+
def change
|
4
|
+
create_table :cm_page_builder_rails_page_components, id: :string do |t|
|
5
|
+
t.references :page, null: false
|
6
|
+
t.string :content
|
7
|
+
t.integer :position
|
8
|
+
t.string :component_type
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_foreign_key :cm_page_builder_rails_page_components, :cm_page_builder_rails_pages, column: :page_id
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module CmPageBuilder
|
2
|
+
module Rails
|
3
|
+
module ApplicationHelper
|
4
|
+
|
5
|
+
|
6
|
+
# def method_missing method, *args, &block
|
7
|
+
# pp "==========="
|
8
|
+
# if method.to_s.end_with?('_path') or method.to_s.end_with?('_url')
|
9
|
+
# if main_app.respond_to?(method)
|
10
|
+
# main_app.send(method, *args)
|
11
|
+
# else
|
12
|
+
# super
|
13
|
+
# end
|
14
|
+
# else
|
15
|
+
# super
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def respond_to?(method)
|
20
|
+
# if method.to_s.end_with?('_path') or method.to_s.end_with?('_url')
|
21
|
+
# if main_app.respond_to?(method)
|
22
|
+
# true
|
23
|
+
# else
|
24
|
+
# super
|
25
|
+
# end
|
26
|
+
# else
|
27
|
+
# super
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CmPageBuilder
|
2
|
+
module Rails
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace CmPageBuilder::Rails
|
5
|
+
|
6
|
+
config.generators do |g|
|
7
|
+
g.template_engine :slim
|
8
|
+
end
|
9
|
+
# This part of the code makes sure that the main application's helper
|
10
|
+
# methods can be accessed from the engine
|
11
|
+
# initializer 'cm_page_builder_rails.action_controller' do |app|
|
12
|
+
# ActiveSupport.on_load :action_controller do
|
13
|
+
# helper CmPageBuilder::Rails::ApplicationHelper
|
14
|
+
# end
|
15
|
+
# # ActiveSupport.on_load(:action_controller) do
|
16
|
+
# # helper ::Rails.application.routes.url_helpers
|
17
|
+
# # end
|
18
|
+
# end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cm_page_builder-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Camilo Ernesto Forero Junco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slim-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pg
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Description of CmPageBuilder::Rails.
|
56
|
+
email:
|
57
|
+
- camilo@commutatus.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/assets/config/cm_page_builder_rails_manifest.js
|
66
|
+
- app/assets/stylesheets/cm_page_builder/rails/application.css
|
67
|
+
- app/assets/stylesheets/cm_page_builder/rails/page_components.css
|
68
|
+
- app/assets/stylesheets/cm_page_builder/rails/pages.css
|
69
|
+
- app/assets/stylesheets/scaffold.css
|
70
|
+
- app/controllers/cm_page_builder/rails/application_controller.rb
|
71
|
+
- app/controllers/cm_page_builder/rails/page_components_controller.rb
|
72
|
+
- app/controllers/cm_page_builder/rails/pages_controller.rb
|
73
|
+
- app/helpers/cm_page_builder/rails/application_helper.rb
|
74
|
+
- app/helpers/cm_page_builder/rails/page_components_helper.rb
|
75
|
+
- app/helpers/cm_page_builder/rails/pages_helper.rb
|
76
|
+
- app/jobs/cm_page_builder/rails/application_job.rb
|
77
|
+
- app/mailers/cm_page_builder/rails/application_mailer.rb
|
78
|
+
- app/models/cm_page_builder/rails/application_record.rb
|
79
|
+
- app/models/cm_page_builder/rails/page.rb
|
80
|
+
- app/models/cm_page_builder/rails/page_component.rb
|
81
|
+
- app/models/concerns/cm_page_builder/rails/has_cm_content.rb
|
82
|
+
- app/views/cm_page_builder/rails/page_components/_form.html.slim
|
83
|
+
- app/views/cm_page_builder/rails/page_components/edit.html.slim
|
84
|
+
- app/views/cm_page_builder/rails/page_components/index.html.slim
|
85
|
+
- app/views/cm_page_builder/rails/page_components/new.html.slim
|
86
|
+
- app/views/cm_page_builder/rails/page_components/show.html.slim
|
87
|
+
- app/views/cm_page_builder/rails/pages/_form.html.slim
|
88
|
+
- app/views/cm_page_builder/rails/pages/edit.html.slim
|
89
|
+
- app/views/cm_page_builder/rails/pages/index.html.slim
|
90
|
+
- app/views/cm_page_builder/rails/pages/new.html.slim
|
91
|
+
- app/views/cm_page_builder/rails/pages/show.html.slim
|
92
|
+
- app/views/layouts/cm_page_builder/rails/application.html.erb
|
93
|
+
- config/routes.rb
|
94
|
+
- db/migrate/20190816103148_create_cm_page_builder_rails_pages.rb
|
95
|
+
- db/migrate/20190816105056_create_cm_page_builder_rails_page_components.rb
|
96
|
+
- lib/cm_page_builder/rails.rb
|
97
|
+
- lib/cm_page_builder/rails/application_helper.rb
|
98
|
+
- lib/cm_page_builder/rails/engine.rb
|
99
|
+
- lib/cm_page_builder/rails/version.rb
|
100
|
+
- lib/tasks/cm_page_builder/rails_tasks.rake
|
101
|
+
homepage: https://commutatus.com
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata:
|
105
|
+
allowed_push_host: https://rubygems.org
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubygems_version: 3.0.3
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Summary of CmPageBuilder::Rails.
|
125
|
+
test_files: []
|