5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-05 20:15:46 +00:00

Merge branch 'usar-sutty-editor' into panel.sutty.nl
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
f 2023-03-31 17:23:50 -03:00
commit 504bbfd357
4 changed files with 26 additions and 5 deletions

View file

@ -21,11 +21,26 @@ module ActiveStorage
def update
if (token = decode_verified_token)
if acceptable_content?(token)
named_disk_service(token[:service_name]).upload token[:key], request.body, checksum: token[:checksum]
blob = ActiveStorage::Blob.find_by_key token[:key]
site = Site.find_by_name token[:service_name]
if remote_file?(token)
begin
url = request.body.read
body = Down.download(url, max_size: 111.megabytes)
checksum = nil
rescue StandardError => e
ExceptionNotifier.notify_exception(e, data: { key: token[:key], url: url, site: site.name })
head :content_too_large
end
else
body = request.body
checksum = token[:checksum]
end
named_disk_service(token[:service_name]).upload token[:key], body, checksum: checksum
site.static_files.attach(blob)
else
head :unprocessable_entity
@ -36,6 +51,12 @@ module ActiveStorage
rescue ActiveStorage::IntegrityError
head :unprocessable_entity
end
private
def remote_file?(token)
token[:content_type] == 'sutty/download-from-url'
end
end
end
end

View file

@ -207,7 +207,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
def allowed_tags
@allowed_tags ||= %w[strong em del u mark p h1 h2 h3 h4 h5 h6 ul ol li img iframe audio video div figure blockquote
figcaption a sub sup small table thead tbody tfoot tr th td br code].freeze
figcaption a sub sup small table thead tbody tfoot tr th td br code start type reversed].freeze
end
# Decifra el valor

View file

@ -127,4 +127,4 @@
%p= t('editor.word')
.editor-content.form-control.h-auto.mt-1{ contenteditable: 'true' }
= metadata.value.html_safe
= metadata.to_s.html_safe

View file

@ -13,7 +13,7 @@
"@rails/activestorage": "^6.1.3-1",
"@rails/ujs": "^6.1.3-1",
"@rails/webpacker": "5.2.1",
"@suttyweb/editor": "^0.1.14",
"@suttyweb/editor": "^0.1.15",
"babel-loader": "^8.2.2",
"chart.js": "^3.5.1",
"chartkick": "^4.0.5",