diff --git a/r2/r2/controllers/validator/wiki.py b/r2/r2/controllers/validator/wiki.py index a9c3cd17f..7018bb824 100644 --- a/r2/r2/controllers/validator/wiki.py +++ b/r2/r2/controllers/validator/wiki.py @@ -206,7 +206,6 @@ class VWikiPage(Validator): page = normalize_page(page) - c.wiki_page = page if (not c.is_wiki_mod) and self.modonly: return self.set_error('MOD_REQUIRED', code=403) diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 58801fea7..b7f5baacf 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -137,12 +137,13 @@ class Reddit(Templated): def __init__(self, space_compress = True, nav_menus = None, loginbox = True, infotext = '', content = None, short_description='', title = '', robots = None, show_sidebar = True, footer = True, srbar = True, page_classes = None, - show_wiki_actions = False, **context): + show_wiki_actions = False, extra_js_config = {}, **context): Templated.__init__(self, **context) self.title = title self.short_description = short_description self.robots = robots self.infotext = infotext + self.extra_js_config = extra_js_config self.show_wiki_actions = show_wiki_actions self.loginbox = True self.show_sidebar = show_sidebar diff --git a/r2/r2/lib/pages/wiki.py b/r2/r2/lib/pages/wiki.py index 856302cbb..998f7ab52 100644 --- a/r2/r2/lib/pages/wiki.py +++ b/r2/r2/lib/pages/wiki.py @@ -93,7 +93,8 @@ class WikiBase(Reddit): elif c.wikidisabled: context['infotext'] = _("this wiki is currently disabled, only mods may interact with this wiki") context['content'] = WikiBasePage(content, action, pageactions, page=page, **context) - Reddit.__init__(self, show_wiki_actions=True, **context) + Reddit.__init__(self, extra_js_config={'wiki_page': page}, + show_wiki_actions=True, **context) class WikiPageView(WikiBase): def __init__(self, content, page, diff=None, **context): diff --git a/r2/r2/lib/template_helpers.py b/r2/r2/lib/template_helpers.py index 658969f80..3ac083f07 100755 --- a/r2/r2/lib/template_helpers.py +++ b/r2/r2/lib/template_helpers.py @@ -116,7 +116,7 @@ def s3_https_if_secure(url): replace = "https://%s/" % s3_direct_url return url.replace("http://", replace) -def js_config(): +def js_config(extra_config={}): config = { # is the user logged in? "logged": c.user_is_loggedin and c.user.name, @@ -151,8 +151,7 @@ def js_config(): "static_root": static(''), } - if c.wiki_page: - config["wiki_page"] = c.wiki_page + config.update(extra_config) return config diff --git a/r2/r2/templates/base.compact b/r2/r2/templates/base.compact index 64c16524a..606faaf1f 100644 --- a/r2/r2/templates/base.compact +++ b/r2/r2/templates/base.compact @@ -45,7 +45,7 @@ ${self.robots()} ${unsafe(js.use('jquery', 'mobile'))} - ${js_setup()} + ${js_setup(thing.extra_js_config)} ${googleanalytics('mobile')} ${self.bodyHTML()} diff --git a/r2/r2/templates/base.html b/r2/r2/templates/base.html index 2a611c901..7c73a92d3 100644 --- a/r2/r2/templates/base.html +++ b/r2/r2/templates/base.html @@ -39,7 +39,7 @@ ${self.pagemeta()} ${self.stylesheet()} ${self.javascript()} - ${js_setup()} + ${js_setup(getattr(thing, "extra_js_config", None))} ##things here may depend on globals, or included js, so we run them last