riddler_admin 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/riddler_admin_manifest.js +2 -0
- data/app/assets/javascripts/riddler_admin/application.js +21 -0
- data/app/assets/javascripts/riddler_admin/steps.js +42 -0
- data/app/assets/stylesheets/riddler_admin/application.scss +14 -0
- data/app/assets/stylesheets/riddler_admin/steps.css +13 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/riddler_admin/application_controller.rb +5 -0
- data/app/controllers/riddler_admin/elements_controller.rb +79 -0
- data/app/controllers/riddler_admin/steps_controller.rb +72 -0
- data/app/helpers/riddler_admin/application_helper.rb +4 -0
- data/app/helpers/riddler_admin/steps_helper.rb +4 -0
- data/app/jobs/riddler_admin/application_job.rb +4 -0
- data/app/mailers/riddler_admin/application_mailer.rb +6 -0
- data/app/models/riddler_admin/application_record.rb +24 -0
- data/app/models/riddler_admin/element.rb +55 -0
- data/app/models/riddler_admin/elements/copy.rb +11 -0
- data/app/models/riddler_admin/elements/heading.rb +11 -0
- data/app/models/riddler_admin/step.rb +35 -0
- data/app/models/riddler_admin/steps/content.rb +19 -0
- data/app/views/layouts/riddler_admin/application.html.erb +17 -0
- data/app/views/riddler_admin/_element.html.erb +15 -0
- data/app/views/riddler_admin/elements/_new.html.erb +15 -0
- data/app/views/riddler_admin/elements/_show.html.erb +18 -0
- data/app/views/riddler_admin/elements/copy/_class.html.erb +3 -0
- data/app/views/riddler_admin/elements/copy/_form.html.erb +2 -0
- data/app/views/riddler_admin/elements/destroy.js.erb +1 -0
- data/app/views/riddler_admin/elements/heading/_class.html.erb +3 -0
- data/app/views/riddler_admin/elements/heading/_form.html.erb +2 -0
- data/app/views/riddler_admin/elements/new.js.erb +3 -0
- data/app/views/riddler_admin/elements/show.js.erb +4 -0
- data/app/views/riddler_admin/steps/_form.html.erb +22 -0
- data/app/views/riddler_admin/steps/_preview.html.erb +5 -0
- data/app/views/riddler_admin/steps/content/_show.html.erb +31 -0
- data/app/views/riddler_admin/steps/edit.html.erb +6 -0
- data/app/views/riddler_admin/steps/index.html.erb +31 -0
- data/app/views/riddler_admin/steps/new.html.erb +5 -0
- data/app/views/riddler_admin/steps/show.html.erb +14 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20181124201519_create_riddler_admin_steps.rb +20 -0
- data/lib/riddler_admin/engine.rb +11 -0
- data/lib/riddler_admin/version.rb +3 -0
- data/lib/riddler_admin.rb +13 -0
- data/lib/tasks/riddler_admin_tasks.rake +4 -0
- metadata +202 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9561218c85dfee3d311a84b0681f7464ea5f02712fe940f698775d816a4f9913
|
4
|
+
data.tar.gz: 225ca8ed1782b0600e07911c81befc5a4fe21530a2a6095e967d262f8e6d16dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 04da84f8aa2b102182e9ac084c6c5d86879cd3629f883371cfe511de9a4ed8e8431b602522c622806b0ad9117f66410d57d383b09fc4b3cfe15bed5ed16737b7
|
7
|
+
data.tar.gz: 0fa37404a58600285e9f58984d35dd9cf9d3a67e93dba9416337d9a6d0741d559d16be8b20a76705b315307f44afff110a0f507928a8963b98ab79fc61ad3191
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 JohnnyT
|
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
|
+
# RiddlerAdmin
|
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 'riddler_admin'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install riddler_admin
|
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 = 'RiddlerAdmin'
|
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,21 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require jquery3
|
16
|
+
//= require jquery-ui/widgets/draggable
|
17
|
+
//= require jquery-ui/widgets/droppable
|
18
|
+
//= require jquery-ui/widgets/sortable
|
19
|
+
//= require popper
|
20
|
+
//= require bootstrap-sprockets
|
21
|
+
//= require_tree .
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
// All this logic will automatically be available in application.js.
|
3
|
+
$(document).ready(function(){
|
4
|
+
|
5
|
+
$("#step-elements").sortable({
|
6
|
+
revert: 50,
|
7
|
+
opacity: 0.5,
|
8
|
+
cursor: "move",
|
9
|
+
forcePlaceholderSize: true,
|
10
|
+
update: function(event, ui) {
|
11
|
+
element_ids = $(this).sortable("toArray", { attribute: "data-id" })
|
12
|
+
|
13
|
+
Rails.ajax({
|
14
|
+
type: "PUT",
|
15
|
+
url: "/riddler_admin/elements/sort",
|
16
|
+
data: $.param({ element_order: element_ids })
|
17
|
+
})
|
18
|
+
},
|
19
|
+
|
20
|
+
|
21
|
+
old_update: function(event, ui) {
|
22
|
+
params = {
|
23
|
+
type: ui.item.data("klass"),
|
24
|
+
step_id: ui.item.parent().data("stepId")
|
25
|
+
}
|
26
|
+
$.get("/riddler_admin/elements/new", params, function(data) {
|
27
|
+
ui.item.removeAttr("style");
|
28
|
+
ui.item.html(data);
|
29
|
+
});
|
30
|
+
}
|
31
|
+
})
|
32
|
+
|
33
|
+
/*
|
34
|
+
$(".element-classes-draggable").draggable({
|
35
|
+
connectToSortable: "#step-elements",
|
36
|
+
revertDuration: 50,
|
37
|
+
revert: "invalid",
|
38
|
+
helper: "clone"
|
39
|
+
})
|
40
|
+
*/
|
41
|
+
|
42
|
+
})
|
@@ -0,0 +1,14 @@
|
|
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
|
+
*/
|
14
|
+
@import "bootstrap";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
Place all the styles related to the matching controller here.
|
3
|
+
They will automatically be included in application.css.
|
4
|
+
*/
|
5
|
+
.ui-state-active {
|
6
|
+
background-color: #ff6;
|
7
|
+
border: 2px solid black;
|
8
|
+
}
|
9
|
+
|
10
|
+
.ui-state-active {
|
11
|
+
background-color: #eee;
|
12
|
+
border: 2px solid blue;
|
13
|
+
}
|
@@ -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,79 @@
|
|
1
|
+
require_dependency "riddler_admin/application_controller"
|
2
|
+
|
3
|
+
module RiddlerAdmin
|
4
|
+
class ElementsController < ApplicationController
|
5
|
+
before_action :set_element, only: [:show, :edit, :update, :destroy]
|
6
|
+
before_action :set_element_class
|
7
|
+
|
8
|
+
# GET /elements/new
|
9
|
+
def new
|
10
|
+
hash = {}
|
11
|
+
if step = Step.find_by_id(params["step_id"])
|
12
|
+
hash[:container] = step
|
13
|
+
end
|
14
|
+
@element = @element_class.new hash
|
15
|
+
end
|
16
|
+
|
17
|
+
# POST /elements
|
18
|
+
def create
|
19
|
+
@element = @element_class.new element_create_params
|
20
|
+
|
21
|
+
if @element.save
|
22
|
+
render :show
|
23
|
+
else
|
24
|
+
render :new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# PATCH/PUT /elements/1
|
29
|
+
def update
|
30
|
+
if @element.update element_params
|
31
|
+
redirect_to @element, notice: 'Element was successfully updated.'
|
32
|
+
else
|
33
|
+
render :edit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# DELETE /elements/1
|
38
|
+
def destroy
|
39
|
+
@element.destroy
|
40
|
+
render :destroy
|
41
|
+
end
|
42
|
+
|
43
|
+
# PUT /elements/sort
|
44
|
+
def sort
|
45
|
+
element_order = params.fetch "element_order"
|
46
|
+
|
47
|
+
element_order.each_with_index do |element_id, index|
|
48
|
+
element = Element.find_by_id element_id
|
49
|
+
element.update_attribute :position, index+1
|
50
|
+
end
|
51
|
+
|
52
|
+
head :no_content
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
# Use callbacks to share common setup or constraints between actions.
|
57
|
+
def set_element
|
58
|
+
@element = Element.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_element_class
|
62
|
+
class_name = params.fetch(:element, {}).delete(:type) ||
|
63
|
+
params.delete(:type)
|
64
|
+
class_name = RiddlerAdmin::Element.default_class.name if class_name.blank?
|
65
|
+
|
66
|
+
@element_class = class_name.constantize
|
67
|
+
end
|
68
|
+
|
69
|
+
# Only allow a trusted parameter "white list" through.
|
70
|
+
def element_create_params
|
71
|
+
params.require(:element).permit(:id, :name, :type, :text, :container_type, :container_id)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Only allow a trusted parameter "white list" through.
|
75
|
+
def element_params
|
76
|
+
params.require(:element).permit(:name, :text)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_dependency "riddler_admin/application_controller"
|
2
|
+
|
3
|
+
module RiddlerAdmin
|
4
|
+
class StepsController < ApplicationController
|
5
|
+
before_action :set_step, only: [:show, :edit, :update, :destroy, :preview]
|
6
|
+
before_action :set_step_class
|
7
|
+
|
8
|
+
# GET /steps
|
9
|
+
def index
|
10
|
+
@steps = Step.all
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /steps/1
|
14
|
+
def show
|
15
|
+
step_definition = @step.definition_hash
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /steps/new
|
19
|
+
def new
|
20
|
+
@step = Step.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /steps/1/edit
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
# POST /steps
|
28
|
+
def create
|
29
|
+
@step = @step_class.new(step_params)
|
30
|
+
|
31
|
+
if @step.save
|
32
|
+
redirect_to @step, notice: 'Step was successfully created.'
|
33
|
+
else
|
34
|
+
render :new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# PATCH/PUT /steps/1
|
39
|
+
def update
|
40
|
+
if @step.update(step_params)
|
41
|
+
redirect_to @step, notice: 'Step was successfully updated.'
|
42
|
+
else
|
43
|
+
render :edit
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# DELETE /steps/1
|
48
|
+
def destroy
|
49
|
+
@step.destroy
|
50
|
+
redirect_to steps_url, notice: 'Step was successfully destroyed.'
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
# Use callbacks to share common setup or constraints between actions.
|
55
|
+
def set_step
|
56
|
+
@step = Step.find(params[:id])
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_step_class
|
60
|
+
class_name = params.fetch(:step, {}).delete(:type) ||
|
61
|
+
params.delete(:type)
|
62
|
+
class_name = RiddlerAdmin::Step.default_class.name if class_name.blank?
|
63
|
+
|
64
|
+
@step_class = class_name.constantize
|
65
|
+
end
|
66
|
+
|
67
|
+
# Only allow a trusted parameter "white list" through.
|
68
|
+
def step_params
|
69
|
+
params.require(:step).permit(:name)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "ksuid"
|
2
|
+
|
3
|
+
module RiddlerAdmin
|
4
|
+
class ApplicationRecord < ActiveRecord::Base
|
5
|
+
self.abstract_class = true
|
6
|
+
|
7
|
+
after_initialize :generate_id
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def id_length
|
12
|
+
return 21 unless self.class.const_defined? :ID_LENGTH
|
13
|
+
self.class.const_get :ID_LENGTH
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate_id
|
17
|
+
return if id.present?
|
18
|
+
model_key = self.class.const_get :MODEL_KEY
|
19
|
+
ksuid = KSUID.new.to_s
|
20
|
+
id_string = ksuid[0..(5+id_length)]
|
21
|
+
self.id = [model_key, id_string].join "_"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module RiddlerAdmin
|
2
|
+
class Element < ApplicationRecord
|
3
|
+
MODEL_KEY = "el".freeze
|
4
|
+
ID_LENGTH = 6 # 56_800_235_584 per second
|
5
|
+
|
6
|
+
belongs_to :container, polymorphic: true, validate: true
|
7
|
+
|
8
|
+
acts_as_list scope: [:container_type, :container_id]
|
9
|
+
|
10
|
+
def self.available_classes
|
11
|
+
[ Elements::Heading, Elements::Copy ]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.default_class
|
15
|
+
Elements::Copy
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.short_name
|
19
|
+
name.demodulize
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.to_partial_path
|
23
|
+
"#{name.underscore}/class"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_partial_path detail=nil
|
27
|
+
[self.class.name.underscore, detail].compact.join "/"
|
28
|
+
end
|
29
|
+
|
30
|
+
def short_name
|
31
|
+
self.class.short_name
|
32
|
+
end
|
33
|
+
|
34
|
+
# Used in serialization
|
35
|
+
def object
|
36
|
+
type.demodulize.underscore
|
37
|
+
end
|
38
|
+
|
39
|
+
def definition_hash options=nil
|
40
|
+
options ||= {}
|
41
|
+
serializable_hash options.merge(serializable_hash_options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def serializable_hash_options
|
45
|
+
{
|
46
|
+
methods: :object,
|
47
|
+
except: excluded_attrs
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def excluded_attrs
|
52
|
+
[:created_at, :updated_at, :container_type, :container_id, :position, :name]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RiddlerAdmin
|
2
|
+
class Step < ApplicationRecord
|
3
|
+
MODEL_KEY = "st".freeze
|
4
|
+
ID_LENGTH = 5 # 916_132_832 per second
|
5
|
+
|
6
|
+
def self.default_class
|
7
|
+
Steps::Content
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_partial_path detail=nil
|
11
|
+
[self.class.name.underscore, detail].compact.join "/"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Used in serialization
|
15
|
+
def object
|
16
|
+
type.demodulize.underscore
|
17
|
+
end
|
18
|
+
|
19
|
+
def definition_hash options=nil
|
20
|
+
options ||= {}
|
21
|
+
serializable_hash options.merge(serializable_hash_options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def serializable_hash_options
|
25
|
+
{
|
26
|
+
methods: :object,
|
27
|
+
except: excluded_attrs
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def excluded_attrs
|
32
|
+
[:created_at, :updated_at, :name]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RiddlerAdmin
|
2
|
+
module Steps
|
3
|
+
class Content < Step
|
4
|
+
has_many :elements, -> { order position: :asc },
|
5
|
+
dependent: :destroy,
|
6
|
+
as: :container
|
7
|
+
|
8
|
+
def self.model_name
|
9
|
+
Step.model_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def definition_hash options=nil
|
13
|
+
hash = super
|
14
|
+
hash["elements"] = elements.map { |e| e.definition_hash }
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Riddler Admin</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
8
|
+
|
9
|
+
<%= stylesheet_link_tag "riddler_admin/application", media: "all" %>
|
10
|
+
<%= javascript_include_tag "riddler_admin/application" %>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
|
14
|
+
<%= yield %>
|
15
|
+
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<li class="list-group-item" id="<%= element.id %>" data-id="<%= element.id %>">
|
2
|
+
<b><%= element.short_name %> Element</b>
|
3
|
+
|
4
|
+
<%= link_to "Delete", element, method: :delete, remote: true, data: { confirm: "Are you sure?" } %>
|
5
|
+
|
6
|
+
<%= form_with model: element do |f| %>
|
7
|
+
<% if element.errors.any? %>
|
8
|
+
ERRORS
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= render partial: element.to_partial_path("form"), locals: { f: f } %>
|
12
|
+
|
13
|
+
<%= f.submit %>
|
14
|
+
<% end %>
|
15
|
+
</li>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= form_with model: @element do |f| %>
|
2
|
+
<h5>New Element</h5>
|
3
|
+
<% if @element.errors.any? %>
|
4
|
+
ERRORS
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<%= f.hidden_field :id %>
|
8
|
+
<%= f.hidden_field :type %>
|
9
|
+
<%= f.hidden_field :container_type %>
|
10
|
+
<%= f.hidden_field :container_id %>
|
11
|
+
|
12
|
+
<%= render partial: "#{@element.to_partial_path}/form", locals: { f: f } %>
|
13
|
+
|
14
|
+
<%= f.submit %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%- binding.pry %>
|
2
|
+
<div id="<%= element.id %>">
|
3
|
+
<%= form_with model: element, data: { "new-element-form" => true } do |f| %>
|
4
|
+
<h5>Element</h5>
|
5
|
+
<% if element.errors.any? %>
|
6
|
+
ERRORS
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%= f.hidden_field :id %>
|
10
|
+
<%= f.hidden_field :type %>
|
11
|
+
<%= f.hidden_field :container_type %>
|
12
|
+
<%= f.hidden_field :container_id %>
|
13
|
+
|
14
|
+
<%= render partial: "#{element.to_partial_path}/form", locals: { f: f } %>
|
15
|
+
|
16
|
+
<%= f.submit %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
$("#<%= @element.id %>").fadeOut().remove();
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= form_with(model: step, local: true) do |form| %>
|
2
|
+
<% if step.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(step.errors.count, "error") %> prohibited this step from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% step.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= form.label :name %>
|
16
|
+
<%= form.text_field :name %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="actions">
|
20
|
+
<%= form.submit %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<ul id="step-tabs" class="nav nav-tabs">
|
2
|
+
<li class="nav-item">
|
3
|
+
<a class="nav-link active" id="elements-tab" data-toggle="tab" href="#elements" role="tab" aria-controls="elements" aria-selected="true">Elements</a>
|
4
|
+
</li>
|
5
|
+
<li class="nav-item">
|
6
|
+
<a class="nav-link" id="step-preview-tab" data-toggle="tab" href="#step-preview" role="tab" aria-controls="step-preview" aria-selected="false">Preview</a>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
|
10
|
+
<div class="tab-content" id="step-tabs-content">
|
11
|
+
<div class="tab-pane fade show active" id="elements" role="tabpanel" aria-labelledby="elements-tab">
|
12
|
+
<h4>Available Elements</h4>
|
13
|
+
<ul class="list-group">
|
14
|
+
<%- RiddlerAdmin::Element.available_classes.each do |klass| %>
|
15
|
+
<%= render klass, object: klass, step: @step %>
|
16
|
+
<%- end %>
|
17
|
+
</ul>
|
18
|
+
|
19
|
+
<div id="new-element">
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h4>Elements</h4>
|
23
|
+
<ul id="step-elements" class="list-group step-elements" data-step-id="<%= @step.id %>">
|
24
|
+
<%= render partial: "riddler_admin/element", collection: @step.elements %>
|
25
|
+
</ul>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="tab-pane fade" id="step-preview" role="tabpanel" aria-labelledby="preview-tab">
|
29
|
+
<%= render partial: "preview", object: @step %>
|
30
|
+
</div>
|
31
|
+
</div>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Steps</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>Id</th>
|
9
|
+
<th>Type</th>
|
10
|
+
<th>Name</th>
|
11
|
+
<th colspan="3"></th>
|
12
|
+
</tr>
|
13
|
+
</thead>
|
14
|
+
|
15
|
+
<tbody>
|
16
|
+
<% @steps.each do |step| %>
|
17
|
+
<tr>
|
18
|
+
<td><%= step.id %></td>
|
19
|
+
<td><%= step.type.demodulize %></td>
|
20
|
+
<td><%= step.name %></td>
|
21
|
+
<td><%= link_to 'Show', step %></td>
|
22
|
+
<td><%= link_to 'Edit', edit_step_path(step) %></td>
|
23
|
+
<td><%= link_to 'Destroy', step, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
|
31
|
+
<%= link_to 'New Step', new_step_path %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<%= link_to 'Edit', edit_step_path(@step) %> |
|
4
|
+
<%= link_to 'Steps', steps_path %>
|
5
|
+
|
6
|
+
<h1>
|
7
|
+
<%= @step.name %>
|
8
|
+
<small class="text-muted" style="font-size: 0.4em;">
|
9
|
+
<%= @step.type.demodulize.titleize %> Step
|
10
|
+
<%= @step.id %>
|
11
|
+
</small>
|
12
|
+
</h1>
|
13
|
+
|
14
|
+
<%= render partial: @step.to_partial_path("show") %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateRiddlerAdminSteps < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :riddler_steps, id: false do |t|
|
4
|
+
t.primary_key :id, :string, index: true
|
5
|
+
t.timestamps
|
6
|
+
t.string :type, null: false
|
7
|
+
t.string :name
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table :riddler_elements, id: false do |t|
|
11
|
+
t.primary_key :id, :string, index: true
|
12
|
+
t.timestamps
|
13
|
+
t.string :type, null: false
|
14
|
+
t.string :name
|
15
|
+
t.references :container, polymorphic: true, index: true, type: :string
|
16
|
+
t.integer :position
|
17
|
+
t.string :text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riddler_admin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JohnnyT
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: riddler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 5.2.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bootstrap
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.1.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.1.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ksuid
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: acts_as_list
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jquery-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: jquery-ui-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- ubergeek3141@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- MIT-LICENSE
|
133
|
+
- README.md
|
134
|
+
- Rakefile
|
135
|
+
- app/assets/config/riddler_admin_manifest.js
|
136
|
+
- app/assets/javascripts/riddler_admin/application.js
|
137
|
+
- app/assets/javascripts/riddler_admin/steps.js
|
138
|
+
- app/assets/stylesheets/riddler_admin/application.scss
|
139
|
+
- app/assets/stylesheets/riddler_admin/steps.css
|
140
|
+
- app/assets/stylesheets/scaffold.css
|
141
|
+
- app/controllers/riddler_admin/application_controller.rb
|
142
|
+
- app/controllers/riddler_admin/elements_controller.rb
|
143
|
+
- app/controllers/riddler_admin/steps_controller.rb
|
144
|
+
- app/helpers/riddler_admin/application_helper.rb
|
145
|
+
- app/helpers/riddler_admin/steps_helper.rb
|
146
|
+
- app/jobs/riddler_admin/application_job.rb
|
147
|
+
- app/mailers/riddler_admin/application_mailer.rb
|
148
|
+
- app/models/riddler_admin/application_record.rb
|
149
|
+
- app/models/riddler_admin/element.rb
|
150
|
+
- app/models/riddler_admin/elements/copy.rb
|
151
|
+
- app/models/riddler_admin/elements/heading.rb
|
152
|
+
- app/models/riddler_admin/step.rb
|
153
|
+
- app/models/riddler_admin/steps/content.rb
|
154
|
+
- app/views/layouts/riddler_admin/application.html.erb
|
155
|
+
- app/views/riddler_admin/_element.html.erb
|
156
|
+
- app/views/riddler_admin/elements/_new.html.erb
|
157
|
+
- app/views/riddler_admin/elements/_show.html.erb
|
158
|
+
- app/views/riddler_admin/elements/copy/_class.html.erb
|
159
|
+
- app/views/riddler_admin/elements/copy/_form.html.erb
|
160
|
+
- app/views/riddler_admin/elements/destroy.js.erb
|
161
|
+
- app/views/riddler_admin/elements/heading/_class.html.erb
|
162
|
+
- app/views/riddler_admin/elements/heading/_form.html.erb
|
163
|
+
- app/views/riddler_admin/elements/new.js.erb
|
164
|
+
- app/views/riddler_admin/elements/show.js.erb
|
165
|
+
- app/views/riddler_admin/steps/_form.html.erb
|
166
|
+
- app/views/riddler_admin/steps/_preview.html.erb
|
167
|
+
- app/views/riddler_admin/steps/content/_show.html.erb
|
168
|
+
- app/views/riddler_admin/steps/edit.html.erb
|
169
|
+
- app/views/riddler_admin/steps/index.html.erb
|
170
|
+
- app/views/riddler_admin/steps/new.html.erb
|
171
|
+
- app/views/riddler_admin/steps/show.html.erb
|
172
|
+
- config/routes.rb
|
173
|
+
- db/migrate/20181124201519_create_riddler_admin_steps.rb
|
174
|
+
- lib/riddler_admin.rb
|
175
|
+
- lib/riddler_admin/engine.rb
|
176
|
+
- lib/riddler_admin/version.rb
|
177
|
+
- lib/tasks/riddler_admin_tasks.rake
|
178
|
+
homepage: https://github.com/riddler/riddler_admin
|
179
|
+
licenses:
|
180
|
+
- MIT
|
181
|
+
metadata: {}
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 2.7.6
|
199
|
+
signing_key:
|
200
|
+
specification_version: 4
|
201
|
+
summary: Admin Rails engine for Riddler
|
202
|
+
test_files: []
|