Permalink
Browse files

Planes is in.

  • Loading branch information...
Livid
Livid committed Apr 5, 2011
1 parent aa370a0 commit 036836ebada49a4ba3bc6a56c3b4bb9894c7170f
View
39 main.py
@@ -56,8 +56,7 @@ def head(self):
def get(self):
host = self.request.headers['Host']
if host == 'beta.v2ex.com':
- self.redirect('http://www.v2ex.com/')
- return
+ return self.redirect('http://www.v2ex.com/')
site = GetSite()
browser = detect(self.request)
template_values = {}
@@ -219,6 +218,39 @@ def get(self):
path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'index.html')
output = template.render(path, template_values)
self.response.out.write(output)
+
+class PlanesHandler(BaseHandler):
+ def get(self):
+ c = 0
+ c = memcache.get('planes_c')
+ s = ''
+ s = memcache.get('planes')
+ if (s == None):
+ c = 0
+ s = ''
+ q = db.GqlQuery("SELECT * FROM Section ORDER BY nodes DESC")
+ if (q.count() > 0):
+ for section in q:
+ q2 = db.GqlQuery("SELECT * FROM Node WHERE section_num = :1 ORDER BY topics DESC", section.num)
+ n = ''
+ if (q2.count() > 0):
+ nodes = []
+ i = 0
+ for node in q2:
+ nodes.append(node)
+ i = i + 1
+ random.shuffle(nodes)
+ for node in nodes:
+ fs = random.randrange(12, 16)
+ n = n + '<a href="/go/' + node.name + '" class="item_node">' + node.title + '</a>'
+ c = c + 1
+ s = s + '<div class="sep20"></div><div class="box"><div class="cell"><div class="fr"><strong class="snow">' + section.title_alternative + u'</strong><small class="snow"> • ' + str(section.nodes) + ' nodes</small></div>' + section.title + '</div><div class="inner">' + n + '</div></div>'
+ memcache.set('planes', s, 3600)
+ memcache.set('planes_c', c, 3600)
+ self.values['c'] = c
+ self.values['s'] = s
+ self.values['page_title'] = self.site.title.decode('utf-8') + u'' + self.l10n.planes.decode('utf-8')
+ self.finalize(template_name='planes')
class RecentHandler(webapp.RequestHandler):
def get(self):
@@ -507,7 +539,7 @@ def post(self):
member.auth = hashlib.sha1(str(member.num) + ':' + member.password).hexdigest()
member.l10n = site.l10n
member.newbie = 1
- member.noob = 1
+ member.noob = 0
if member.num == 1:
member.level = 0
else:
@@ -1041,6 +1073,7 @@ def get(self):
def main():
application = webapp.WSGIApplication([
('/', HomeHandler),
+ ('/planes/?', PlanesHandler),
('/recent', RecentHandler),
('/ua', UAHandler),
('/signin', SigninHandler),
View
@@ -168,7 +168,9 @@ def get(self):
if (member.bio == None):
member.bio = ''
template_values['member_bio'] = member.bio
- if (member.l10n == None):
+ template_values['member_show_home_top'] = member.show_home_top
+ template_values['member_show_quick_post'] = member.show_quick_post
+ if member.l10n is None:
member.l10n = 'en'
template_values['member_l10n'] = member.l10n
s = GetLanguageSelect(member.l10n)
@@ -398,6 +400,19 @@ def post(self):
template_values['member_bio_error'] = member_bio_error
template_values['member_bio_error_message'] = member_bio_error_messages[member_bio_error]
template_values['errors'] = errors
+ # Verification: show_home_top and show_quick_post
+ try:
+ member_show_home_top = int(self.request.get('show_home_top'))
+ except:
+ member_show_home_top = 1
+ try:
+ member_show_quick_post = int(self.request.get('show_quick_post'))
+ except:
+ member_show_quick_post = 0
+ if member_show_home_top not in [0, 1]:
+ member_show_home_top = 1
+ if member_show_quick_post not in [0, 1]:
+ member_show_quick_post = 0
# Verification: l10n
member_l10n = self.request.get('l10n').strip()
supported = GetSupportedLanguages()
@@ -427,6 +442,8 @@ def post(self):
if member.twitter_oauth == 1:
member.twitter_sync = member_twitter_sync
member.bio = member_bio
+ member.show_home_top = member_show_home_top
+ member.show_quick_post = member_show_quick_post
member.l10n = member_l10n
member.put()
memcache.delete('Member_' + str(member.num))
View
@@ -199,6 +199,7 @@ def get(self, num):
class NotesItemEditHandler(webapp.RequestHandler):
def get(self, num):
site = GetSite()
+ browser = detect(self.request)
template_values = {}
template_values['site'] = site
template_values['system_version'] = SYSTEM_VERSION
@@ -213,7 +214,11 @@ def get(self, num):
if note.member.num == member.num:
template_values['member'] = member
template_values['note'] = note
- path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'notes_edit.html')
+ template_values['note_content'] = note.content
+ if browser['ios']:
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'mobile', 'notes_edit.html')
+ else:
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'notes_edit.html')
output = template.render(path, template_values)
self.response.out.write(output)
else:
@@ -225,6 +230,7 @@ def get(self, num):
def post(self, num):
site = GetSite()
+ browser = detect(self.request)
template_values = {}
template_values['site'] = site
template_values['system_version'] = SYSTEM_VERSION
@@ -257,7 +263,10 @@ def post(self, num):
self.redirect('/notes')
else:
template_values['note_content'] = note_content
- path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'notes_new.html')
+ if browser['ios']:
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'mobile', 'notes_new.html')
+ else:
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'notes_new.html')
output = template.render(path, template_values)
self.response.out.write(output)
else:
@@ -296,6 +296,7 @@ td.avatar_mini {
font-size: 14px;
font-weight: bold;
border: 1px solid #ccc;
+ width: 150px;
}
.sl:focus {
@@ -305,7 +306,6 @@ td.avatar_mini {
font-size: 14px;
font-weight: bold;
border: 1px solid #889fb9;
- width: 150px;
-moz-box-shadow: 0px 0px 5px #889fb9;
-webkit-box-shadow: 0px 0px 5px #889fb9;
outline: none;
View
@@ -22,12 +22,14 @@
</div>
<div id="Content">
<div class="box" id="topics_index">
- {{ site.home_top }}
+ {% if member %}{% if member.show_home_top %}{{ site.home_top }}{% endif %}{% else %}{{ site.home_top }}{% endif %}
{% if member %}
{% ifequal member.newbie 0 %}
+ {% ifequal member.show_quick_post 1 %}
<div class="cell"><div class="fr fade">请在 120 字内描述你的问题,或者,也可以使用 <a href="/new/qna">详细提问模式</a></div><span class="bigger snow"><strong style="font-family: 'Arial Black'; letter-spacing: -1.5px;">V2EX</strong> =› way to explore</span>
<div class="sep3"></div><form method="post" action="/new/qna"><textarea class="mll short" name="title"></textarea><div class="sep3"></div><div align="right"><div class="fl"><a href="/t/10686" class="node">V2EX 提问指南</a><span class="snow"> • </span><a href="/go/guide" class="node">本站规则指南</a></div><input type="submit" class="super normal button" value="向世界提问" /></div></form></div>
{% endifequal %}
+ {% endifequal %}
{% endif %}
{{ home }}
{% if member %}
@@ -57,7 +59,7 @@
</div>
<div class="sep20"></div>
<div class="box">
- <div class="cell"><span class="fade"><strong>{{ site.title }}</strong> / {{ l10n.nodes_portal }}</span></div>
+ <div class="cell"><div class="fr"><a href="/planes">{{ l10n.planes }}</a></div><span class="fade"><strong>{{ site.title }}</strong> / {{ l10n.nodes_portal }}</span></div>
{{ c }}
</div>
</div>
Oops, something went wrong.

0 comments on commit 036836e

Please sign in to comment.