Permalink
Browse files

Add browse page.

  • Loading branch information...
1 parent 654ee05 commit 05b3e09eb156a20723a80b27ccb9aba84d382cdc @bradfitz committed Mar 22, 2010
Showing with 59 additions and 5 deletions.
  1. +1 −0 base.html
  2. +24 −0 browse.html
  3. +6 −5 index.html
  4. +26 −0 main.py
  5. +2 −0 static/robots.txt
View
@@ -2,6 +2,7 @@
<head>
<title>{% block headtitle %}{% endblock %}</title>
<link rel='stylesheet' href='/static/style.css' type='text/css' />
+{% block head %}{% endblock %}
</head>
<body>
<table style="border-bottom: 1px solid #77f" width="100%" id='topbar'>
View
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+{% block headtitle %}
+ Browse Projects
+{% endblock %}
+{% block title %}
+ Browse Projects
+{% endblock %}
+{% block head %}
+<meta name="robots" content="noindex" />
+{% endblock %}
+{% block content %}
+
+<p>Some projects that are using <i>Contributing</i> ...</p>
+
+<ul>
+{% for p in projects %}
+ <li><a href="/{{ p.key.name }}" rel="nofollow">{{ p.key.name }}</a></li>
+{% endfor %}
+{% if next_page_project %}
+ <li><a href="/s/browse/?start={{ next_page_project.key.name }}" rel="nofollow"><i>next page...</i></a></li>
+{% endif %}
+</ul>
+
+{% endblock %}
View
@@ -10,10 +10,10 @@
source projects.</p>
<p>It gives projects a stable URL which they can put in their
- documentation (and/or <tt>CONTRIBUTING</tt> files) providing
- an abstraction layer making sure even old downloads of projects
- still contain a pointer to recent pointers to how-to-contribute
- docs.</p>
+ documentation (and/or <tt>CONTRIBUTING</tt> files) providing an
+ abstraction layer, making sure even old downloads of projects
+ still contain a pointer to recent information on how to
+ contribute.</p>
<p>Also, this site allows for <a href="#">project take-overs</a>,
if the original maintainer(s) disappear and don't keep their
@@ -33,7 +33,8 @@
to keep running and minimizes risks of it shutting down due to
lack of funds or forgotten domain name renewals.</p>
- <p>Feel free to <a href='/s/create'>create a project page</a>.</p>
+ <p>Feel free to <a href='/s/create'>create a project page</a> or
+ <a href='/s/browse'>browse existing projects</a>.</p>
{% endblock %}
View
26 main.py
@@ -219,6 +219,31 @@ def post(self):
self.redirect('/' + project_key)
+class BrowseHandler(webapp.RequestHandler):
+
+ def get(self):
+ user = GetCurrentUser(self.request)
+
+ projects = models.Project.all().order('__key__')
+ if self.request.get("start"):
+ projects = projects.filter('__key__ >=',
+ db.Key.from_path(models.Project.kind(),
+ self.request.get("start")))
+ PAGE_SIZE = 25
+ projects = projects.fetch(PAGE_SIZE + 1)
+ next_page_project = None
+ if len(projects) > PAGE_SIZE:
+ next_page_project = projects[-1]
+ projects = projects[0:PAGE_SIZE]
+
+ template_values = {
+ "user": user,
+ "projects": projects,
+ "next_page_project": next_page_project,
+ }
+ self.response.out.write(template.render("browse.html", template_values))
+
+
def main():
application = webapp.WSGIApplication([
('/', IndexHandler),
@@ -227,6 +252,7 @@ def main():
('/s/logout', LogoutHandler),
('/s/editproject', ProjectEditHandler),
('/s/notelogin', NoteLoginHandler),
+ ('/s/browse/?', BrowseHandler),
('/s/.*', SiteHandler),
(r'/u/([a-f0-9]{6,})', UserHandler),
(r'/([a-z][a-z0-9\.\-]*[a-z0-9])/?', ProjectHandler),
View
@@ -1,2 +1,4 @@
User-agent: *
+Disallow: /s/browse
+Disallow: /s/browse/
Allow: /

0 comments on commit 05b3e09

Please sign in to comment.