Permalink
Browse files

toolbar: Fix embed for offsite subdomains like blog.

  • Loading branch information...
1 parent 49d25b7 commit ca272316e2617d26caaa32c505bf947bffd421db @andre-d andre-d committed with chromakode Jan 29, 2014
Showing with 15 additions and 4 deletions.
  1. +2 −0 r2/example.ini
  2. +1 −0 r2/r2/lib/app_globals.py
  3. +12 −4 r2/r2/lib/utils/utils.py
View
@@ -37,6 +37,8 @@ shortdomain =
domain_prefix =
# subdomains that don't need special processing
reserved_subdomains = www, ssl
+# subdomains that are not reddit instances
+offsite_subdomains =
# https api endpoint (must be g.domain or a subdomain of g.domain)
https_endpoint =
# (secure) payment domain for self-serve ads
View
@@ -206,6 +206,7 @@ class Globals(object):
'hardcache_categories',
'case_sensitive_domains',
'reserved_subdomains',
+ 'offsite_subdomains',
'TRAFFIC_LOG_HOSTS',
'exempt_login_user_agents',
'timed_templates',
View
@@ -500,10 +500,18 @@ def is_reddit_url(self, subreddit = None):
g.domain, or a subdomain of the provided subreddit's cname.
"""
from pylons import g
- return (not self.hostname or
- is_subdomain(self.hostname, g.domain) or
- (subreddit and subreddit.domain and
- is_subdomain(self.hostname, subreddit.domain)))
+ subdomain = (
+ not self.hostname or
+ is_subdomain(self.hostname, g.domain) or
+ (subreddit and subreddit.domain and
+ is_subdomain(self.hostname, subreddit.domain))
+ )
+ if not subdomain or not self.hostname or not g.offsite_subdomains:
+ return subdomain
+ return not any(
+ self.hostname.startswith(subdomain + '.')
+ for subdomain in g.offsite_subdomains
+ )
def path_add_subreddit(self, subreddit):
"""

0 comments on commit ca27231

Please sign in to comment.