diff --git a/Gemfile b/Gemfile index 76dcf69bcef307160f8f1a1600ece4ce9babed9f..74724d81ff851468e91c730c631979d9b8906fca 100644 --- a/Gemfile +++ b/Gemfile @@ -47,7 +47,7 @@ gem 'simple-navigation' gem 'simple_form' gem 'simple_form_bs5_file_input'#, path: '../simple_form_bs5_file_input' gem 'simple_form_password_with_hints'#, path: '../simple_form_password_with_hints' -gem 'summernote-rails', git: 'https://github.com/noesya/summernote-rails.git', branch: 'feature/cleaner' +gem 'summernote-rails', git: 'https://github.com/noesya/summernote-rails.git', branch: 'activestorage' # gem 'summernote-rails', path: '../summernote-rails' gem 'two_factor_authentication', git: 'https://github.com/noesya/two_factor_authentication.git' # gem 'two_factor_authentication', path: '../two_factor_authentication' diff --git a/Gemfile.lock b/Gemfile.lock index 6debe6da20632a4c629cfa01452bc52592888880..59cf54d68f48805440504d79c58b3c32c7f5d912 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ GIT remote: https://github.com/noesya/summernote-rails.git - revision: da6e54c1e45c09dbeef2382d50f390aba968bd63 - branch: feature/cleaner + revision: ed2ee76977c5362707a1da7d8d30ab5d3efdcbab + branch: activestorage specs: summernote-rails (0.8.20.1) - railties (>= 3.1) + rails (>= 6.0) GIT remote: https://github.com/noesya/two_factor_authentication.git diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 80befcf48dc7a06a6679a24199cdf8cfd11c6c2b..43e04d1b6d9290f7cb778462f5841c181a75b45a 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -10,6 +10,7 @@ //= require gdpr/cookie_consent //= require sortablejs/Sortable //= require summernote/summernote-lite +//= require summernote-rails //= require slug/slug //= require cocoon //= require_self diff --git a/app/models/communication/website/imported/page.rb b/app/models/communication/website/imported/page.rb index 18420493d442c459c29460b24a6b35195b094e8d..f4dbdce8b81fd6e8eaea69c81cbe758c6badc6f7 100644 --- a/app/models/communication/website/imported/page.rb +++ b/app/models/communication/website/imported/page.rb @@ -122,6 +122,6 @@ class Communication::Website::Imported::Page < ApplicationRecord end end end - page.update(text: rich_text_with_attachments(page.text)) + page.update(text: rich_text_with_attachments(page.text.to_s)) end end diff --git a/app/models/communication/website/imported/post.rb b/app/models/communication/website/imported/post.rb index 0c77bc954ea42d38ec2479fc0293e80ee1f7cceb..8e2bcaec9fdd9d675bc39f557c55f873ce59a9c2 100644 --- a/app/models/communication/website/imported/post.rb +++ b/app/models/communication/website/imported/post.rb @@ -122,7 +122,7 @@ class Communication::Website::Imported::Post < ApplicationRecord content_type: featured_medium.file.blob.content_type ) else - fragment = Nokogiri::HTML.fragment(post.text) + fragment = Nokogiri::HTML.fragment(post.text.body.to_html) image = fragment.css('img').first if image.present? begin @@ -135,6 +135,6 @@ class Communication::Website::Imported::Post < ApplicationRecord end end end - post.update(text: rich_text_with_attachments(post.text)) + post.update(text: rich_text_with_attachments(post.text.body.to_html)) end end diff --git a/app/services/osuny/sanitizer.rb b/app/services/osuny/sanitizer.rb index bb3484bf258bb311cea4dd5f9539f42200856559..ede92d17125ac5eb9b3365f935a1a1f0c57ac37f 100644 --- a/app/services/osuny/sanitizer.rb +++ b/app/services/osuny/sanitizer.rb @@ -9,8 +9,12 @@ class Osuny::Sanitizer private + # input can be String or ActionText::Content def self.sanitize_text(input) - safe_list_sanitizer.sanitize(input) + input.is_a?(String) ? safe_list_sanitizer.sanitize(input) + : ActionText::Content.new( + safe_list_sanitizer.sanitize(input.to_html) + ) end def self.sanitize_string(string) diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb index d32d113d373408172e0e452249241c17a5b218e0..00d096e51246a0b8869a5c9227360a2c4327b5e4 100644 --- a/app/views/admin/communication/websites/pages/_form.html.erb +++ b/app/views/admin/communication/websites/pages/_form.html.erb @@ -13,7 +13,7 @@ <%= f.input :breadcrumb_title %> <%= f.input :description_short, input_html: { value: page.description_short&.gsub('&', '&') } %> <%= f.input :header_text, as: :string %> - <%= f.input :text, as: :summernote if page.text&.present? %> + <%= f.input :text, as: :summernote if page.text&.to_plain_text.present? %> </div> </div> <div class="card"> diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index b86553e58735c655d2d2fcc96f28ba70a71965fa..0b5b5f084162a58ca88921b755da1300e6850d8d 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -20,7 +20,7 @@ </div> <div class="card-body"> <%= render 'admin/application/property/text', object: @page, property: :description_short %> - <%= render 'admin/application/property/text', object: @page, property: :text if @page.text&.present? %> + <%= render 'admin/application/property/text', object: @page, property: :text if @page.text&.to_plain_text.present? %> </div> </div> <%= render 'admin/communication/blocks/list', about: @page %> diff --git a/db/schema.rb b/db/schema.rb index eaaa424e178e80a70dbee61b7e0e1237a1d21d6c..c610b826c5264de7942abc49c59bd96df5ce1118 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -302,10 +302,10 @@ ActiveRecord::Schema.define(version: 2022_05_23_172753) do t.text "github_path" t.string "featured_image_alt" t.text "text" - t.text "description_short" t.string "breadcrumb_title" t.text "header_text" t.integer "kind" + t.text "description_short" t.string "bodyclass" t.uuid "language_id" t.text "featured_image_credit"