scribo 1.0.38
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 +93 -0
- data/Rakefile +40 -0
- data/app/assets/config/scribo_manifest.js +2 -0
- data/app/assets/javascripts/scribo/scribo.js +1 -0
- data/app/assets/stylesheets/scribo/scribo.css +1 -0
- data/app/controllers/concerns/maintenance_standards.rb +24 -0
- data/app/controllers/scribo/admin/sites/contents_controller.rb +86 -0
- data/app/controllers/scribo/admin/sites_controller.rb +61 -0
- data/app/controllers/scribo/api/sites_controller.rb +23 -0
- data/app/controllers/scribo/application_admin_controller.rb +11 -0
- data/app/controllers/scribo/application_controller.rb +6 -0
- data/app/controllers/scribo/contents_controller.rb +20 -0
- data/app/drops/scribo/action_dispatch/request_drop.rb +15 -0
- data/app/drops/scribo/active_model/errors_drop.rb +16 -0
- data/app/drops/scribo/application_drop.rb +9 -0
- data/app/drops/scribo/array_drop.rb +13 -0
- data/app/drops/scribo/content_drop.rb +73 -0
- data/app/drops/scribo/data_drop.rb +35 -0
- data/app/drops/scribo/form_drop.rb +26 -0
- data/app/drops/scribo/include_drop.rb +13 -0
- data/app/drops/scribo/paginator_drop.rb +73 -0
- data/app/drops/scribo/site_drop.rb +83 -0
- data/app/helpers/scribo/application_helper.rb +13 -0
- data/app/jobs/scribo/application_job.rb +6 -0
- data/app/models/scribo/application_record.rb +11 -0
- data/app/models/scribo/content.rb +378 -0
- data/app/models/scribo/site.rb +161 -0
- data/app/services/scribo/application_service.rb +9 -0
- data/app/services/scribo/content_find_service.rb +69 -0
- data/app/services/scribo/content_render_service.rb +127 -0
- data/app/services/scribo/site_export_service.rb +41 -0
- data/app/services/scribo/site_find_service.rb +26 -0
- data/app/services/scribo/site_import_service.rb +96 -0
- data/app/views/layouts/scribo.html.slim +1 -0
- data/app/views/scribo/admin/sites/_create_sites.html.slim +22 -0
- data/app/views/scribo/admin/sites/_sites.html.slim +18 -0
- data/app/views/scribo/admin/sites/contents/_form.html.slim +17 -0
- data/app/views/scribo/admin/sites/contents/create.json.jbuilder +11 -0
- data/app/views/scribo/admin/sites/contents/edit.html.slim +2 -0
- data/app/views/scribo/admin/sites/contents/edit.json.jbuilder +9 -0
- data/app/views/scribo/admin/sites/contents/index.html.slim +1 -0
- data/app/views/scribo/admin/sites/contents/move.json.jbuilder +9 -0
- data/app/views/scribo/admin/sites/contents/rename.json.jbuilder +9 -0
- data/app/views/scribo/admin/sites/contents/upload.json.jbuilder +9 -0
- data/app/views/scribo/admin/sites/import.json.jbuilder +4 -0
- data/app/views/scribo/admin/sites/index.html.slim +7 -0
- data/app/views/scribo/shared/_entry.html.slim +17 -0
- data/app/views/scribo/shared/_ide.html.slim +14 -0
- data/app/views/scribo/shared/_tree-view.html.slim +32 -0
- data/config/locales/en.yml +39 -0
- data/config/routes.rb +35 -0
- data/db/migrate/20200123095630_initial_scribo.rb +34 -0
- data/db/migrate/20220919124119_add_ancestry_to_scribo_contents.rb +13 -0
- data/db/migrate/20220919124749_remove_parent_id_from_scribo_contents.rb +8 -0
- data/lib/scribo/action_controller_helpers.rb +51 -0
- data/lib/scribo/action_controller_renderers.rb +71 -0
- data/lib/scribo/action_view_helpers.rb +17 -0
- data/lib/scribo/active_record_helpers.rb +11 -0
- data/lib/scribo/configuration.rb +97 -0
- data/lib/scribo/engine.rb +24 -0
- data/lib/scribo/i18n_store.rb +100 -0
- data/lib/scribo/liquid/filters/jekyll_filters.rb +94 -0
- data/lib/scribo/liquid/filters/markdownify.rb +11 -0
- data/lib/scribo/liquid/filters/url_filters.rb +76 -0
- data/lib/scribo/liquid/parser.rb +32 -0
- data/lib/scribo/liquid/tags/application_assets_tag.rb +14 -0
- data/lib/scribo/liquid/tags/application_js_tag.rb +16 -0
- data/lib/scribo/liquid/tags/asset_tag.rb +56 -0
- data/lib/scribo/liquid/tags/button_tag.rb +24 -0
- data/lib/scribo/liquid/tags/check_box_tag.rb +31 -0
- data/lib/scribo/liquid/tags/csrf_meta_tags_tag.rb +16 -0
- data/lib/scribo/liquid/tags/date_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/editable_url_tag.rb +19 -0
- data/lib/scribo/liquid/tags/email_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/feed_meta_tag.rb +22 -0
- data/lib/scribo/liquid/tags/field_error_tag.rb +26 -0
- data/lib/scribo/liquid/tags/fields_for_tag.rb +82 -0
- data/lib/scribo/liquid/tags/form_tag.rb +57 -0
- data/lib/scribo/liquid/tags/google_analytics_javascript_tag.rb +30 -0
- data/lib/scribo/liquid/tags/google_tag_manager_javascript_tag.rb +28 -0
- data/lib/scribo/liquid/tags/hidden_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/highlight_tag.rb +106 -0
- data/lib/scribo/liquid/tags/include_tag.rb +28 -0
- data/lib/scribo/liquid/tags/label_tag.rb +24 -0
- data/lib/scribo/liquid/tags/number_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/options_for_select.rb +36 -0
- data/lib/scribo/liquid/tags/password_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/search_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/search_tag.rb +29 -0
- data/lib/scribo/liquid/tags/select_tag.rb +22 -0
- data/lib/scribo/liquid/tags/seo_tag.rb +35 -0
- data/lib/scribo/liquid/tags/set_session.rb +19 -0
- data/lib/scribo/liquid/tags/telephone_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/text_field_tag.rb +35 -0
- data/lib/scribo/liquid/tags/textarea_tag.rb +28 -0
- data/lib/scribo/liquid/tags/time_field_tag.rb +23 -0
- data/lib/scribo/liquid/tags/url_field_tag.rb +23 -0
- data/lib/scribo/preamble.rb +89 -0
- data/lib/scribo/sassc/importer.rb +72 -0
- data/lib/scribo/utility.rb +94 -0
- data/lib/scribo/version.rb +5 -0
- data/lib/scribo.rb +59 -0
- data/lib/tasks/scribo_tasks.rake +28 -0
- metadata +498 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fed1fcd709cca14b78b592dea59e90e7b9f5878fb1e68c91dbd3bf4e1f1f4c9e
|
4
|
+
data.tar.gz: b24bc25e2c1e55c0313fc284d8e62f9a59ffcc6712707848f7a296bbcc9be7a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f2ade1bb9a68e21915299b22e3f571dfbc83774cd2cc906acea2829d7108eb0058e5f6f63c8bed2bf48fe702ea77b59e47591ea5d341406185fc6473fa82bc4
|
7
|
+
data.tar.gz: f5d01119bdf9aa97d19f0cfd116dbd43bcac04d150bde68742d554e541a2203defaafd6a165188d1ba710d8ebb285f17197f7b85d70aad77bc1428ffd5c6449b
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Tom de Grunt
|
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,93 @@
|
|
1
|
+
# Scribo
|
2
|
+
|
3
|
+
A easy to use, embeddable CMS for Ruby on Rails.
|
4
|
+
Scribo is designed to work with your models and can also render your content inside customer designed layouts.
|
5
|
+
|
6
|
+
## Features
|
7
|
+
|
8
|
+
Scribo is designed to be easy to use and we try to keep it as simple as possible.
|
9
|
+
It's designed to have the least possible impact on your database, we only use two models/tables (Site and Content).
|
10
|
+
It also makes no assumptions about your data models, it does come feature packed though:
|
11
|
+
|
12
|
+
- Pages
|
13
|
+
- Blog (with permalinks & categories)
|
14
|
+
- Static assets
|
15
|
+
- Data files (think: make a page based on an Excel sheet)
|
16
|
+
- Layouts
|
17
|
+
- [Liquid](http://liquidmarkup.org) templating
|
18
|
+
- Mostly [Jekyll](https://jekyllrb.com) compatibile
|
19
|
+
- Use of [YAML](https://yaml.org) in front-matter and configuration
|
20
|
+
- Use of [Jekyll themes](https://jekyllrb.com/docs/themes/)
|
21
|
+
|
22
|
+
## Documentation
|
23
|
+
|
24
|
+
- [YAML](https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml) cheatsheet
|
25
|
+
- Quick [YAML](https://learnxinyminutes.com/docs/yaml/) introduction
|
26
|
+
|
27
|
+
## API
|
28
|
+
|
29
|
+
The API uses token authorization, the token is obtained by making an sgid from the `scribable`.
|
30
|
+
So for a `scribable` model `Account`, you could create it as follows:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
token = Account.first.to_sgid(for: 'scribo', expires_in: nil).to_s
|
34
|
+
```
|
35
|
+
|
36
|
+
This token can be used in the below request.
|
37
|
+
|
38
|
+
### POST /api/sites/import
|
39
|
+
|
40
|
+
This allows you to import a site (in ZIP format) using an API token.
|
41
|
+
|
42
|
+
```shell
|
43
|
+
curl -H 'Authorization: Token {token}' -X POST -F 'files[]=@site.zip' https://endpoint/api/sites/import
|
44
|
+
```
|
45
|
+
|
46
|
+
## Installation
|
47
|
+
|
48
|
+
Add this line to your application's Gemfile:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
gem 'scribo'
|
52
|
+
```
|
53
|
+
|
54
|
+
Migrate your database:
|
55
|
+
|
56
|
+
```bash
|
57
|
+
$ bin/rails db:migrate
|
58
|
+
```
|
59
|
+
|
60
|
+
Then add Scribo to your routes file.
|
61
|
+
Scribo consumes all URLs, so make sure you put the following line at the bottom of your routes.rb.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
mount Scribo::Engine, at: '/'
|
65
|
+
```
|
66
|
+
|
67
|
+
## Using your controllers with scribo
|
68
|
+
|
69
|
+
In your controller add the following:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
render(scribo: current_site, path: '/index', restricted: false, owner: Account.first)
|
73
|
+
```
|
74
|
+
|
75
|
+
This will look for `index` in the `current_site`.
|
76
|
+
|
77
|
+
## Testing
|
78
|
+
|
79
|
+
bin/rails db:drop
|
80
|
+
bin/rails db:create
|
81
|
+
bin/rails db:migrate
|
82
|
+
|
83
|
+
The admin side of Scribo can be accessed here: https://localhost:3000/sites/
|
84
|
+
Run `yarn watch` and you can develop using the above URL.
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/entropydecelerator/scribo.
|
89
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
90
|
+
|
91
|
+
## License
|
92
|
+
|
93
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rdoc/task'
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'Scribo'
|
14
|
+
rdoc.options << '--line-numbers'
|
15
|
+
rdoc.rdoc_files.include('README.md')
|
16
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
20
|
+
load 'rails/tasks/engine.rake'
|
21
|
+
|
22
|
+
load 'rails/tasks/statistics.rake'
|
23
|
+
|
24
|
+
require 'bundler/gem_tasks'
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
|
28
|
+
Rake::TestTask.new(:test) do |t|
|
29
|
+
t.libs << 'test'
|
30
|
+
t.pattern = 'test/**/*_test.rb'
|
31
|
+
t.verbose = false
|
32
|
+
t.warning = false
|
33
|
+
end
|
34
|
+
|
35
|
+
task default: :test
|
36
|
+
|
37
|
+
# Adds the Auxilium semver task
|
38
|
+
spec = Gem::Specification.find_by_name 'auxilium'
|
39
|
+
load "#{spec.gem_dir}/lib/tasks/semver.rake"
|
40
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
../../../../frontend/dist/scribo.js
|
@@ -0,0 +1 @@
|
|
1
|
+
../../../../frontend/dist/scribo.css
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MaintenanceStandards
|
4
|
+
# Informs the user and redirects when needed
|
5
|
+
#
|
6
|
+
# @param result [Boolean] was update or create succesful
|
7
|
+
# @param path [URL] where to redirect to
|
8
|
+
# @param notice [String] What to show on success
|
9
|
+
# @param error [String] What to show on error
|
10
|
+
# @param render_action [Symbol] What to render
|
11
|
+
#
|
12
|
+
def flash_and_redirect(result, path, notice, error, render_action = :edit)
|
13
|
+
if result
|
14
|
+
if params[:commit] == 'continue'
|
15
|
+
flash.now[:notice] = notice
|
16
|
+
else
|
17
|
+
redirect_to(path, notice: notice) && return
|
18
|
+
end
|
19
|
+
else
|
20
|
+
flash.now[:error] = error
|
21
|
+
end
|
22
|
+
render render_action
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_admin_controller'
|
4
|
+
|
5
|
+
module Scribo
|
6
|
+
module Admin
|
7
|
+
class Sites::ContentsController < ApplicationAdminController
|
8
|
+
before_action :set_objects
|
9
|
+
|
10
|
+
# Render the IDE
|
11
|
+
def index; end
|
12
|
+
|
13
|
+
def edit; end
|
14
|
+
|
15
|
+
def update
|
16
|
+
@content.update(content_params)
|
17
|
+
render :edit
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
render :edit
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy
|
25
|
+
@content.destroy
|
26
|
+
head 200
|
27
|
+
end
|
28
|
+
|
29
|
+
def move
|
30
|
+
if params[:to]
|
31
|
+
new_parent = @site.contents.find(params[:to])
|
32
|
+
@content.update!(parent: new_parent)
|
33
|
+
else
|
34
|
+
@content.update!(parent_id: nil)
|
35
|
+
end
|
36
|
+
rescue
|
37
|
+
Signum.error(Current.user, text: t('.move_fail'))
|
38
|
+
end
|
39
|
+
|
40
|
+
def rename
|
41
|
+
@content.update(path: params[:to]) if params[:to]
|
42
|
+
end
|
43
|
+
|
44
|
+
def create
|
45
|
+
parent = params[:parent] ? @site.contents.find(params[:parent]) : nil
|
46
|
+
@content = @site.contents.create!(path: params[:path], kind: params[:kind], parent: parent)
|
47
|
+
rescue
|
48
|
+
Signum.error(Current.user, text: t('.create_fail', kind: params[:kind]))
|
49
|
+
end
|
50
|
+
|
51
|
+
def upload
|
52
|
+
@parent = Scribo::Content.find(params[:content][:parent_id]) if params[:content][:parent_id]
|
53
|
+
|
54
|
+
params[:content][:files]&.each do |file|
|
55
|
+
content = @site.contents.create!(kind: Scribo::Utility.kind_for_path(file.original_filename),
|
56
|
+
path: file.original_filename, data_with_frontmatter: file.read)
|
57
|
+
content.update!(parent: @parent) if @parent
|
58
|
+
rescue
|
59
|
+
Signum.error(Current.user, text:t('.upload_fail'))
|
60
|
+
end
|
61
|
+
|
62
|
+
@contents = @site.contents.roots.reorder(:path) # unless params[:content][:parent_id]
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def set_objects
|
68
|
+
@site = Scribo::Site.find(params[:site_id])
|
69
|
+
@content = if params[:id]
|
70
|
+
@site.contents.find(params[:id])
|
71
|
+
else
|
72
|
+
params[:content] ? @site.contents.new(content_params) : @site.contents.new
|
73
|
+
end
|
74
|
+
|
75
|
+
@contents = @site.contents.roots.where(kind: 'folder').reorder(:path) + @site.contents.roots.where("kind <> 'folder'").reorder(:path)
|
76
|
+
@readme = @site.contents.roots.where("path ilike '%readme%'").first
|
77
|
+
end
|
78
|
+
|
79
|
+
def content_params
|
80
|
+
params.require(:content).permit(:data_with_frontmatter).tap do |whitelisted|
|
81
|
+
whitelisted[:data_with_frontmatter] = params[:content][:data_with_frontmatter].read.force_encoding('utf-8') if params[:content][:data_with_frontmatter].respond_to?(:read)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_admin_controller'
|
4
|
+
|
5
|
+
module Scribo
|
6
|
+
module Admin
|
7
|
+
class SitesController < ApplicationAdminController
|
8
|
+
before_action :set_objects, except: [:index]
|
9
|
+
|
10
|
+
def new
|
11
|
+
if params[:template_id]
|
12
|
+
url = Scribo.config.templates.find { |t| t[:id] == params[:template_id] }&.[](:url)
|
13
|
+
redirect_to(admin_sites_path) && return unless url
|
14
|
+
|
15
|
+
file = Down.download(url)
|
16
|
+
@site = Scribo::SiteImportService.new(file.path, scribable: Scribo.config.scribable_for_request(request)).call
|
17
|
+
redirect_to(admin_site_contents_path(@site))
|
18
|
+
nil
|
19
|
+
else
|
20
|
+
@site = Scribo::Site.create!(scribable: Scribo.config.scribable_for_request(request))
|
21
|
+
Scribo.config.after_site_create(@site)
|
22
|
+
redirect_to(admin_site_contents_path(@site))
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
flash_and_redirect @site.save, admin_site_contents_path(@site), 'Site created successfully',
|
29
|
+
'There were problems creating the site'
|
30
|
+
end
|
31
|
+
|
32
|
+
def index
|
33
|
+
@sites = Site.adminable
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
flash_and_redirect @site.destroy, admin_sites_url, 'Site deleted successfully',
|
38
|
+
'There were problems deleting the site'
|
39
|
+
end
|
40
|
+
|
41
|
+
def import
|
42
|
+
@sites = Site.adminable
|
43
|
+
params[:files].each do |file|
|
44
|
+
Scribo::SiteImportService.new(file.path, scribable: Scribo.config.scribable_for_request(request)).call
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def export
|
49
|
+
name, data = Scribo::SiteExportService.new(@site).call
|
50
|
+
send_data data, type: 'application/zip', filename: name
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def set_objects
|
56
|
+
@sites = Site.adminable
|
57
|
+
@site = Site.adminable.find(params[:id]) if params[:id]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_controller'
|
4
|
+
module Scribo
|
5
|
+
module Api
|
6
|
+
class SitesController < ApplicationController
|
7
|
+
skip_before_action :verify_authenticity_token
|
8
|
+
|
9
|
+
def import
|
10
|
+
sgid = request.authorization&.split&.last
|
11
|
+
head(400) && return unless sgid
|
12
|
+
|
13
|
+
scribable = ::GlobalID::Locator.locate_signed(sgid, for: 'scribo')
|
14
|
+
|
15
|
+
head(401) && return unless scribable
|
16
|
+
|
17
|
+
params[:files].each do |file|
|
18
|
+
Scribo::SiteImportService.new(file.path, scribable: scribable).call
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_controller'
|
4
|
+
require_dependency 'concerns/maintenance_standards'
|
5
|
+
|
6
|
+
module Scribo
|
7
|
+
class ApplicationAdminController < ApplicationController
|
8
|
+
include MaintenanceStandards
|
9
|
+
include Scribo.config.admin_authentication_module.constantize if Scribo.config.admin_authentication_module
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_controller'
|
4
|
+
require_dependency 'scribo/action_dispatch/request_drop'
|
5
|
+
|
6
|
+
module Scribo
|
7
|
+
class ContentsController < ApplicationController
|
8
|
+
protect_from_forgery except: :show
|
9
|
+
|
10
|
+
def show
|
11
|
+
render scribo: request
|
12
|
+
rescue StandardError => e
|
13
|
+
Scribo.config.logger.error '-' * 80
|
14
|
+
Scribo.config.logger.error '=> Content rendering errors: ' + e.message
|
15
|
+
Scribo.config.logger.error '=> ' + e.backtrace.map(&:to_s).join("\n")
|
16
|
+
Scribo.config.logger.error '-' * 80
|
17
|
+
render body: e.message, status: 500
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../application_drop'
|
4
|
+
|
5
|
+
module Scribo
|
6
|
+
module ActionDispatch
|
7
|
+
class RequestDrop < ::Scribo::ApplicationDrop
|
8
|
+
delegate :fullpath, :host, :scheme, :ip, :media_type, :query_parameters, :uuid, :request_method, to: :@object
|
9
|
+
|
10
|
+
def headers
|
11
|
+
@object.headers.to_h
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Scribo
|
4
|
+
module ActiveModel
|
5
|
+
class ErrorsDrop < Liquid::Drop
|
6
|
+
def initialize(object)
|
7
|
+
@object = object
|
8
|
+
end
|
9
|
+
delegate :base, :details, to: :@object
|
10
|
+
|
11
|
+
def messages
|
12
|
+
@object.messages.stringify_keys
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_drop'
|
4
|
+
|
5
|
+
module Scribo
|
6
|
+
class ArrayDrop < ApplicationDrop
|
7
|
+
delegate :each, :map, :size, :length, :first, :last, :empty?, :join, to: :@object
|
8
|
+
|
9
|
+
def ==(other)
|
10
|
+
@object.include?(other) || @object == other
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_drop'
|
4
|
+
|
5
|
+
module Scribo
|
6
|
+
# https://jekyllrb.com/docs/variables/#page-variables
|
7
|
+
class ContentDrop < ApplicationDrop
|
8
|
+
delegate :url, :path, :excerpt, :categories, :tags, :dir, to: :@object
|
9
|
+
delegate :site, to: :@object
|
10
|
+
|
11
|
+
def initialize(object)
|
12
|
+
@object = object
|
13
|
+
@properties = object.properties
|
14
|
+
end
|
15
|
+
|
16
|
+
def date
|
17
|
+
@object.date
|
18
|
+
end
|
19
|
+
|
20
|
+
def id
|
21
|
+
@object.full_path
|
22
|
+
end
|
23
|
+
|
24
|
+
# FIXME: This breaks when the collection_path is set (https://jekyllrb.com/docs/collections/#setup)
|
25
|
+
def collection
|
26
|
+
base_dir = @object.dir.split('/').first.gsub('_', '')
|
27
|
+
base_dir if @object.site.collections.include?(base_dir)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Find out how to merge properties with this drop
|
31
|
+
def name
|
32
|
+
@properties&.[]('name') || @object.path
|
33
|
+
end
|
34
|
+
|
35
|
+
def layout
|
36
|
+
@object.layout_name
|
37
|
+
end
|
38
|
+
|
39
|
+
def next
|
40
|
+
@object.right_sibling
|
41
|
+
end
|
42
|
+
|
43
|
+
def previous
|
44
|
+
@object.left_sibling
|
45
|
+
end
|
46
|
+
|
47
|
+
def content
|
48
|
+
Scribo::ContentRenderService.new(@object, @context.registers['controller'], {}).call
|
49
|
+
end
|
50
|
+
|
51
|
+
def [](property)
|
52
|
+
if respond_to?(property)
|
53
|
+
send(property)
|
54
|
+
elsif @properties.present?
|
55
|
+
@properties[property]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def categories
|
60
|
+
Scribo::ArrayDrop.new(@properties&.[]('categories'))
|
61
|
+
end
|
62
|
+
|
63
|
+
def tags
|
64
|
+
Scribo::ArrayDrop.new(@properties&.[]('tags'))
|
65
|
+
end
|
66
|
+
|
67
|
+
def liquid_method_missing(method)
|
68
|
+
return nil unless @properties
|
69
|
+
|
70
|
+
@properties[method.to_s]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'scribo/application_drop'
|
4
|
+
require 'csv'
|
5
|
+
|
6
|
+
module Scribo
|
7
|
+
class DataDrop < ApplicationDrop
|
8
|
+
attr_accessor :data_path
|
9
|
+
|
10
|
+
def initialize(object, data_path = [])
|
11
|
+
@object = object
|
12
|
+
@data_path = data_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](name)
|
16
|
+
method_missing(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(method)
|
20
|
+
content = @object.contents.data((data_path + [method.to_s]).join('/')).first
|
21
|
+
|
22
|
+
return Scribo::DataDrop.new(@object, data_path + [content.path]) if content&.kind == 'folder'
|
23
|
+
|
24
|
+
case content&.content_type
|
25
|
+
when 'text/x-yaml'
|
26
|
+
Scribo::Utility.yaml_safe_parse(content.data)
|
27
|
+
when 'application/json'
|
28
|
+
::JSON.parse(content.data)
|
29
|
+
when 'text/csv'
|
30
|
+
CSV.parse(content.data, headers: true, liberal_parsing: true, quote_char: '"', col_sep: ';',
|
31
|
+
row_sep: "\r\n").map(&:to_h)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Scribo
|
4
|
+
class FormDrop < Liquid::Drop
|
5
|
+
def initialize(model, attribute = nil)
|
6
|
+
@model = model
|
7
|
+
@attribute = attribute
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :model, :attribute
|
11
|
+
|
12
|
+
def class_name
|
13
|
+
model.class.name.gsub(/Drop$/, '')
|
14
|
+
end
|
15
|
+
|
16
|
+
def errors
|
17
|
+
errors = if @model&.instance_variable_get('@object')
|
18
|
+
@model.instance_variable_get('@object').errors
|
19
|
+
else
|
20
|
+
::ActiveModel::Errors.new([])
|
21
|
+
end
|
22
|
+
|
23
|
+
::Scribo::ActiveModel::ErrorsDrop.new errors
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|