Permalink
Browse files

Style, add bug tracker field, add linkify filter, ...

  • Loading branch information...
1 parent 5ad1286 commit 1b623c6796238df41e73c2df2d3982041650fa16 @bradfitz committed Mar 20, 2010
Showing with 47 additions and 17 deletions.
  1. +17 −0 filters.py
  2. +4 −8 main.py
  3. +1 −0 models.py
  4. +20 −9 project.html
  5. +5 −0 static/style.css
View
@@ -0,0 +1,17 @@
+import re
+from google.appengine.ext import webapp
+
+register = webapp.template.create_template_register()
+
+def linkify(text):
+ """Escape tags, add line breaks, and linkify HTTP URLs."""
+ if not text:
+ return ""
+ text = text.replace('<', '&lt;').replace('>', '&gt;').replace("\n", '<br/>\n')
+ text = re.sub(r'\b(https?://[\w\-\/\?\&\=\.]+)',
+ lambda x: "<a href='%s'>%s</a>" % (x.group(1), x.group(1)),
+ text)
+ return text
+
+register.filter(linkify)
+
View
12 main.py
@@ -27,6 +27,9 @@
import consumer
import models
+import filters
+
+webapp.template.register_template_library('filters')
def GetCurrentUser(request):
@@ -168,20 +171,12 @@ def get(self, project_key):
can_edit = user and project and user.sha1_key == project.owner.sha1_key
edit_mode = can_edit and (self.request.get('mode') == "edit")
- how_to_html = ""
- if project and project.how_to:
- how_to_html = project.how_to.replace('<', '&lt;').replace('>', '&gt;').replace("\n", '<br/>\n')
- how_to_html = re.sub(r'\b(https?://[\w\-\/\?\&\=\.]+)',
- lambda x: "<a href='%s'>%s</a>" % (x.group(1), x.group(1)),
- how_to_html)
-
template_values = {
"user": user,
"project": project,
"edit_mode": edit_mode,
"can_edit": can_edit,
"project_key": project_key,
- "how_to_html": how_to_html,
}
self.response.out.write(template.render("project.html", template_values))
@@ -205,6 +200,7 @@ def post(self):
project.how_to = self.request.get("how_to")
project.code_repo = self.request.get("code_repo")
project.home_page = self.request.get("home_page")
+ project.bug_tracker = self.request.get("bug_tracker")
project.put()
self.redirect('/' + project_key)
View
@@ -88,6 +88,7 @@ class Project(db.Model):
how_to = db.TextProperty(default="")
code_repo = db.StringProperty(indexed=False, default="")
home_page = db.StringProperty(indexed=False, default="")
+ bug_tracker = db.StringProperty(indexed=False, default="")
@property
def name(self):
View
@@ -28,48 +28,59 @@
<table cellpadding='10' border='0'>
<tr>
- <td align=right>Project homepage:</td>
+ <td align='right' class='f'>Project homepage:</td>
<td>
{% if edit_mode %}
<input name='home_page' value="{{ project.home_page|escape }}" size='40' />
{% else %}
- <a href="{{ project.home_page|escape }}">{{ project.home_page|escape }}</a>
+ {{ project.home_page|linkify }}
{% endif %}
</td>
</tr>
<tr>
- <td align=right><nobr>Code repository:</nobr></td>
+ <td align='right' class='f'><nobr>Code repository:</nobr></td>
<td>
{% if edit_mode %}
<input name='code_repo' value="{{ project.code_repo|escape }}" size='40' />
{% else %}
- <a href="{{ project.code_repo|escape }}">{{ project.code_repo|escape }}</a>
+ {{ project.code_repo|linkify }}
{% endif %}
</td>
</tr>
+ <tr>
+ <td align='right' class='f'><nobr>Bug Tracker:</nobr></td>
+ <td>
+ {% if edit_mode %}
+ <input name='bug_tracker' value="{{ project.bug_tracker|escape }}" size='40' />
+ {% else %}
+ {{ project.bug_tracker|linkify }}
+ {% endif %}
+ </td>
+ </tr>
+
<tr valign='top'>
- <td align=right>How to submit patches:</td>
+ <td align='right' class='f'>How to submit patches:</td>
<td>
{% if edit_mode %}
<textarea name='how_to' rows='10' cols='40'>{{ project.how_to|escape }}</textarea>
{% else %}
- {{ how_to_html }}
+ {{ project.how_to|linkify }}
{% endif %}
</td>
</tr>
{% if edit_mode %}
<tr valign='bottom'>
- <td align=right></td>
+ <td align='right'></td>
<td><input type='submit' value="Save" /></td>
</tr>
{% else %}
<tr valign='bottom'>
- <td align=right><nobr>Maintainer of this</nobr><br/><nobr>metadata page:</nobr></td>
+ <td align='right' class='f'><nobr>Maintainer of this</nobr><br/><nobr>metadata page:</nobr></td>
<td><a href="{{ project.owner.profile_page_url|escape }}">{{ project.owner.public_name|escape }}</a></td>
</tr>
<tr valign='bottom'>
- <td align=right>Last modified:</td>
+ <td align='right' class='f'>Last modified:</td>
<td>{{ project.last_edit_short }}</td>
</tr>
{% endif %}
View
@@ -19,3 +19,8 @@ body {
text-decoration: none;
color: #000;
}
+
+table .f {
+ font-weight: bold;
+ color: #676;
+}

0 comments on commit 1b623c6

Please sign in to comment.