yarii-editor 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +31 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/images/yarii_editor/butterfly-small.png +0 -0
  6. data/app/controllers/concerns/yarii_editor/controller_authorization.rb +22 -0
  7. data/app/controllers/concerns/yarii_editor/repository_pullable.rb +11 -0
  8. data/app/controllers/yarii_editor/application_controller.rb +22 -0
  9. data/app/controllers/yarii_editor/dashboard_controller.rb +17 -0
  10. data/app/controllers/yarii_editor/documents_controller.rb +147 -0
  11. data/app/controllers/yarii_editor/publish_controller.rb +24 -0
  12. data/app/helpers/yarii_editor/application_helper.rb +9 -0
  13. data/app/helpers/yarii_editor/document_helper.rb +15 -0
  14. data/app/helpers/yarii_editor/editor_helper.rb +19 -0
  15. data/app/javascript/controllers/building_controller.js +28 -0
  16. data/app/javascript/controllers/card_controller.js +49 -0
  17. data/app/javascript/controllers/commit_modal_controller.js +55 -0
  18. data/app/javascript/controllers/editor_modal_controller.js +76 -0
  19. data/app/javascript/controllers/index.js +85 -0
  20. data/app/javascript/controllers/list_loading_controller.js +33 -0
  21. data/app/javascript/controllers/markdown_editor_controller.js +157 -0
  22. data/app/javascript/controllers/new_document_controller.js +16 -0
  23. data/app/javascript/controllers/push_to_public_controller.js +17 -0
  24. data/app/javascript/controllers/testengine_controller.js +7 -0
  25. data/app/javascript/lib/utils.js +45 -0
  26. data/app/javascript/packs/application.js +4 -0
  27. data/app/jobs/yarii/application_job.rb +4 -0
  28. data/app/mailers/yarii/application_mailer.rb +6 -0
  29. data/app/models/concerns/yarii_editor/model_callbacks.rb +26 -0
  30. data/app/models/concerns/yarii_editor/previewing.rb +18 -0
  31. data/app/models/page.rb +13 -0
  32. data/app/models/post.rb +29 -0
  33. data/app/models/yarii/application_record.rb +5 -0
  34. data/app/models/yarii/repository.rb +50 -0
  35. data/app/models/yarii/site.rb +107 -0
  36. data/app/styles/FiraGO/FiraGO-Bold.woff +0 -0
  37. data/app/styles/FiraGO/FiraGO-BoldItalic.woff +0 -0
  38. data/app/styles/FiraGO/FiraGO-Book.woff +0 -0
  39. data/app/styles/FiraGO/FiraGO-BookItalic.woff +0 -0
  40. data/app/styles/FiraGO/FiraGO-HeavyItalic.woff +0 -0
  41. data/app/styles/FiraGO/FiraGO-SemiBold.woff +0 -0
  42. data/app/styles/FiraGO/FiraGO-SemiBoldItalic.woff +0 -0
  43. data/app/styles/FiraGO/FiraGO.scss +48 -0
  44. data/app/styles/Vidaloka/Vidaloka-Regular.woff +0 -0
  45. data/app/styles/Vidaloka/Vidaloka.scss +6 -0
  46. data/app/styles/application.scss +141 -0
  47. data/app/styles/dashboard.scss +139 -0
  48. data/app/styles/editor.scss +70 -0
  49. data/app/styles/helpers.scss +45 -0
  50. data/app/views/application/yarii_extra_head.html.erb +3 -0
  51. data/app/views/layouts/yarii_editor/application.html.erb +21 -0
  52. data/app/views/yarii_editor/application/render_engine_stylesheet_tag.html.erb +1 -0
  53. data/app/views/yarii_editor/dashboard/_card.html.erb +3 -0
  54. data/app/views/yarii_editor/dashboard/_extras.html.erb +1 -0
  55. data/app/views/yarii_editor/dashboard/_inner_list.html.erb +42 -0
  56. data/app/views/yarii_editor/dashboard/_list.html.erb +34 -0
  57. data/app/views/yarii_editor/dashboard/index.html.erb +18 -0
  58. data/app/views/yarii_editor/documents/modal.html.erb +78 -0
  59. data/app/views/yarii_editor/editor/_dropdown.html.erb +14 -0
  60. data/app/views/yarii_editor/editor/_markdown.html.erb +13 -0
  61. data/app/views/yarii_editor/editor/_text.html.erb +13 -0
  62. data/app/views/yarii_editor/editor/_textarea.html.erb +13 -0
  63. data/app/views/yarii_editor/model_cards/_hashtags.html.erb +5 -0
  64. data/app/views/yarii_editor/model_cards/_page.html.erb +18 -0
  65. data/app/views/yarii_editor/model_cards/_post.html.erb +17 -0
  66. data/app/views/yarii_editor/model_cards/_standard_footer_buttons.html.erb +20 -0
  67. data/app/views/yarii_editor/publish/commit.html.erb +45 -0
  68. data/app/views/yarii_editor/shared/_navbar.html.erb +38 -0
  69. data/app/views/yarii_editor/shared/_publishing_menu.html.erb +42 -0
  70. data/config/initializers/assets.rb +1 -0
  71. data/config/routes.rb +16 -0
  72. data/config/webpack/development.js +5 -0
  73. data/config/webpack/environment.js +3 -0
  74. data/config/webpack/production.js +5 -0
  75. data/config/webpack/staging.js +5 -0
  76. data/config/webpack/test.js +5 -0
  77. data/config/webpacker.yml +109 -0
  78. data/db/migrate/20190923000809_create_yarii_sites.rb +12 -0
  79. data/db/migrate/20191014203116_add_git_repo_path_to_yarii_sites.rb +5 -0
  80. data/db/migrate/20200420221048_add_preview_build_command_to_yarii_sites.rb +5 -0
  81. data/lib/tasks/yarii_editor_tasks.rake +66 -0
  82. data/lib/yarii-editor.rb +24 -0
  83. data/lib/yarii-editor/engine.rb +22 -0
  84. data/lib/yarii-editor/setup_current_site.rb +20 -0
  85. data/lib/yarii-editor/setup_current_user.rb +13 -0
  86. data/lib/yarii-editor/version.rb +3 -0
  87. metadata +172 -0
@@ -0,0 +1,14 @@
1
+ <%-
2
+ input_classes = ['input']
3
+ input_classes << className if local_assigns[:className]
4
+ name = name_from_variable(local_assigns)
5
+ value = value_from_variable(local_assigns)
6
+ %>
7
+ <div class="field">
8
+ <label class="label"><%= local_assigns[:label] %></label>
9
+ <div class="select">
10
+ <%= content_tag :select, nil, name: name, class: input_classes.join(' ') do %>
11
+ <% options_for_select @doc.send("values_for_#{variable}"), value %>
12
+ <% end %>
13
+ </div>
14
+ </div>
@@ -0,0 +1,13 @@
1
+ <%-
2
+ props = local_assigns
3
+ input_classes = ['textarea']
4
+ input_classes << className if props[:className]
5
+ name = name_from_variable(props)
6
+ value = value_from_variable(props) || ""
7
+ %>
8
+ <div data-controller="markdown-editor" class="field">
9
+ <% if props[:label] %><label class="label"><%= props[:label] %></label><% end %>
10
+ <div class="control">
11
+ <%= content_tag :textarea, value, name: name, data: {target: 'markdown-editor.editor'}, class: input_classes.join(' '), rows: 10, placeholder: props[:placeholder] %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,13 @@
1
+ <%-
2
+ props = local_assigns
3
+ input_classes = ['input']
4
+ input_classes << className if props[:className]
5
+ name = name_from_variable(props)
6
+ value = value_from_variable(props)
7
+ %>
8
+ <div class="field">
9
+ <label class="label"><%= props[:label] %></label>
10
+ <div class="control">
11
+ <%= content_tag :input, nil, name: name, value: value, class: input_classes.join(' '), type: 'text', placeholder: props[:placeholder] %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,13 @@
1
+ <%-
2
+ props = local_assigns
3
+ input_classes = ['textarea']
4
+ input_classes << className if props[:className]
5
+ name = name_from_variable(props)
6
+ value = value_from_variable(props) || ""
7
+ %>
8
+ <div class="field">
9
+ <label class="label"><%= props[:label] %></label>
10
+ <div class="control">
11
+ <%= content_tag :textarea, value, name: name, class: input_classes.join(' '), rows: 2, placeholder: props[:placeholder] %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,5 @@
1
+ <p class="tags">
2
+ <% tags.split(' ').each do |tag| %>
3
+ <span class="tag is-medium is-rounded is-success">#<%= tag %></span>
4
+ <% end %>
5
+ </p>
@@ -0,0 +1,18 @@
1
+ <header class="card-header">
2
+ <p class="card-header-title">
3
+ <%= model.title %>
4
+ </p>
5
+ </header>
6
+ <div class="card-content">
7
+ <div class="content">
8
+ <p><%= model.subtitle || model.content&.truncate(250) %></p>
9
+ <% if model.tags.present? %>
10
+ <%= render 'yarii_editor/model_cards/hashtags', tags: model.tags %>
11
+ <% end %>
12
+ <p class="has-text-right"><time datetime="<%= model.posted_datetime.strftime('%Y-%-m-%-d') %>"><%= model.posted_datetime.strftime('%B %-d, %Y') %></time> <small class="has-text-grey">/</small>
13
+ <small class="has-text-primary"><%= Base64::decode64 model.id %></small></p>
14
+ </div>
15
+ </div>
16
+ <footer class="card-footer">
17
+ <%= render 'yarii_editor/model_cards/standard_footer_buttons', model: model, content_model_type: content_model_type %>
18
+ </footer>
@@ -0,0 +1,17 @@
1
+ <header class="card-header">
2
+ <p class="card-header-title">
3
+ <%= model.title %>
4
+ </p>
5
+ </header>
6
+ <div class="card-content">
7
+ <div class="content">
8
+ <p><%= model.subtitle || model.content&.truncate(250) %></p>
9
+ <% if model.tags.present? %>
10
+ <%= render 'yarii_editor/model_cards/hashtags', tags: model.tags %>
11
+ <% end %>
12
+ <p class="has-text-right"><time datetime="<%= model.posted_datetime.strftime('%Y-%-m-%-d') %>"><%= model.posted_datetime.strftime('%B %-d, %Y') %></time></p>
13
+ </div>
14
+ </div>
15
+ <footer class="card-footer">
16
+ <%= render 'yarii_editor/model_cards/standard_footer_buttons', model: model, content_model_type: content_model_type %>
17
+ </footer>
@@ -0,0 +1,20 @@
1
+ <%- props = local_assigns %>
2
+ <% if props[:model].is_a? Yarii::DatafileModel %>
3
+ <a data-action="card#edit" href="<%= yarii_editor.edit_document_path(props[:model], content_model: props[:content_model_type], key_path: props[:model].key_path) %>" class="card-footer-item">
4
+ <span class="icon"><i class="fa fa-pencil-square-o"></i></span>
5
+ <span>Edit</span>
6
+ </a>
7
+ <% else %>
8
+ <a data-action="card#edit" href="<%= yarii_editor.edit_document_path(props[:model], content_model: props[:content_model_type]) %>" class="card-footer-item">
9
+ <span class="icon"><i class="fa fa-pencil-square-o"></i></span>
10
+ <span>Edit</span>
11
+ </a>
12
+ <a href="<%= props[:model].preview_url %>" target="_blank" class="card-footer-item">
13
+ <span class="icon"><i class="fa fa-eye"></i></span>
14
+ <span>Preview</span>
15
+ </a>
16
+ <a data-action="card#destroy" href="<%= yarii_editor.destroy_document_path(props[:model], content_model: props[:content_model_type]) %>" class="card-footer-item">
17
+ <span class="icon"><i class="fa fa-trash"></i></span>
18
+ <span>Delete</span>
19
+ </a>
20
+ <% end %>
@@ -0,0 +1,45 @@
1
+ <div
2
+ data-controller="commit-modal"
3
+ data-commit-modal-path="<%= yarii_editor.push_commit_publish_path %>"
4
+ data-commit-modal-publishing-menu-path="<%= yarii_editor.publishing_menu_path %>"
5
+ id="commit-modal"
6
+ class="modal is-active"
7
+ >
8
+ <div class="modal-background"></div>
9
+ <div class="modal-card">
10
+ <header class="modal-card-head">
11
+ <p class="modal-card-title">Push Updates to Public</p>
12
+ <button data-action="commit-modal#cancel" class="delete" aria-label="close"></button>
13
+ </header>
14
+ <section class="modal-card-body">
15
+ <%= form_tag do %>
16
+ <div class="content">
17
+ <p>Describe the updates you're pushing to the public website. For example:</p>
18
+
19
+ <ul>
20
+ <li>New "Title Goes Here" blog post</li>
21
+ <li>Updated the pricing page</li>
22
+ <li>Deleted old event listing</li>
23
+ <li>Fixed typos on upcoming products</li>
24
+ <li>etc.</li>
25
+ </ul>
26
+
27
+ <p>This commit message will be stored in the version history for your website repository.</p>
28
+ </div>
29
+
30
+ <div class="field">
31
+ <label class="label" for="commit_message">Commit Message:</label>
32
+ <div class="control">
33
+ <input class="input" type="text" name="commit_message" />
34
+ </div>
35
+ </div>
36
+ <% end %>
37
+ </section>
38
+ <footer class="modal-card-foot">
39
+ <div data-target="commit-modal.status" class="modal-foot-status"></div>
40
+ <button data-action="commit-modal#cancel" class="button is-dark is-text">Cancel</button>
41
+ &nbsp;
42
+ <button data-action="commit-modal#commit" class="button is-success">Push Updates</button>
43
+ </footer>
44
+ </div>
45
+ </div>
@@ -0,0 +1,38 @@
1
+ <nav class="navbar is-fixed-top is-dark" role="navigation" aria-label="main navigation">
2
+ <div class="navbar-brand">
3
+ <h1 class="navbar-item"><%= image_tag 'yarii_editor/butterfly-small.png', alt: 'Yarii' %> Yarii</h1>
4
+
5
+ <a role="button" class="navbar-burger" data-target="navMenu" aria-label="menu" aria-expanded="false" onclick="document.querySelectorAll('.navbar .navbar-burger, #navMenu').forEach((item) => {item.classList.toggle('is-active')})">
6
+ <span aria-hidden="true"></span>
7
+ <span aria-hidden="true"></span>
8
+ <span aria-hidden="true"></span>
9
+ </a>
10
+ </div>
11
+
12
+ <div class="navbar-menu" id="navMenu">
13
+ <div class="navbar-start">
14
+ <div class="navbar-item">Legend:</div>
15
+ <div class="navbar-item"><span class="tag is-primary">Draft</span></div>
16
+ <div class="navbar-item"><span class="tag is-info">Queued</span></div>
17
+ <div class="navbar-item"><span class="tag is-success">Public</span></div>
18
+
19
+ <div id="publishing-menu" class="navbar-item has-dropdown is-hoverable">
20
+ <%= render 'yarii_editor/shared/publishing_menu' %>
21
+ </div>
22
+ </div>
23
+ <div class="navbar-end">
24
+ <div class="navbar-item has-dropdown is-hoverable">
25
+ <a href="javascript:void(0);" class="navbar-link">
26
+ <span style="font-weight:bold"><%= current_site.title %></span>
27
+ </a>
28
+ <div class="navbar-dropdown is-boxed is-right">
29
+ <a href="javascript:alert('To Be Implemented…')" class="navbar-item">
30
+ Site Settings
31
+ </a>
32
+ <hr class="navbar-divider" />
33
+ <%= link_to "Sign Out", main_app.signout_path, class: "navbar-item", method: :delete %>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </nav>
@@ -0,0 +1,42 @@
1
+ <a href="javascript:void(0);" class="navbar-link">
2
+ Publishing
3
+ <span class="publishing-status">
4
+ <% if current_site.repository.changes.total > 0 %>
5
+ <span class="ml-2 tag is-danger">Updates</span>
6
+ <% elsif !current_site.remote_is_up_to_date? %>
7
+ <span data-controller="building" data-building-path="<%= yarii_editor.remote_is_up_to_date_path %>" class="ml-2 tag is-warning">Building…</span>
8
+ <% end %>
9
+ </span>
10
+ </a>
11
+
12
+ <div class="navbar-dropdown is-boxed">
13
+ <% if current_site.repository.changes.total > 0 %>
14
+ <a data-controller="push-to-public" data-action="push-to-public#open" href="<%= yarii_editor.commit_publish_path %>" class="navbar-item is-size-6 has-text-weight-bold">
15
+ Push Updates to Public
16
+ </a>
17
+ <hr class="navbar-divider" />
18
+ <a href="javascript:alert('To Be Implemented…')" class="navbar-item">
19
+ Compare Changes
20
+ </a>
21
+ <% else %>
22
+ <a href="javascript:void(0)" class="navbar-item is-italic">
23
+ All Up to Date!
24
+ </a>
25
+ <% end %>
26
+ <a href="javascript:alert('To Be Implemented…')" class="navbar-item">
27
+ Push History
28
+ </a>
29
+ <hr class="navbar-divider" />
30
+ <div class="navbar-item has-text-weight-bold is-size-8">
31
+ Last Push: <%= current_site.repository.git.log.first.date.in_time_zone.strftime('%B %-d, %Y') %>
32
+ </div>
33
+ <hr class="navbar-divider" />
34
+ <a href="<%= current_site.preview_base_url %>" target="_blank" class="navbar-item">
35
+ <span>Open Preview Website</span>
36
+ <span class="icon"><i class="fa fa-external-link"></i></span>
37
+ </a>
38
+ <a href="<%= current_site.published_base_url %>" target="_blank" class="navbar-item">
39
+ <span>Open Public Website</span>
40
+ <span class="icon"><i class="fa fa-external-link"></i></span>
41
+ </a>
42
+ </div>
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.precompile += %w( yarii_editor/butterfly-small.png )
data/config/routes.rb ADDED
@@ -0,0 +1,16 @@
1
+ YariiEditor::Engine.routes.draw do
2
+ get 'documents/:content_model', to: 'documents#index', as: 'documents'
3
+ post 'documents/:content_model', to: 'documents#create', as: 'create_document'
4
+ get 'documents/:content_model/new', to: 'documents#new', as: 'new_document'
5
+ get 'documents/:content_model/:id/edit', to: 'documents#edit', as: 'edit_document'
6
+ put 'documents/:content_model/:id', to: 'documents#update', as: 'update_document'
7
+ delete 'documents/:content_model/:id', to: 'documents#destroy', as: 'destroy_document'
8
+
9
+ get 'publish/remote_is_up_to_date', to: 'publish#remote_is_up_to_date', as: 'remote_is_up_to_date'
10
+ get 'publish/menu', to: 'publish#menu', as: 'publishing_menu'
11
+ get 'publish/commit', to: 'publish#commit', as: 'commit_publish'
12
+ post 'publish/push_commit', to: 'publish#push_commit', as: 'push_commit_publish'
13
+
14
+ get 'dashboard/list', to: 'dashboard#list', as: 'dashboard_list'
15
+ root to: "dashboard#index"
16
+ end
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ module.exports = environment
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'staging'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,109 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ # use a different sub-folder name
8
+ public_output_path: yarii-editor-packs
9
+
10
+ cache_path: tmp/cache/webpacker
11
+ check_yarn_integrity: false
12
+ webpack_compile_output: false
13
+
14
+ # Additional paths webpack should lookup modules
15
+ # ['app/assets', 'engine/foo/app/assets']
16
+ resolved_paths: []
17
+
18
+ # Reload manifest.json on all requests so we reload latest compiled packs
19
+ cache_manifest: false
20
+
21
+ # Extract and emit a css file
22
+ extract_css: true
23
+
24
+ static_assets_extensions:
25
+ - .jpg
26
+ - .jpeg
27
+ - .png
28
+ - .gif
29
+ - .tiff
30
+ - .ico
31
+ - .svg
32
+ - .eot
33
+ - .otf
34
+ - .ttf
35
+ - .woff
36
+ - .woff2
37
+
38
+ extensions:
39
+ - .mjs
40
+ - .js
41
+ - .sass
42
+ - .scss
43
+ - .css
44
+ - .module.sass
45
+ - .module.scss
46
+ - .module.css
47
+ - .png
48
+ - .svg
49
+ - .gif
50
+ - .jpeg
51
+ - .jpg
52
+
53
+ development:
54
+ <<: *default
55
+ compile: true
56
+
57
+ # Verifies that versions and hashed value of the package contents in the project's package.json
58
+ check_yarn_integrity: true
59
+
60
+ # Reference: https://webpack.js.org/configuration/dev-server/
61
+ dev_server:
62
+ https: false
63
+ host: localhost
64
+ port: 3035
65
+ public: localhost:3035
66
+ hmr: false
67
+ # Inline should be set to true if using HMR
68
+ inline: true
69
+ overlay: true
70
+ compress: true
71
+ disable_host_check: true
72
+ use_local_ip: false
73
+ quiet: false
74
+ headers:
75
+ 'Access-Control-Allow-Origin': '*'
76
+ watch_options:
77
+ ignored: '**/node_modules/**'
78
+
79
+
80
+ test:
81
+ <<: *default
82
+ compile: true
83
+
84
+ # Compile test packs to a separate directory
85
+ public_output_path: packs-test
86
+
87
+ staging:
88
+ <<: *default
89
+
90
+ # Staging, like Production, depends on precompilation of packs prior to booting for performance.
91
+ compile: false
92
+
93
+ # Extract and emit a css file
94
+ extract_css: true
95
+
96
+ # Cache manifest.json for performance
97
+ cache_manifest: true
98
+
99
+ production:
100
+ <<: *default
101
+
102
+ # Production depends on precompilation of packs prior to booting for performance.
103
+ compile: false
104
+
105
+ # Extract and emit a css file
106
+ extract_css: true
107
+
108
+ # Cache manifest.json for performance
109
+ cache_manifest: true
@@ -0,0 +1,12 @@
1
+ class CreateYariiSites < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :yarii_sites do |t|
4
+ t.string :title
5
+ t.string :preview_base_url
6
+ t.string :published_base_url
7
+ t.string :content_base_path
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddGitRepoPathToYariiSites < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :yarii_sites, :git_repo_path, :string
4
+ end
5
+ end