yarii-editor 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +32 -0
- data/app/assets/images/yarii_editor/butterfly-small.png +0 -0
- data/app/controllers/concerns/yarii_editor/controller_authorization.rb +22 -0
- data/app/controllers/concerns/yarii_editor/repository_pullable.rb +11 -0
- data/app/controllers/yarii_editor/application_controller.rb +22 -0
- data/app/controllers/yarii_editor/dashboard_controller.rb +17 -0
- data/app/controllers/yarii_editor/documents_controller.rb +147 -0
- data/app/controllers/yarii_editor/publish_controller.rb +24 -0
- data/app/helpers/yarii_editor/application_helper.rb +9 -0
- data/app/helpers/yarii_editor/document_helper.rb +15 -0
- data/app/helpers/yarii_editor/editor_helper.rb +19 -0
- data/app/javascript/controllers/building_controller.js +28 -0
- data/app/javascript/controllers/card_controller.js +49 -0
- data/app/javascript/controllers/commit_modal_controller.js +55 -0
- data/app/javascript/controllers/editor_modal_controller.js +76 -0
- data/app/javascript/controllers/index.js +85 -0
- data/app/javascript/controllers/list_loading_controller.js +33 -0
- data/app/javascript/controllers/markdown_editor_controller.js +157 -0
- data/app/javascript/controllers/new_document_controller.js +16 -0
- data/app/javascript/controllers/push_to_public_controller.js +17 -0
- data/app/javascript/controllers/testengine_controller.js +7 -0
- data/app/javascript/lib/utils.js +45 -0
- data/app/javascript/packs/application.js +4 -0
- data/app/jobs/yarii/application_job.rb +4 -0
- data/app/mailers/yarii/application_mailer.rb +6 -0
- data/app/models/concerns/yarii_editor/model_callbacks.rb +26 -0
- data/app/models/concerns/yarii_editor/previewing.rb +18 -0
- data/app/models/page.rb +13 -0
- data/app/models/post.rb +29 -0
- data/app/models/yarii/application_record.rb +5 -0
- data/app/models/yarii/repository.rb +50 -0
- data/app/models/yarii/site.rb +107 -0
- data/app/styles/FiraGO/FiraGO-Bold.woff +0 -0
- data/app/styles/FiraGO/FiraGO-BoldItalic.woff +0 -0
- data/app/styles/FiraGO/FiraGO-Book.woff +0 -0
- data/app/styles/FiraGO/FiraGO-BookItalic.woff +0 -0
- data/app/styles/FiraGO/FiraGO-HeavyItalic.woff +0 -0
- data/app/styles/FiraGO/FiraGO-SemiBold.woff +0 -0
- data/app/styles/FiraGO/FiraGO-SemiBoldItalic.woff +0 -0
- data/app/styles/FiraGO/FiraGO.scss +48 -0
- data/app/styles/Vidaloka/Vidaloka-Regular.woff +0 -0
- data/app/styles/Vidaloka/Vidaloka.scss +6 -0
- data/app/styles/application.scss +141 -0
- data/app/styles/dashboard.scss +139 -0
- data/app/styles/editor.scss +70 -0
- data/app/styles/helpers.scss +45 -0
- data/app/views/application/yarii_extra_head.html.erb +3 -0
- data/app/views/layouts/yarii_editor/application.html.erb +21 -0
- data/app/views/yarii_editor/application/render_engine_stylesheet_tag.html.erb +1 -0
- data/app/views/yarii_editor/dashboard/_card.html.erb +3 -0
- data/app/views/yarii_editor/dashboard/_extras.html.erb +1 -0
- data/app/views/yarii_editor/dashboard/_inner_list.html.erb +42 -0
- data/app/views/yarii_editor/dashboard/_list.html.erb +34 -0
- data/app/views/yarii_editor/dashboard/index.html.erb +18 -0
- data/app/views/yarii_editor/documents/modal.html.erb +78 -0
- data/app/views/yarii_editor/editor/_dropdown.html.erb +14 -0
- data/app/views/yarii_editor/editor/_markdown.html.erb +13 -0
- data/app/views/yarii_editor/editor/_text.html.erb +13 -0
- data/app/views/yarii_editor/editor/_textarea.html.erb +13 -0
- data/app/views/yarii_editor/model_cards/_hashtags.html.erb +5 -0
- data/app/views/yarii_editor/model_cards/_page.html.erb +18 -0
- data/app/views/yarii_editor/model_cards/_post.html.erb +17 -0
- data/app/views/yarii_editor/model_cards/_standard_footer_buttons.html.erb +20 -0
- data/app/views/yarii_editor/publish/commit.html.erb +45 -0
- data/app/views/yarii_editor/shared/_navbar.html.erb +38 -0
- data/app/views/yarii_editor/shared/_publishing_menu.html.erb +42 -0
- data/config/initializers/assets.rb +1 -0
- data/config/routes.rb +16 -0
- data/config/webpack/development.js +5 -0
- data/config/webpack/environment.js +3 -0
- data/config/webpack/production.js +5 -0
- data/config/webpack/staging.js +5 -0
- data/config/webpack/test.js +5 -0
- data/config/webpacker.yml +109 -0
- data/db/migrate/20190923000809_create_yarii_sites.rb +12 -0
- data/db/migrate/20191014203116_add_git_repo_path_to_yarii_sites.rb +5 -0
- data/db/migrate/20200420221048_add_preview_build_command_to_yarii_sites.rb +5 -0
- data/lib/tasks/yarii_editor_tasks.rake +66 -0
- data/lib/yarii-editor.rb +24 -0
- data/lib/yarii-editor/engine.rb +22 -0
- data/lib/yarii-editor/setup_current_site.rb +20 -0
- data/lib/yarii-editor/setup_current_user.rb +13 -0
- data/lib/yarii-editor/version.rb +3 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34c51bc7203286b8032640275ff95921fc41049cc3ff8ca29ff84d5bff173991
|
4
|
+
data.tar.gz: 50a57ca81c3a912511d624d16cc9a22615894dde667e06aba40efc218b29f9ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06ada7816fdf2329e3b527bc88ad72172d8a1a447a46912831559478a612ecfaea44f840eea2ba684e3aaec22872b8d77b3312a7f01392d1230c65d8d7102dbd
|
7
|
+
data.tar.gz: be4c7f725ed23e589056ad1b32d33d724eda35adf6fbf94e3cbc6cb40d05bfc3d31bda37c4a3a4b9beecb3389bfbfb73c5433211ef833af1bb04087f958d3ad3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Whitefusion
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Yarii Editor Engine
|
2
|
+
|
3
|
+
Short description and motivation. Etc.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
How to use my plugin.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'yarii-editor'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
```bash
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
```bash
|
24
|
+
$ gem install yarii-editor
|
25
|
+
```
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
Contribution directions go here.
|
29
|
+
|
30
|
+
## License
|
31
|
+
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 = 'Yariieditor'
|
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
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
module ControllerAuthorization
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
before_action :check_if_yarii_is_authorized
|
7
|
+
|
8
|
+
rescue_from YariiEditor::NotAuthorizedError, with: :handle_yarii_authorization_failure
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_if_yarii_is_authorized
|
12
|
+
yarii_user = YariiEditor::CurrentUser.from_controller(self)
|
13
|
+
unless yarii_user&.can_access_yarii?
|
14
|
+
raise YariiEditor::NotAuthorizedError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def handle_yarii_authorization_failure
|
19
|
+
render plain: "503 Not Authorized", status: 503
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
protect_from_forgery with: :exception
|
4
|
+
include YariiEditor::ControllerAuthorization
|
5
|
+
include YariiEditor::RepositoryPullable
|
6
|
+
|
7
|
+
before_action :set_content_model_base_path
|
8
|
+
|
9
|
+
def set_content_model_base_path
|
10
|
+
if session[:current_yarii_site]
|
11
|
+
CurrentSite.setup(Yarii::Site.find(session[:current_yarii_site]))
|
12
|
+
else
|
13
|
+
CurrentSite.setup
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_site
|
18
|
+
CurrentSite.site
|
19
|
+
end
|
20
|
+
helper_method :current_site
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
class DashboardController < ApplicationController
|
3
|
+
before_action :pull_if_needed, except: [:list]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@custom_lists = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def list
|
10
|
+
model_details = current_site.content_models[params[:model_type]]
|
11
|
+
|
12
|
+
list = render_to_string(formats: [:html], partial: 'yarii_editor/dashboard/inner_list', locals: {model_type: params[:model_type], model_details: model_details})
|
13
|
+
|
14
|
+
render html: list
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
class DocumentsController < ApplicationController
|
3
|
+
before_action :pull_if_needed, only: [:create, :update, :destroy]
|
4
|
+
|
5
|
+
def new
|
6
|
+
@doc_heading = "New #{model_title}"
|
7
|
+
if params[:copy_from_template]
|
8
|
+
template_file_path = content_model.sanitize_filepath(File.join(current_site.git_repo_path, ".yarii", "templates", params[:copy_from_template]))
|
9
|
+
template_doc = content_model.new(file_path: template_file_path)
|
10
|
+
template_doc.load_file_from_path
|
11
|
+
@doc = template_doc.dup
|
12
|
+
@doc.file_path = nil
|
13
|
+
else
|
14
|
+
@doc = content_model.new
|
15
|
+
end
|
16
|
+
@doc.published = true # default to adding to public publishing
|
17
|
+
if @doc.respond_to? :setup_default_values
|
18
|
+
@doc.setup_default_values(self, params)
|
19
|
+
end
|
20
|
+
render 'modal', layout: nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@doc = content_model.new(secure_params)
|
25
|
+
@doc.date = DateTime.current.iso8601
|
26
|
+
if @doc.respond_to? :process_controller_params
|
27
|
+
# Allow the content model to massage incoming data, if necessary
|
28
|
+
@doc.process_controller_params(self, params)
|
29
|
+
end
|
30
|
+
@doc.save
|
31
|
+
|
32
|
+
render json: {status: 'ok', document_html: rendered_card}
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit
|
36
|
+
@doc_heading = "Edit #{model_title}"
|
37
|
+
if params[:key_path]
|
38
|
+
@doc = content_model.find(params[:id], params[:key_path])
|
39
|
+
else
|
40
|
+
@doc = content_model.find(params[:id])
|
41
|
+
end
|
42
|
+
if @doc.respond_to?(:published) and @doc.published.nil?
|
43
|
+
@doc.published = true
|
44
|
+
end
|
45
|
+
if @doc.respond_to? :setup_default_values
|
46
|
+
@doc.setup_default_values(self, params)
|
47
|
+
end
|
48
|
+
render 'modal', layout: nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def update
|
52
|
+
if params[:key_path]
|
53
|
+
@doc = content_model.find(params[:id], params[:key_path])
|
54
|
+
else
|
55
|
+
@doc = content_model.find(params[:id])
|
56
|
+
end
|
57
|
+
@doc.assign_attributes(secure_params)
|
58
|
+
if @doc.respond_to? :process_controller_params
|
59
|
+
# Allow the content model to massage incoming data, if necessary
|
60
|
+
@doc.process_controller_params(self, params)
|
61
|
+
end
|
62
|
+
@doc.save
|
63
|
+
|
64
|
+
render json: {status: 'ok', document_html: rendered_card}
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy
|
68
|
+
if params[:key_path]
|
69
|
+
@doc = content_model.find(params[:id], params[:key_path])
|
70
|
+
else
|
71
|
+
@doc = content_model.find(params[:id])
|
72
|
+
end
|
73
|
+
@doc.destroy
|
74
|
+
|
75
|
+
render json: {status: 'ok'}
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def content_model
|
81
|
+
current_site.content_models[params[:content_model]][:class_name].constantize
|
82
|
+
end
|
83
|
+
|
84
|
+
def model_title
|
85
|
+
model_details = current_site.content_models[params[:content_model]]
|
86
|
+
model_title = model_details.fetch(:title, model_details[:class_name].titleize)
|
87
|
+
end
|
88
|
+
|
89
|
+
def rendered_card
|
90
|
+
render_to_string(formats: [:html], partial: 'yarii_editor/dashboard/card', locals: {model_class: content_model, model: @doc, content_model_type: params[:content_model]})
|
91
|
+
end
|
92
|
+
|
93
|
+
def secure_params
|
94
|
+
content_model_param = params[:content_model].to_sym
|
95
|
+
variable_names = content_model.variable_names + [:content]
|
96
|
+
|
97
|
+
variable_names = variable_names.map do |variable|
|
98
|
+
if params[content_model_param][variable.to_sym].is_a? Array
|
99
|
+
# scrub empty values
|
100
|
+
params[content_model_param][variable.to_sym] = params[content_model_param][variable.to_sym].select do |value|
|
101
|
+
value.present?
|
102
|
+
end
|
103
|
+
# permit the array variable
|
104
|
+
{ variable => [] }
|
105
|
+
else
|
106
|
+
variable
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
detect_integer = ->(str) {
|
111
|
+
begin
|
112
|
+
!!Integer(str)
|
113
|
+
rescue ArgumentError, TypeError
|
114
|
+
false
|
115
|
+
end
|
116
|
+
}
|
117
|
+
variable_names.each do |variable|
|
118
|
+
value = variable.is_a?(Hash) ?
|
119
|
+
params[content_model_param][variable.keys.first.to_sym] :
|
120
|
+
params[content_model_param][variable.to_sym]
|
121
|
+
|
122
|
+
if value.is_a?(String)
|
123
|
+
if value.strip.blank?
|
124
|
+
# Scrub blank string values
|
125
|
+
params[content_model_param][variable.to_sym] = nil
|
126
|
+
elsif value.strip.match(/^false|true$/)
|
127
|
+
# Convert to real boolean values
|
128
|
+
params[content_model_param][variable.to_sym] = params[content_model_param][variable.to_sym].strip == 'true'
|
129
|
+
elsif detect_integer.call(value)
|
130
|
+
# Incoming strings that are simply numbers should be treated as such
|
131
|
+
params[content_model_param][variable.to_sym] = value.to_i
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Markdown editor adds carriage returns for some reason. Take them out!
|
137
|
+
if params[content_model_param][:content]
|
138
|
+
params[content_model_param][:content] = params[content_model_param][:content].gsub(/\r/, '')
|
139
|
+
end
|
140
|
+
if params[content_model_param][:link_excerpt]
|
141
|
+
params[content_model_param][:link_excerpt] = params[content_model_param][:link_excerpt].gsub(/\r/, '')
|
142
|
+
end
|
143
|
+
|
144
|
+
params.require(content_model_param).permit(*variable_names)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
class PublishController < ApplicationController
|
3
|
+
def remote_is_up_to_date
|
4
|
+
# NOTE: the Jekyll site config needs to include .well-known in the list of
|
5
|
+
# folders to build! Otherwise this won't work!
|
6
|
+
render json: {updated: current_site.remote_is_up_to_date?}
|
7
|
+
end
|
8
|
+
|
9
|
+
def menu
|
10
|
+
render partial: "yarii_editor/shared/publishing_menu", formats: [:html]
|
11
|
+
end
|
12
|
+
|
13
|
+
def commit
|
14
|
+
render layout: nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def push_commit
|
18
|
+
current_site.commit!(message: params[:commit_message])
|
19
|
+
current_site.push
|
20
|
+
|
21
|
+
render json: {status: 'ok'}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
module DocumentHelper
|
3
|
+
def status_of_document(document)
|
4
|
+
if document.will_be_published?
|
5
|
+
if CurrentSite.site.repository.git.diff('HEAD', '--cached').path(document.file_path).stats[:total][:files] == 1
|
6
|
+
:queued
|
7
|
+
else
|
8
|
+
:published
|
9
|
+
end
|
10
|
+
else
|
11
|
+
return :draft
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module YariiEditor
|
2
|
+
module EditorHelper
|
3
|
+
def add_field(type, props)
|
4
|
+
render "yarii_editor/editor/#{type}", props
|
5
|
+
end
|
6
|
+
|
7
|
+
def name_from_variable(props)
|
8
|
+
model_name = params[:content_model]
|
9
|
+
"#{model_name}[#{props[:variable]}]" || "unknown#{(1..10000).to_a.sample}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def value_from_variable(props)
|
13
|
+
variable = props[:variable]
|
14
|
+
if variable && @doc
|
15
|
+
@doc.send(variable)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Controller } from "stimulus"
|
2
|
+
import axios from "axios"
|
3
|
+
import { axiosPostable } from "../lib/utils"
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
initialize() {
|
7
|
+
this.axios = axiosPostable(axios)
|
8
|
+
}
|
9
|
+
|
10
|
+
connect() {
|
11
|
+
this.checkingInterval = setInterval(this.checkBuildingStatus.bind(this), 5000)
|
12
|
+
}
|
13
|
+
|
14
|
+
async checkBuildingStatus() {
|
15
|
+
try {
|
16
|
+
let response = await this.axios.get(this.data.get('path'))
|
17
|
+
if (response.data.updated) {
|
18
|
+
this.element.classList.remove('is-warning')
|
19
|
+
this.element.classList.add('is-success')
|
20
|
+
this.element.innerHTML = 'Public Website Updated!'
|
21
|
+
clearInterval(this.checkingInterval)
|
22
|
+
setTimeout(() => { this.element.remove() }, 8000)
|
23
|
+
}
|
24
|
+
} catch (error) {
|
25
|
+
console.error(error)
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Controller } from "stimulus"
|
2
|
+
import axios from "axios"
|
3
|
+
import { axiosPostable } from "../lib/utils"
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
initialize() {
|
7
|
+
this.axios = axiosPostable(axios)
|
8
|
+
}
|
9
|
+
|
10
|
+
async edit(event) {
|
11
|
+
event.preventDefault()
|
12
|
+
const editPath = event.currentTarget.href
|
13
|
+
|
14
|
+
try {
|
15
|
+
const response = await this.axios.get(editPath, {headers: {'Accept': 'text/html'}})
|
16
|
+
document.querySelector('#editor-modal-wrapper').innerHTML = response.data
|
17
|
+
document.querySelector('#editor-modal input').focus()
|
18
|
+
} catch (error) {
|
19
|
+
console.log(error)
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
async destroy(event) {
|
24
|
+
event.preventDefault()
|
25
|
+
const deletePath = event.currentTarget.href
|
26
|
+
const cardId = this.element.id
|
27
|
+
|
28
|
+
if (confirm("Are you sure you wish to delete this item?")) {
|
29
|
+
this.element.classList.add('dimmed')
|
30
|
+
try {
|
31
|
+
await this.axios.delete(deletePath)
|
32
|
+
document.getElementById(cardId).remove()
|
33
|
+
this.refreshPublishingMenu()
|
34
|
+
} catch (error) {
|
35
|
+
console.log(error)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
async refreshPublishingMenu() {
|
41
|
+
try {
|
42
|
+
let response = null
|
43
|
+
response = await this.axios.get(this.data.get('publishing-menu-path'))
|
44
|
+
document.getElementById('publishing-menu').innerHTML = response.data
|
45
|
+
} catch (error) {
|
46
|
+
console.log(error)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|