Browse files

Make read-only mode slightly less frustrating.

Also includes some work on heavy-load mode which
isn't being used right now.
  • Loading branch information...
1 parent 2397f62 commit 4758ac8d2ed27889717c911aa49bddafc1a2d788 @spladug spladug committed Jul 23, 2011
2 r2/example.ini
@@ -25,6 +25,8 @@ amqp_logging = false
read_only_mode = false
# global switch for wiki write permissions
allow_wiki_editing = true
+# a modified read only mode used for cache shown during heavy load 503s
+heavy_load_mode = false
# -- SECRETS! <-- update these first! --
# global secret
5 r2/r2/lib/
@@ -91,6 +91,7 @@ class Globals(object):
+ 'heavy_load_mode',
@@ -187,6 +188,10 @@ def __init__(self, global_conf, app_conf, paths, **extra):
self.display_tz = pytz.timezone(dtz)
def setup(self, global_conf):
+ # heavy load mode is read only mode with a different infobar
+ if self.heavy_load_mode:
+ self.read_only_mode = True
if hasattr(signal, 'SIGUSR1'):
# not all platforms have user signals
signal.signal(signal.SIGUSR1, thread_dump)
11 r2/r2/lib/pages/
@@ -141,7 +141,10 @@ def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
u.hostname = "%s.%s" % (g.domain_prefix, u.hostname)
self.canonical_link = u.unparse()
if self.show_firsttext and not infotext:
- if g.read_only_mode:
+ if g.heavy_load_mode:
+ # heavy load mode message overrides read only
+ infotext = strings.heavy_load_msg
+ elif g.read_only_mode:
infotext = strings.read_only_msg
elif (c.firsttime == 'mobile_suggest' and
c.render_style != 'compact'):
@@ -220,7 +223,7 @@ def rightbox(self):
no_ads_yet = False
- if self.submit_box:
+ if self.submit_box and (c.user_is_loggedin or not g.read_only_mode):
ps.append(SideBox(_('Submit a link'),
'/submit', 'submit',
sr_path = (isinstance(,DefaultSR)
@@ -322,9 +325,11 @@ def build_toolbars(self):
- NamedButton('saved', False)
+ if c.user_is_loggedin or not g.read_only_mode:
+ main_buttons.append(NamedButton('saved', False))
more_buttons = []
if c.user_is_loggedin:
1 r2/r2/lib/
@@ -139,6 +139,7 @@
verified_quota_msg = _("You've submitted several links recently that haven't been doing very well. You'll have to wait a while before you can submit again, or [write to the moderators of this reddit](%(link)s) and ask for an exemption."),
unverified_quota_msg = _("You haven't [verified your email address](%(link1)s); until you do, your submitting privileges will be severely limited. Please try again in an hour or verify your email address. If you'd like an exemption from this rule, please [write to the moderators of this reddit](%(link2)s)."),
read_only_msg = _("reddit is in \"emergency read-only mode\" right now. :( you won't be able to log in. we're sorry, and are working frantically to fix the problem."),
+ heavy_load_msg = _("reddit is under heavy load right now. :( we're sorry, and are working frantically to fix the problem. in the mean time, here's a read-only cached version of the page you were trying to access."),
lounge_msg = _("Please grab a drink and join us in [the lounge](%(link)s)."),
postcard_msg = _("You sent us a postcard! (Or something similar.) When we run out of room on our refrigerator, we might one day auction off the stuff that people sent in. Is it okay if we include your thing?"),
over_comment_limit = _("Sorry, the maximum number of comments is %(max)d. (However, if you subscribe to reddit gold, it goes up to %(goldmax)d.)"),
2 r2/r2/templates/printablebuttons.html
@@ -149,10 +149,12 @@
${self.simple_button(_("edit"), "edit_usertext", css_class="edit-usertext")}
+ % if c.user_is_loggedin or not g.read_only_mode:
<li class="share">
${self.toggle_button("share-button", _("share"), _("cancel"),
"share", "cancelShare", login_required = True)}
+ % endif
%if thing.is_loggedin:
%if thing.saved:
2 r2/r2/templates/reddit.html
@@ -142,7 +142,7 @@
- %if not c.user_is_loggedin:
+ %if not c.user_is_loggedin and not g.read_only_mode:
%if thing.enable_login_cover:
<div class="login-popup cover-overlay" style="display: none">
<div class="cover" onclick="return hidecover(this)"></div>
2 r2/r2/templates/redditheader.html
@@ -53,7 +53,7 @@
<div id="header-bottom-${'left' if c.lang_rtl else 'right'}">
%if not c.user_is_loggedin:
- %if thing.enable_login_cover:
+ %if thing.enable_login_cover and not g.read_only_mode:
<span class="user">
${text_with_js(_("want to join? %(register)s in seconds"),
register=(_("register"), "return showcover(false);"))}

0 comments on commit 4758ac8

Please sign in to comment.