Add r.config.cur_site to js_config

Define `r.config.cur_site` in `js_config()` and remove from the
reddit.html template.
This commit is contained in:
Florence Yeun
2015-11-11 12:04:46 -08:00
parent 62888d02f6
commit f0cc2caca2
3 changed files with 3 additions and 10 deletions

View File

@@ -171,8 +171,10 @@ def js_config(extra_config=None):
mac = hmac.new(g.secrets["action_name"], route_name, hashlib.sha1)
verification = mac.hexdigest()
cur_subreddit = ""
cur_sr_fullname = ""
if isinstance(c.site, Subreddit) and not c.default_sr:
cur_subreddit = c.site.name
cur_sr_fullname = c.site._fullname
config = {
# is the user logged in?
@@ -181,6 +183,7 @@ def js_config(extra_config=None):
"user_id": user_id,
# the subreddit's name (for posts)
"post_site": cur_subreddit,
"cur_site": cur_sr_fullname,
# the user's voting hash
"modhash": c.modhash or False,
# the current rendering style

View File

@@ -46,9 +46,6 @@
${js_setup(getattr(thing, "extra_js_config", None))}
##things here may depend on globals, or included js, so we run them last
<script type="text/javascript">
${self.javascript_run()}
</script>
<style type="text/css">
## <style>s are treated as RAWTEXT segments, so we can't `websafe()` their contents.
## According to the HTML spec's RAWTEXT parsing rules, this should work for escaping.
@@ -86,9 +83,6 @@ reddit, reddit.com, vote, comment, submit
%endif
</%def>
<%def name="javascript_run()">
</%def>
<%def name="head()">
${googleanalytics('web', thing.is_gold_page() if hasattr(thing, 'is_gold_page') else False)}
</%def>

View File

@@ -131,10 +131,6 @@
${unsafe(c.js_preload.use())}
</%def>
<%def name="javascript_run()">
reddit.cur_site = "${c.site._fullname if hasattr(c.site, '_fullname') else ''}";
</%def>
<%def name="bodyContent()">
%if thing.header:
<%include file="adminbar.html"/>