Rename c.allow_styles and repurpose it for convenient overriding.

This enables fine-grained control to un-block CSS without affecting
whether it would be displayed based on user settings or context.
This commit is contained in:
Max Goodman
2012-04-05 15:00:47 -07:00
parent 7689d9c01d
commit 3a5d967553
3 changed files with 7 additions and 6 deletions

View File

@@ -892,15 +892,16 @@ class RedditController(MinimalController):
return self.intermediate_redirect("/over18")
#check whether to allow custom styles
c.allow_styles = self.allow_stylesheets
c.allow_styles = True
c.can_apply_styles = self.allow_stylesheets
if g.css_killswitch:
c.allow_styles = False
c.can_apply_styles = False
#if the preference is set and we're not at a cname
elif not c.user.pref_show_stylesheets and not c.cname:
c.allow_styles = False
c.can_apply_styles = False
#if the site has a cname, but we're not using it
elif c.site.domain and c.site.css_on_cname and not c.cname:
c.allow_styles = False
c.can_apply_styles = False
def check_modified(self, thing, action,
private=True, max_age=0, must_revalidate=True):

View File

@@ -67,7 +67,7 @@
<link rel="shorturl" href="http://${thing.shortlink}"/>
%endif
%if c.allow_styles and c.site.stylesheet_contents:
%if c.can_apply_styles and c.allow_styles and c.site.stylesheet_contents:
<% inline_stylesheet = (
len(c.site.stylesheet_contents) < 1024
and '<' not in c.site.stylesheet_contents) %>

View File

@@ -35,7 +35,7 @@
<%
header_title = c.site.header_title
d = DefaultSR()
if c.site.header and c.allow_styles:
if c.site.header and c.can_apply_styles and c.allow_styles:
header_img = c.site.header
header_size = c.site.header_size
else: