mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 07:19:25 -05:00
Load jQuery from a secure source on secure domains.
This commit is contained in:
@@ -685,6 +685,7 @@ class RedditController(MinimalController):
|
||||
#can't handle broken cookies
|
||||
request.environ['HTTP_COOKIE'] = ''
|
||||
|
||||
c.secure = request.host in g.secure_domains
|
||||
c.firsttime = firsttime()
|
||||
|
||||
# the user could have been logged in via one of the feeds
|
||||
|
||||
@@ -24,6 +24,7 @@ from pylons import config
|
||||
import pytz, os, logging, sys, socket, re, subprocess, random
|
||||
import signal
|
||||
from datetime import timedelta, datetime
|
||||
from urlparse import urlparse
|
||||
from pycassa.pool import ConnectionPool as PycassaConnectionPool
|
||||
from r2.lib.cache import LocalCache, SelfEmptyingCache
|
||||
from r2.lib.cache import CMemcache, StaleCacheChain
|
||||
@@ -273,6 +274,8 @@ class Globals(object):
|
||||
|
||||
self.paths = paths
|
||||
|
||||
self.secure_domains = set([urlparse(self.payment_domain).hostname])
|
||||
|
||||
# load the md5 hashes of files under static
|
||||
static_files = os.path.join(paths.get('static_files'), 'static')
|
||||
self.static_md5 = {}
|
||||
|
||||
@@ -60,17 +60,21 @@ def static(file):
|
||||
|
||||
return os.path.join(c.site.static_path, file) + v
|
||||
|
||||
|
||||
external_resources = {
|
||||
"jquery.js": {
|
||||
True: lambda: static("jquery.js"),
|
||||
False: lambda: "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"
|
||||
}
|
||||
}
|
||||
|
||||
def external(name):
|
||||
"""
|
||||
Look up a named external URL from a static mapping. Helper for making
|
||||
frequently used URLs consistent across templates.
|
||||
"""
|
||||
|
||||
resources = {
|
||||
"jquery.js": "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js",
|
||||
}
|
||||
|
||||
return resources[name]
|
||||
return external_resources[name][c.secure]()
|
||||
|
||||
def generateurl(context, path, **kw):
|
||||
if kw:
|
||||
|
||||
Reference in New Issue
Block a user