mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
Adds a Site Setting to whitelist onebox domains
This commit is contained in:
parent
f8964bf453
commit
b0405d7cfa
|
@ -1682,6 +1682,7 @@ en:
|
|||
files: 'Files'
|
||||
trust: 'Trust Levels'
|
||||
security: 'Security'
|
||||
onebox: "Onebox"
|
||||
seo: 'SEO'
|
||||
spam: 'Spam'
|
||||
rate_limits: 'Rate Limits'
|
||||
|
|
|
@ -610,6 +610,7 @@ en:
|
|||
|
||||
post_excerpt_maxlength: "Maximum length in chars of a post's excerpt"
|
||||
post_onebox_maxlength: "Maximum length of a oneboxed Discourse post"
|
||||
onebox_domains_whitelist: "A list of domains to whitelist for oneboxing. (Example: eviltrout.com)"
|
||||
category_post_template: "The post template used when you create a new category"
|
||||
|
||||
logo_url: "The logo for your site eg: http://example.com/logo.png"
|
||||
|
|
|
@ -228,7 +228,6 @@ posting:
|
|||
default: -1
|
||||
hidden: true
|
||||
post_excerpt_maxlength: 300
|
||||
post_onebox_maxlength: 500
|
||||
display_name_on_posts:
|
||||
client: true
|
||||
default: false
|
||||
|
@ -336,12 +335,18 @@ trust:
|
|||
regular_requires_topic_reply_count: 3
|
||||
|
||||
security:
|
||||
enable_flash_video_onebox: false
|
||||
use_https: false
|
||||
enable_escaped_fragments: true
|
||||
allow_index_in_robots_txt: true
|
||||
enable_noscript_support: true
|
||||
|
||||
onebox:
|
||||
enable_flash_video_onebox: false
|
||||
post_onebox_maxlength: 500
|
||||
onebox_domains_whitelist:
|
||||
default: ''
|
||||
list: true
|
||||
|
||||
spam:
|
||||
add_rel_nofollow_to_user_content: true
|
||||
exclude_rel_nofollow_domains:
|
||||
|
|
|
@ -99,9 +99,23 @@ module Oneboxer
|
|||
"onebox__#{url}"
|
||||
end
|
||||
|
||||
def self.add_discourse_whitelists
|
||||
# Add custom domain whitelists
|
||||
if SiteSetting.onebox_domains_whitelist.present?
|
||||
domains = SiteSetting.onebox_domains_whitelist.split('|')
|
||||
whitelist = Onebox::Engine::WhitelistedGenericOnebox.whitelist
|
||||
whitelist.concat(domains)
|
||||
whitelist.uniq!
|
||||
end
|
||||
end
|
||||
|
||||
def self.onebox_raw(url)
|
||||
Rails.cache.fetch(onebox_cache_key(url)){
|
||||
begin
|
||||
|
||||
# This might be able to move to whenever the SiteSetting changes?
|
||||
Oneboxer.add_discourse_whitelists
|
||||
|
||||
r = Onebox.preview(url, cache: {})
|
||||
{
|
||||
onebox: r.to_s,
|
||||
|
|
Loading…
Reference in New Issue
Block a user