spina-pro 0.0.1 → 0.13.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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +83 -0
  3. data/LICENSE +21 -0
  4. data/README.md +66 -0
  5. data/Rakefile +13 -0
  6. data/app/assets/config/spina/pro/manifest.js +2 -0
  7. data/app/assets/javascripts/spina/pro/controllers/form_autosave_controller.js +19 -0
  8. data/app/assets/javascripts/spina/pro/controllers/search_controller.js +64 -0
  9. data/app/assets/javascripts/spina/pro/controllers/seo_controller.js +66 -0
  10. data/app/assets/javascripts/spina/pro/libraries/debounce.js +65 -0
  11. data/app/components/spina/pro/messages/field_component.html.erb +1 -0
  12. data/app/components/spina/pro/messages/field_component.rb +36 -0
  13. data/app/components/spina/pro/messages/message_component.html.erb +31 -0
  14. data/app/components/spina/pro/messages/message_component.rb +30 -0
  15. data/app/components/spina/pro/pages/page_revision_component.html.erb +42 -0
  16. data/app/components/spina/pro/pages/page_revision_component.rb +15 -0
  17. data/app/components/spina/pro/user_interface/hint_component.html.erb +6 -0
  18. data/app/components/spina/pro/user_interface/hint_component.rb +17 -0
  19. data/app/controllers/spina/admin/pro/drafts_controller.rb +41 -0
  20. data/app/controllers/spina/admin/pro/inboxes_controller.rb +50 -0
  21. data/app/controllers/spina/admin/pro/message_archive_controller.rb +15 -0
  22. data/app/controllers/spina/admin/pro/message_spam_controller.rb +15 -0
  23. data/app/controllers/spina/admin/pro/messages_controller.rb +78 -0
  24. data/app/controllers/spina/admin/pro/not_found_errors_controller.rb +35 -0
  25. data/app/controllers/spina/admin/pro/rewrite_rules_controller.rb +53 -0
  26. data/app/controllers/spina/admin/pro/search_controller.rb +41 -0
  27. data/app/controllers/spina/admin/pro/version_history_controller.rb +18 -0
  28. data/app/mailers/spina/pro/message_mailer.rb +15 -0
  29. data/app/models/spina/parts/pro/date.rb +11 -0
  30. data/app/models/spina/parts/pro/date_time.rb +11 -0
  31. data/app/models/spina/pro/inbox.rb +31 -0
  32. data/app/models/spina/pro/message.rb +142 -0
  33. data/app/models/spina/pro/not_found_error.rb +15 -0
  34. data/app/models/spina/pro/page_revision.rb +22 -0
  35. data/app/models/spina/pro/search_document.rb +19 -0
  36. data/app/views/spina/admin/hooks/pro/_primary_navigation.html.erb +40 -0
  37. data/app/views/spina/admin/hooks/pro/_website_secondary_navigation.html.erb +1 -0
  38. data/app/views/spina/admin/pages/_button_metadata.html.erb +4 -0
  39. data/app/views/spina/admin/pages/_button_pro_seo.html.erb +5 -0
  40. data/app/views/spina/admin/pages/_form.html.erb +52 -0
  41. data/app/views/spina/admin/pages/_form_metadata.html.erb +10 -0
  42. data/app/views/spina/admin/pages/_form_page_content.html.erb +15 -0
  43. data/app/views/spina/admin/pages/_form_pro_seo.html.erb +64 -0
  44. data/app/views/spina/admin/parts/pro/date_times/_form.html.erb +6 -0
  45. data/app/views/spina/admin/parts/pro/dates/_form.html.erb +6 -0
  46. data/app/views/spina/admin/pro/drafts/index.html.erb +52 -0
  47. data/app/views/spina/admin/pro/inboxes/_unread_count.html.erb +5 -0
  48. data/app/views/spina/admin/pro/inboxes/_unread_indicator.html.erb +3 -0
  49. data/app/views/spina/admin/pro/inboxes/edit.html.erb +21 -0
  50. data/app/views/spina/admin/pro/inboxes/show.html.erb +50 -0
  51. data/app/views/spina/admin/pro/message_archive/show.html.erb +34 -0
  52. data/app/views/spina/admin/pro/message_spam/show.html.erb +34 -0
  53. data/app/views/spina/admin/pro/messages/_message.html.erb +3 -0
  54. data/app/views/spina/admin/pro/messages/_modal.html.erb +83 -0
  55. data/app/views/spina/admin/pro/messages/edit.html.erb +26 -0
  56. data/app/views/spina/admin/pro/messages/fields/_boolean.html.erb +1 -0
  57. data/app/views/spina/admin/pro/messages/fields/_string.html.erb +1 -0
  58. data/app/views/spina/admin/pro/messages/fields/_text.html.erb +1 -0
  59. data/app/views/spina/admin/pro/messages/show.html.erb +1 -0
  60. data/app/views/spina/admin/pro/messages/update.turbo_stream.erb +2 -0
  61. data/app/views/spina/admin/pro/not_found_errors/_not_found_error.html.erb +36 -0
  62. data/app/views/spina/admin/pro/not_found_errors/ignored.html.erb +10 -0
  63. data/app/views/spina/admin/pro/not_found_errors/index.html.erb +25 -0
  64. data/app/views/spina/admin/pro/rewrite_rules/_form.html.erb +31 -0
  65. data/app/views/spina/admin/pro/rewrite_rules/_rewrite_rule.html.erb +17 -0
  66. data/app/views/spina/admin/pro/rewrite_rules/index.html.erb +31 -0
  67. data/app/views/spina/admin/pro/rewrite_rules/new.html.erb +3 -0
  68. data/app/views/spina/admin/pro/search/_results.html.erb +9 -0
  69. data/app/views/spina/admin/pro/search/new.html.erb +40 -0
  70. data/app/views/spina/admin/pro/search/results/_page.html.erb +25 -0
  71. data/app/views/spina/admin/pro/shared/_redirects_navigation.html.erb +30 -0
  72. data/app/views/spina/admin/pro/version_history/show.html.erb +34 -0
  73. data/app/views/spina/pro/message_mailer/forward.html.erb +70 -0
  74. data/app/views/spina/pro/message_mailer/forward.text.erb +14 -0
  75. data/config/locales/en.yml +96 -0
  76. data/config/locales/nl.yml +96 -0
  77. data/config/routes.rb +44 -0
  78. data/db/migrate/1_create_spina_pro_not_found_errors.rb +14 -0
  79. data/db/migrate/2_add_created_manually_to_spina_rewrite_rules.rb +5 -0
  80. data/db/migrate/3_create_spina_pro_inboxes.rb +11 -0
  81. data/db/migrate/4_create_spina_pro_messages.rb +14 -0
  82. data/db/migrate/5_add_archived_at_to_spina_pro_messages.rb +5 -0
  83. data/db/migrate/6_create_spina_pro_search_documents.rb +9 -0
  84. data/db/migrate/7_create_spina_pro_page_revisions.rb +12 -0
  85. data/db/migrate/8_add_draft_to_spina_pro_page_revisions.rb +5 -0
  86. data/lib/generators/spina/pro/install_generator.rb +13 -0
  87. data/lib/generators/spina/pro/message_generator.rb +14 -0
  88. data/lib/generators/spina/pro/templates/initializer.rb.tt +6 -0
  89. data/lib/generators/spina/pro/templates/message.rb.tt +5 -0
  90. data/lib/spina/pro/engine.rb +57 -0
  91. data/lib/spina/pro/inboxes_helper.rb +17 -0
  92. data/lib/spina/pro/order_by_date.rb +16 -0
  93. data/lib/spina/pro/page_ordering.rb +34 -0
  94. data/lib/spina/pro/page_revisions/load_page_revision.rb +20 -0
  95. data/lib/spina/pro/page_revisions/page_decorator.rb +40 -0
  96. data/lib/spina/pro/page_revisions/pages_controller_decorator.rb +52 -0
  97. data/lib/spina/pro/page_search.rb +20 -0
  98. data/lib/spina/pro/recently_visited.rb +33 -0
  99. data/lib/spina/pro/replace_seo_tab.rb +18 -0
  100. data/lib/spina/pro/search.rb +45 -0
  101. data/lib/spina/pro/track_not_found_errors.rb +23 -0
  102. data/lib/spina/pro/version.rb +5 -0
  103. data/lib/spina/pro.rb +38 -0
  104. metadata +122 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61fa276bfbebd315c4bef407d3cda74e65ea2159abe4e04723f47291a87d638a
4
- data.tar.gz: c501cf42893c32e9155eff0b34bf20e3dab59ab5957bf72ea3c6f6e803660d72
3
+ metadata.gz: a249b2ddca255ef865e689250559290c21a163026a4e49a88e415eba2e69756a
4
+ data.tar.gz: ac4e83d34b35e85a1e0e16fcdf5fe9ae8aceb1758eb00eb6f1e0255880db0c65
5
5
  SHA512:
6
- metadata.gz: 2268494194bb7795a239675e7d2e764ada496f5f7e82eab8d2fe6088883414c9c04093528692fb2257f4a7bdd96f8a00b9b3b9f8e067142675bee6e3a01af541
7
- data.tar.gz: a43e99f11ad22e446492c2419842c5b0752b157f980d762cbfec49b5483e6083d1bb21f4fa597bb3d8a575423e7f231407ccbcddb376c6e449a147d514f98b74
6
+ metadata.gz: 429cbac4b67fbafe242fa4b374eca60f92608ad82fa2f387634ad044f66e6b818b40b6bed954c8e6047b3f8e27ecfb71aa7909cc117e915257e16140b367713e
7
+ data.tar.gz: 879f75bacd355cb8dba4d0352b700330f80963a7388d04e6088b480f310dfab2376879ecac4109df6cb232e475fb013da4ec4223330adcc24a59e2577f6f782b
data/CHANGELOG.md ADDED
@@ -0,0 +1,83 @@
1
+ # Changelog
2
+
3
+ ## 0.12
4
+
5
+ ### 0.12.0
6
+ - Added UI for spam messages
7
+
8
+ ## 0.11
9
+
10
+ ### 0.11.0
11
+ - Added Dutch translations
12
+ - Added config.track_not_found_errors (default: true)
13
+
14
+ ## 0.10
15
+
16
+ ### 0.10.3
17
+ - Added Dutch translations
18
+
19
+ ### 0.10.2
20
+ - Fixed licensing bug
21
+
22
+ ### 0.10.1
23
+ - Fixed UI bug when deleting drafts
24
+ - Temporarily disabled phoning home to spinacms.com (because of Apple and Heroku downtime)
25
+
26
+ ### 0.10.0
27
+ - Updated ViewComponents Slots API to v3
28
+ - Spina Pro now requires Spina >= v2.15.0
29
+
30
+ ## 0.9
31
+
32
+ ### 0.9.3
33
+ - Fixed bug when creating new drafts
34
+
35
+ ### 0.9.2
36
+ - Skip saving a revision if nothing changed
37
+ - Use update instead of destroy/insert on search documents
38
+
39
+ ### 0.9.1
40
+ - Add the `inbox` class method to messages
41
+
42
+ ### 0.9.0
43
+ - Added support for version history
44
+ - Refactored UI for drafts
45
+
46
+ ## 0.8
47
+
48
+ ### 0.8.1
49
+ - Fixed bug for page revisions without AttrJson::NestedAttributes
50
+
51
+ ### 0.8.0
52
+ - Added support for page revisions (multiple drafts)
53
+
54
+ ## 0.7
55
+
56
+ ### 0.7.1
57
+ - Rename search methods to prevent naming collision
58
+
59
+ ### 0.7.0
60
+ - Added support for Spina::Parts::Pro::Date/Datetime fields
61
+ - Added support for ordering pages based on Date/Datetime fields
62
+
63
+ ## 0.6
64
+
65
+ ### 0.6.0
66
+ - Multi-model support in global search
67
+ - UI bugfixes
68
+ - Added pagination to Rewrite Rules
69
+
70
+ ## 0.5
71
+
72
+ ### 0.5.0
73
+ - Updated inbox view template
74
+ - Fixed bug with Tailwind content
75
+ - Fixed UI bug with page search
76
+
77
+ ## 0.4
78
+
79
+ ### 0.4.1
80
+ - Fixed bug with expires_at DateTime parsing
81
+
82
+ ### 0.4.0
83
+ - Licensing validation
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2026 Bram Jetten
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,66 @@
1
+ # Spina::Pro
2
+
3
+ Spina Pro is a Rails engine that adds a collection of extra features to a
4
+ [Spina CMS](https://www.spinacms.com) project. It was previously distributed as
5
+ a commercial add-on and is now open source under the MIT license.
6
+
7
+ ## Features
8
+
9
+ - **Global search** — full-text search across pages and other models, powered by
10
+ `pg_search`.
11
+ - **Page revisions & drafts** — keep a version history of pages and work on
12
+ multiple drafts before publishing.
13
+ - **Messages & inboxes** — store and manage form submissions (e.g. contact
14
+ forms) in the admin, with forwarding, archiving and spam/ham handling.
15
+ - **Rewrite rules** — manage redirects, including auto-generated suggestions.
16
+ - **404 tracking** — track and review not-found errors so you can fix broken
17
+ links.
18
+ - **Date & DateTime parts** — extra page parts (`Spina::Parts::Pro::Date` and
19
+ `Spina::Parts::Pro::DateTime`) and ordering pages by date.
20
+ - **UI niceties** — recently visited pages, hints, and an enhanced SEO tab.
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem "spina-pro"
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ ```bash
33
+ $ bundle install
34
+ ```
35
+
36
+ Run the migrations from the engine:
37
+
38
+ ```bash
39
+ $ bin/rails spina_pro:install:migrations
40
+ $ bin/rails db:migrate
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ Spina Pro can be configured in an initializer:
46
+
47
+ ```ruby
48
+ # config/initializers/spina_pro.rb
49
+ Spina::Pro.disable_hints = false
50
+ Spina::Pro.hide_inboxes = false
51
+ Spina::Pro.postgresql_dictionary = "english"
52
+ Spina::Pro.track_not_found_errors = true
53
+ ```
54
+
55
+ Spina Pro requires Spina `>= 2.15.0` and a PostgreSQL database (the search and
56
+ several other features rely on PostgreSQL-specific functionality).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome. This project is released under the
61
+ MIT license, so feel free to use it, fork it and build on top of it.
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the
66
+ [MIT License](LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rake/testtask"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'test'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.verbose = false
11
+ end
12
+
13
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../../../javascripts/spina/pro/controllers
2
+ //= link_directory ../../../javascripts/spina/pro/libraries
@@ -0,0 +1,19 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import debounce from "libraries/debounce"
3
+ import formRequestSubmitPolyfill from "libraries/form-request-submit-polyfill"
4
+
5
+ export default class extends Controller {
6
+
7
+ submitForm = debounce(function() {
8
+ this.element.requestSubmit()
9
+ }.bind(this), this.debounceTime)
10
+
11
+ save() {
12
+ this.submitForm()
13
+ }
14
+
15
+ get debounceTime() {
16
+ return this.element.dataset.debounceTime || 200
17
+ }
18
+
19
+ }
@@ -0,0 +1,64 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static get targets() {
5
+ return ['result']
6
+ }
7
+
8
+ preventEnter(event) {
9
+ if (event.key === "Enter") event.preventDefault()
10
+ }
11
+
12
+ navigate(event) {
13
+ switch(event.key) {
14
+ case "Enter":
15
+ this.selected.click()
16
+ break
17
+ case "ArrowUp":
18
+ this.selectPrevious()
19
+ break
20
+ case "ArrowDown":
21
+ this.selectNext()
22
+ break
23
+ default:
24
+ }
25
+ }
26
+
27
+ selectPrevious() {
28
+ if (!this.selected) return
29
+ let previous = this.selected.previousElementSibling
30
+ if (previous) this.selectResult(previous)
31
+ }
32
+
33
+ selectNext() {
34
+ if (!this.selected) return
35
+ let next = this.selected.nextElementSibling
36
+ if (next) this.selectResult(next)
37
+ }
38
+
39
+ select(event) {
40
+ this.selectResult(event.currentTarget)
41
+ }
42
+
43
+ selectResult(resultElement) {
44
+ this.deselectAll()
45
+ resultElement.querySelectorAll("[data-selected-class]").forEach(function(el) {
46
+ el.classList.add(el.dataset.selectedClass)
47
+ })
48
+ resultElement.dataset.selected = true
49
+ }
50
+
51
+ deselectAll() {
52
+ this.resultTargets.forEach(function(result) {
53
+ result.querySelectorAll("[data-selected-class]").forEach(function(el) {
54
+ el.classList.remove(el.dataset.selectedClass)
55
+ })
56
+ result.removeAttribute('data-selected')
57
+ })
58
+ }
59
+
60
+ get selected() {
61
+ return this.resultTargets.find(result => result.hasAttribute('data-selected'))
62
+ }
63
+
64
+ }
@@ -0,0 +1,66 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static get targets() {
5
+ return [ "title", "titleInput", "description", "descriptionInput", "widthCalculator", "widthResult" ]
6
+ }
7
+
8
+ connect() {
9
+ this.renderTitle()
10
+ this.renderDescription()
11
+ }
12
+
13
+ renderTitle() {
14
+ if (this.titleInputTarget.value != "") {
15
+ this.titleTarget.innerText = this.titleInputTarget.value
16
+ } else {
17
+ this.titleTarget.innerText = this.fallbackTitle
18
+ }
19
+ }
20
+
21
+ renderDescription() {
22
+ if (this.descriptionInputTarget.value != "") {
23
+ this.descriptionTarget.innerText = this.descriptionInputTarget.value
24
+ } else {
25
+ this.descriptionTarget.innerText = this.fallbackDescription
26
+ }
27
+
28
+ this.calculateWidth()
29
+ }
30
+
31
+ calculateWidth() {
32
+ this.widthCalculatorTarget.innerText = this.descriptionInputTarget.value
33
+ this.descriptionTarget.classList.remove('text-red-600', 'text-yellow-600', 'text-gray-700')
34
+
35
+ if (this.descriptionWidth > this.descriptionDesktopMaximum) {
36
+ this.descriptionTarget.classList.add('text-red-600')
37
+ } else if (this.descriptionWidth > this.descriptionMobileMaximum) {
38
+ this.descriptionTarget.classList.add('text-yellow-600')
39
+ } else {
40
+ this.descriptionTarget.classList.add('text-gray-700')
41
+ }
42
+ }
43
+
44
+ get fallbackTitle() {
45
+ return this.titleTarget.dataset.fallbackTitle
46
+ }
47
+
48
+ get fallbackDescription() {
49
+ return this.descriptionTarget.dataset.fallbackDescription
50
+ }
51
+
52
+ get descriptionWidth() {
53
+ return this.widthCalculatorTarget.offsetWidth
54
+ }
55
+
56
+ // Max width for desktop
57
+ get descriptionDesktopMaximum() {
58
+ return 920
59
+ }
60
+
61
+ // Max width for mobile
62
+ get descriptionMobileMaximum() {
63
+ return 680
64
+ }
65
+
66
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Returns a function, that, as long as it continues to be invoked, will not
3
+ * be triggered. The function will be called after it stops being called for
4
+ * N milliseconds. If `immediate` is passed, trigger the function on the
5
+ * leading edge, instead of the trailing. The function also has a property 'clear'
6
+ * that is a function which will clear the timer to prevent previously scheduled executions.
7
+ *
8
+ * @source underscore.js
9
+ * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
10
+ * @param {Function} function to wrap
11
+ * @param {Number} timeout in ms (`100`)
12
+ * @param {Boolean} whether to execute at the beginning (`false`)
13
+ * @api public
14
+ */
15
+ export default function debounce(func, wait, immediate){
16
+ var timeout, args, context, timestamp, result;
17
+ if (null == wait) wait = 100;
18
+
19
+ function later() {
20
+ var last = Date.now() - timestamp;
21
+
22
+ if (last < wait && last >= 0) {
23
+ timeout = setTimeout(later, wait - last);
24
+ } else {
25
+ timeout = null;
26
+ if (!immediate) {
27
+ result = func.apply(context, args);
28
+ context = args = null;
29
+ }
30
+ }
31
+ };
32
+
33
+ var debounced = function(){
34
+ context = this;
35
+ args = arguments;
36
+ timestamp = Date.now();
37
+ var callNow = immediate && !timeout;
38
+ if (!timeout) timeout = setTimeout(later, wait);
39
+ if (callNow) {
40
+ result = func.apply(context, args);
41
+ context = args = null;
42
+ }
43
+
44
+ return result;
45
+ };
46
+
47
+ debounced.clear = function() {
48
+ if (timeout) {
49
+ clearTimeout(timeout);
50
+ timeout = null;
51
+ }
52
+ };
53
+
54
+ debounced.flush = function() {
55
+ if (timeout) {
56
+ result = func.apply(context, args);
57
+ context = args = null;
58
+
59
+ clearTimeout(timeout);
60
+ timeout = null;
61
+ }
62
+ };
63
+
64
+ return debounced;
65
+ };
@@ -0,0 +1 @@
1
+ <%= render partial: form_partial_path, locals: {f: form_builder, attribute: attribute} %>
@@ -0,0 +1,36 @@
1
+ module Spina
2
+ module Pro
3
+ module Messages
4
+ class FieldComponent < ApplicationComponent
5
+ attr_reader :form_builder, :attribute
6
+
7
+ def initialize(form_builder, attribute)
8
+ @form_builder, @attribute = form_builder, attribute
9
+ end
10
+
11
+ def form_partial_path
12
+ "spina/admin/pro/messages/fields/#{partial}"
13
+ end
14
+
15
+ private
16
+
17
+ def partial
18
+ partial_exists? ? field_type : default_field_type
19
+ end
20
+
21
+ def partial_exists?
22
+ helpers.lookup_context.template_exists?(field_type, "spina/admin/pro/messages/fields", true)
23
+ end
24
+
25
+ def default_field_type
26
+ :string
27
+ end
28
+
29
+ def field_type
30
+ form_builder.object.field_type(attribute)
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,31 @@
1
+ <%= link_to helpers.spina.admin_pro_inbox_message_path(message.inbox, message), class: button_classes, data: {turbo_frame: "modal"} do %>
2
+ <div class="flex items-center flex-1 relative">
3
+ <%= image_tag message.gravatar_url, alt: 'Image', class: image_classes %>
4
+
5
+ <% if unread? %>
6
+ <div class="absolute w-3 h-3 bg-red-500 rounded-full -top-0.5 -left-0.5"></div>
7
+ <% end %>
8
+
9
+ <div class="text-sm flex items-center flex-1">
10
+ <div class="flex-1">
11
+ <div class="block uppercase text-xs font-semibold tracking-wide text-gray-400">
12
+ <%= message.class.human_attribute_name(:name) %>
13
+ </div>
14
+ <%= message.to_name %>
15
+ </div>
16
+
17
+ <% message.index_attributes.each do |attribute| %>
18
+ <div class="flex-1">
19
+ <div class="block uppercase text-xs font-semibold tracking-wide text-gray-400">
20
+ <%= message.class.human_attribute_name(attribute) %>
21
+ </div>
22
+ <%= message.send(attribute).presence || "–" %>
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+ </div>
27
+
28
+ <div class="text-gray-400 font-normal w-36 text-xs text-right">
29
+ <%=l message.created_at, format: :long %>
30
+ </div>
31
+ <% end %>
@@ -0,0 +1,30 @@
1
+ module Spina
2
+ module Pro
3
+ module Messages
4
+ class MessageComponent < ApplicationComponent
5
+ attr_reader :message
6
+
7
+ def initialize(message)
8
+ @message = message
9
+ end
10
+
11
+ def unread?
12
+ message.unread?
13
+ end
14
+
15
+ def image_classes
16
+ "rounded-lg w-10 h-10 mr-3"
17
+ end
18
+
19
+ def button_classes
20
+ if unread?
21
+ "border-b border-gray-200 flex items-center justify-between space-x-6 px-2 pr-4 py-2 bg-white hover:bg-gray-100 w-full text-left font-semibold shadow-sm relative"
22
+ else
23
+ "border-b border-gray-200 flex items-center justify-between space-x-6 px-2 pr-4 py-2 bg-gray-50 hover:bg-gray-100 w-full text-left font-normal"
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ <div class="ml-2">
2
+ <%= render Spina::UserInterface::DropdownComponent.new do |dropdown| %>
3
+ <% dropdown.with_button(classes: "btn btn-default h-6 px-1.5") do %>
4
+ <% if page_revision&.draft? || page.draft? %>
5
+ <div class="text-xs text-gray-500 uppercase font-semibold">
6
+ <%= Spina::Page.human_attribute_name(:draft) %>
7
+ </div>
8
+ <% elsif page_revision.present? %>
9
+ <div class="text-xs text-gray-500 uppercase font-semibold">
10
+ <%=l page_revision.updated_at, format: :short %>
11
+ </div>
12
+ <% else %>
13
+ <div class="text-xs text-emerald-500 uppercase font-semibold">
14
+ <%=t "spina.pro.page_revisions.live" %>
15
+ </div>
16
+ <% end %>
17
+
18
+ <%= helpers.heroicon("chevron-down", style: :mini, class: "w-3 h-3 ml-1") %>
19
+ <% end %>
20
+
21
+ <% dropdown.with_menu do %>
22
+ <div class="relative overflow-scroll" style="max-height: 220px" data-controller="infinite-scroll" data-infinite-scroll-target="container">
23
+ <%= helpers.turbo_frame_tag "version_history", src: helpers.spina.admin_pro_page_version_history_path(page, page_revision_id: page_revision&.id) %>
24
+ </div>
25
+
26
+ <div class="px-2 py-1">
27
+ <% if @page.drafts.any? %>
28
+ <%= link_to helpers.spina.admin_pro_page_drafts_path(page, editing_id: page_revision&.id), class: 'btn btn-default h-7 text-xs', data: {turbo_frame: "modal"} do %>
29
+ <%=t "spina.pro.page_revisions.drafts" %> (<%= @page.drafts.count %>)
30
+ <% end %>
31
+ <% else %>
32
+ <%= form_with url: helpers.spina.admin_pro_page_drafts_path(@page), data: {turbo_frame: "_top"} do |f| %>
33
+ <%= button_tag type: :submit, class: "btn btn-default h-8 text-xs w-full" do %>
34
+ <%= helpers.heroicon('plus', style: :mini, class: 'w-4 h-4 mr-1') %>
35
+ <%=t "spina.pro.page_revisions.create_new_draft" %>
36
+ <% end %>
37
+ <% end %>
38
+ <% end %>
39
+ </div>
40
+ <% end %>
41
+ <% end %>
42
+ </div>
@@ -0,0 +1,15 @@
1
+ module Spina
2
+ module Pro
3
+ module Pages
4
+ class PageRevisionComponent < ApplicationComponent
5
+ attr_reader :page, :page_revision
6
+
7
+ def initialize(page, page_revision = nil)
8
+ @page = page
9
+ @page_revision = page_revision
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ <div class="px-8 py-4 text-sm font-medium leading-normal bg-blue-100 border-b border-blue-200 text-blue-400 flex items-center">
2
+ <%= helpers.heroicon('information-circle', style: :solid, class: 'w-7 h-7 mr-3') %>
3
+ <div class="max-w-xl">
4
+ <%= sanitize @hint %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,17 @@
1
+ module Spina
2
+ module Pro
3
+ module UserInterface
4
+ class HintComponent < ApplicationComponent
5
+
6
+ def initialize(hint = "")
7
+ @hint = hint
8
+ end
9
+
10
+ def render?
11
+ !Spina::Pro.config.disable_hints
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ module Spina
2
+ module Admin
3
+ module Pro
4
+ class DraftsController < AdminController
5
+ before_action :set_page
6
+
7
+ def index
8
+ @drafts = @page.drafts
9
+ end
10
+
11
+ def create
12
+ revision = @page.create_draft!(updated_by: current_spina_user.name)
13
+ redirect_to spina.edit_admin_page_path(@page, revision: revision.id)
14
+ end
15
+
16
+ def update
17
+ @draft = @page.drafts.find(params[:id])
18
+ @draft.update(page_revision_params)
19
+ head :ok
20
+ end
21
+
22
+ def destroy
23
+ @draft = @page.drafts.find(params[:id])
24
+ @draft.destroy
25
+ render turbo_stream: turbo_stream.remove(view_context.dom_id(@draft))
26
+ end
27
+
28
+ private
29
+
30
+ def page_revision_params
31
+ params.require(:page_revision).permit(:note)
32
+ end
33
+
34
+ def set_page
35
+ @page = Spina::Page.find(params[:page_id])
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end