From 54faeb8aac32c63dc8bce78ec12e569536700b10 Mon Sep 17 00:00:00 2001 From: KeyserSosa Date: Mon, 13 Jul 2009 13:55:07 -0700 Subject: [PATCH] add custom firsttext for iphones, linking out to free reddit app --- r2/r2/controllers/reddit_base.py | 6 +++++- r2/r2/lib/pages/pages.py | 7 +++++-- r2/r2/lib/strings.py | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/r2/r2/controllers/reddit_base.py b/r2/r2/controllers/reddit_base.py index fb5a4e0ef..fb2401d46 100644 --- a/r2/r2/controllers/reddit_base.py +++ b/r2/r2/controllers/reddit_base.py @@ -169,7 +169,11 @@ def read_mod_cookie(): set_user_cookie('mod', '') def firsttime(): - if get_redditfirst('firsttime'): + if (request.user_agent and 'iphone' in request.user_agent.lower() and + not get_redditfirst('iphone')): + set_redditfirst('iphone','first') + return 'iphone' + elif get_redditfirst('firsttime'): return False else: set_redditfirst('firsttime','first') diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 2aa8f34f2..39bcade6f 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -107,8 +107,11 @@ class Reddit(Templated): #add the infobar self.infobar = None - if self.show_firsttext and c.firsttime and c.site.firsttext and not infotext: - infotext = c.site.firsttext + if self.show_firsttext and not infotext: + if c.firsttime == 'iphone': + infotext = strings.iphone_first + elif c.firsttime and c.site.firsttext: + infotext = c.site.firsttext if infotext: self.infobar = InfoBar(message = infotext) diff --git a/r2/r2/lib/strings.py b/r2/r2/lib/strings.py index 908d64240..8e4046136 100644 --- a/r2/r2/lib/strings.py +++ b/r2/r2/lib/strings.py @@ -124,6 +124,7 @@ string_dict = dict( submit_link = _("""You are submitting a link. The key to a successful submission is interesting content and a descriptive title."""), submit_text = _("""You are submitting a text-based post. Speak your mind. A title is required, but expanding further in the text field is not. Beginning your title with "vote up if" is violation of intergalactic law."""), + iphone_first = _("You should consider using [reddit's free iphone app](http://itunes.com/apps/iredditfree)."), ) class StringHandler(object):