mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00: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'
|
files: 'Files'
|
||||||
trust: 'Trust Levels'
|
trust: 'Trust Levels'
|
||||||
security: 'Security'
|
security: 'Security'
|
||||||
|
onebox: "Onebox"
|
||||||
seo: 'SEO'
|
seo: 'SEO'
|
||||||
spam: 'Spam'
|
spam: 'Spam'
|
||||||
rate_limits: 'Rate Limits'
|
rate_limits: 'Rate Limits'
|
||||||
|
@ -610,6 +610,7 @@ en:
|
|||||||
|
|
||||||
post_excerpt_maxlength: "Maximum length in chars of a post's excerpt"
|
post_excerpt_maxlength: "Maximum length in chars of a post's excerpt"
|
||||||
post_onebox_maxlength: "Maximum length of a oneboxed Discourse post"
|
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"
|
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"
|
logo_url: "The logo for your site eg: http://example.com/logo.png"
|
||||||
|
@ -228,7 +228,6 @@ posting:
|
|||||||
default: -1
|
default: -1
|
||||||
hidden: true
|
hidden: true
|
||||||
post_excerpt_maxlength: 300
|
post_excerpt_maxlength: 300
|
||||||
post_onebox_maxlength: 500
|
|
||||||
display_name_on_posts:
|
display_name_on_posts:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
@ -336,12 +335,18 @@ trust:
|
|||||||
regular_requires_topic_reply_count: 3
|
regular_requires_topic_reply_count: 3
|
||||||
|
|
||||||
security:
|
security:
|
||||||
enable_flash_video_onebox: false
|
|
||||||
use_https: false
|
use_https: false
|
||||||
enable_escaped_fragments: true
|
enable_escaped_fragments: true
|
||||||
allow_index_in_robots_txt: true
|
allow_index_in_robots_txt: true
|
||||||
enable_noscript_support: true
|
enable_noscript_support: true
|
||||||
|
|
||||||
|
onebox:
|
||||||
|
enable_flash_video_onebox: false
|
||||||
|
post_onebox_maxlength: 500
|
||||||
|
onebox_domains_whitelist:
|
||||||
|
default: ''
|
||||||
|
list: true
|
||||||
|
|
||||||
spam:
|
spam:
|
||||||
add_rel_nofollow_to_user_content: true
|
add_rel_nofollow_to_user_content: true
|
||||||
exclude_rel_nofollow_domains:
|
exclude_rel_nofollow_domains:
|
||||||
|
@ -99,9 +99,23 @@ module Oneboxer
|
|||||||
"onebox__#{url}"
|
"onebox__#{url}"
|
||||||
end
|
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)
|
def self.onebox_raw(url)
|
||||||
Rails.cache.fetch(onebox_cache_key(url)){
|
Rails.cache.fetch(onebox_cache_key(url)){
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
# This might be able to move to whenever the SiteSetting changes?
|
||||||
|
Oneboxer.add_discourse_whitelists
|
||||||
|
|
||||||
r = Onebox.preview(url, cache: {})
|
r = Onebox.preview(url, cache: {})
|
||||||
{
|
{
|
||||||
onebox: r.to_s,
|
onebox: r.to_s,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user