2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-20 13:43:12 -04:00
|
|
|
require "has_errors"
|
|
|
|
|
|
|
|
class Embedding < OpenStruct
|
|
|
|
include HasErrors
|
|
|
|
|
|
|
|
def self.settings
|
|
|
|
%i[
|
|
|
|
embed_by_username
|
|
|
|
embed_post_limit
|
2016-08-22 12:43:02 -04:00
|
|
|
embed_title_scrubber
|
2015-08-20 13:43:12 -04:00
|
|
|
embed_truncate
|
2020-04-13 15:17:02 -04:00
|
|
|
embed_unlisted
|
2020-07-26 20:23:54 -04:00
|
|
|
allowed_embed_selectors
|
|
|
|
blocked_embed_selectors
|
|
|
|
allowed_embed_classnames
|
2023-01-09 07:20:10 -05:00
|
|
|
]
|
2015-08-20 13:43:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def base_url
|
|
|
|
Discourse.base_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2019-05-06 21:00:09 -04:00
|
|
|
Embedding.settings.each { |s| SiteSetting.set(s, public_send(s)) }
|
2015-08-20 13:43:12 -04:00
|
|
|
true
|
|
|
|
rescue Discourse::InvalidParameters => p
|
|
|
|
errors.add :base, p.to_s
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def embeddable_hosts
|
|
|
|
EmbeddableHost.all.order(:host)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.find
|
|
|
|
embedding_args = { id: "default" }
|
2019-05-06 21:57:27 -04:00
|
|
|
Embedding.settings.each { |s| embedding_args[s] = SiteSetting.get(s) }
|
2015-08-20 13:43:12 -04:00
|
|
|
Embedding.new(embedding_args)
|
|
|
|
end
|
|
|
|
end
|