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
|
|
|
|
embed_whitelist_selector
|
|
|
|
embed_blacklist_selector
|
2015-09-24 18:20:59 -04:00
|
|
|
embed_classname_whitelist
|
2015-08-20 13:43:12 -04:00
|
|
|
feed_polling_enabled
|
|
|
|
feed_polling_url
|
2017-05-10 14:28:16 -04:00
|
|
|
feed_polling_frequency_mins
|
2015-08-20 13:43:12 -04:00
|
|
|
embed_username_key_from_feed)
|
|
|
|
end
|
|
|
|
|
|
|
|
def base_url
|
|
|
|
Discourse.base_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
Embedding.settings.each do |s|
|
|
|
|
SiteSetting.send("#{s}=", send(s))
|
|
|
|
end
|
|
|
|
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' }
|
|
|
|
|
2017-07-27 21:20:09 -04:00
|
|
|
Embedding.settings.each { |s| embedding_args[s] = SiteSetting.send(s) }
|
2015-08-20 13:43:12 -04:00
|
|
|
Embedding.new(embedding_args)
|
|
|
|
end
|
|
|
|
end
|