Skip to content

Commit

Permalink
tweaks to the templates and addition of more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
garethr committed Jun 3, 2009
1 parent 78e6e7c commit 0f47913
Show file tree
Hide file tree
Showing 41 changed files with 398 additions and 54 deletions.
Empty file modified .gitignore 100644 → 100755
Empty file.
Empty file modified README.textile 100644 → 100755
Empty file.
9 changes: 7 additions & 2 deletions admin.py 100644 → 100755
Expand Up @@ -37,7 +37,7 @@ def get(self):
memcache.add("error404", output, 3600)
self.response.out.write(output)

def main():
def application():
"Run the application"
# wire up the views
ROUTES = [
Expand All @@ -46,7 +46,12 @@ def main():
('/.*', NotFoundPageHandler),
]
application = webapp.WSGIApplication(ROUTES, debug=settings.DEBUG)
run_wsgi_app(application)
return application

def main():
"Run the application"
run_wsgi_app(application())


if __name__ == '__main__':
main()
Empty file modified app.yml 100644 → 100755
Empty file.
Empty file modified assets/css/admin.css 100644 → 100755
Empty file.
50 changes: 43 additions & 7 deletions assets/css/main.css 100644 → 100755
Expand Up @@ -45,8 +45,7 @@ a:hover {
margin: 10px;
}
#extra {
float: right;
width: 200px;
margin-top: 40px;
}

/* =Navigation */
Expand All @@ -63,7 +62,7 @@ a:hover {
color: #555;
}
#greeting a, #navigation ul li a {
color: #777769;
color: #999;
text-decoration: none;
}
#navigation ul li.this {
Expand All @@ -75,17 +74,33 @@ a:hover {

/* =Detail */

#content ul.projects .desc {
font-size: 85%;
color: #666;
margin-top: 5px;
}
#content ul.projects li a {
font-size: 200%;
font-size: 110%;
}
#content ul.projects li span {
font-size: 85%;
color: #777;
display: block;
margin-top: 2px;
}
#content ul.projects li p span {
margin : 0;
display: inline;
font-size: 100%;
}
#content ul.projects li {
margin-bottom: 20px;
float: left;
width: 31%;
margin-right: 2%;
margin-bottom: 15px;
}
#content ul.projects li:hover {
border-color: #CCC;
}
#header h1 {
font-size: 200%;
Expand Down Expand Up @@ -131,11 +146,23 @@ a:hover {
border-top: 1px solid #CCC;
}
#txt {
margin: 20px 0 10px;
margin: 20px 20px 10px 0;
}
#txt p {
margin-bottom: 1em;
}
#txt ul, #txt ol {
margin-bottom: 1em;
}
#txt li {
margin-left: 1.5em;
}
#txt ul li {
list-style-type: disc;
}
#txt ol li {
list-style-type: decimal;
}
#extra h2 {
margin-bottom: 10px;
color: #A7BDC8;
Expand Down Expand Up @@ -215,7 +242,7 @@ form div p {
color: #777;
}
#addproject {
margin-bottom: 20px;
margin-bottom: 30px;
}
#addproject label {
left: -9999em;
Expand Down Expand Up @@ -308,4 +335,13 @@ form div p {
}
.home #secondary {
padding-left: 10px;
}
.message {
padding: 10px;
border: 1px solid #CCC;
background: #ECECEC;
margin-bottom: 10px;
}
.message strong {
font-weight: bold;
}
Empty file modified assets/css/reset.css 100644 → 100755
Empty file.
Binary file added assets/images/favicon.ico
Binary file not shown.
Empty file modified ext/PyRSS2Gen.py 100644 → 100755
Empty file.
Empty file modified ext/__init__.py 100644 → 100755
Empty file.
Empty file modified ext/textile.py 100644 → 100755
Empty file.
Empty file modified filters.py 100644 → 100755
Empty file.
17 changes: 13 additions & 4 deletions index.yaml 100644 → 100755
Expand Up @@ -10,21 +10,30 @@ indexes:
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

# Used 11 times in query history.
# Unused in query history -- copied from input.
- kind: Issue
properties:
- name: fixed
- name: project
- name: created_date

# Used 236 times in query history.
# Used 4 times in query history.
- kind: Issue
properties:
- name: fixed
- name: project
- name: name

# Used 426 times in query history.
# Used 6 times in query history.
- kind: Issue
properties:
- name: fixed
- name: project
- name: name
- name: created_date
direction: desc

# Used 9 times in query history.
- kind: Issue
properties:
- name: project
Expand Down Expand Up @@ -53,7 +62,7 @@ indexes:
- name: project
- name: name

# Used 152 times in query history.
# Used 2 times in query history.
- kind: Project
properties:
- name: user
Expand Down
5 changes: 3 additions & 2 deletions lib.py 100644 → 100755
Expand Up @@ -15,9 +15,10 @@

def slugify(value):
"Slugify a string, to make it URL friendly."

value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicodedata.normalize('NFKD', unicode(value)).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
# added remove underscores
value = value.replace('_', '')
return re.sub('[-\s]+','-',value)

def textile(value):
Expand Down
76 changes: 57 additions & 19 deletions main.py 100644 → 100755
Expand Up @@ -14,7 +14,7 @@

from django.utils import simplejson

from lib import BaseRequest, get_cache
from lib import BaseRequest, get_cache, slugify
import settings
from models import Project, Issue
from ext.PyRSS2Gen import RSS2, RSSItem
Expand All @@ -24,6 +24,16 @@
# regex for the patter to look for in the webhooks
GITBUG = re.compile('#gitbug[0-9]+')

# validate url
URL_RE = re.compile(
r'^https?://' # http:// or https://
r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain...
r'localhost|' #localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|/\S+)$', re.IGNORECASE)


class Index(BaseRequest):
"Home page. Shows either introductory info or a list of the users projects"
def get(self):
Expand Down Expand Up @@ -77,7 +87,7 @@ def get(self, slug):
'issues': issues,
'owner': owner,
}
output = self.render("project.html", context)
output = self.render("project.html", context)
if not user:
# only save a cached version if we're not logged in
# so as to avoid revelaving user details
Expand Down Expand Up @@ -114,7 +124,7 @@ def post(self, slug):
""" % (issue.name, issue.description))
logging.info("issue created: %s in %s" % (name, project.name))
except Exception, e:
logging.error("error adding project: %s" % e)
logging.error("error adding issue: %s" % e)

self.redirect("/projects/%s/" % slug)

Expand Down Expand Up @@ -329,9 +339,18 @@ def post(self, slug):
project.other_users = []

if self.request.get("url"):
project.url = self.request.get("url")
url = self.request.get("url")
if not url[:7] == 'http://':
url = "http://%s" % url
if URL_RE.match(url):
project.url = url
else:
project.url = None

if self.request.get("description"):
project.description = self.request.get("description")
else:
project.description = None
project.put()
logging.info("project modified: %s" % project.name)
except db.BadValueError, e:
Expand All @@ -354,12 +373,19 @@ def get(self, project_slug, issue_slug):
if output is None:
try:
issue = Issue.all().filter('internal_url =', "/%s/%s/" % (project_slug, issue_slug)).fetch(1)[0]
issues = Issue.all().filter('project =', issue.project).filter('name !=', issue.name).filter('fixed =', False).order('-created_date').fetch(10)
issues = Issue.all().filter('project =', issue.project).filter('name !=', issue.name).filter('fixed =', False).order('name').order('-created_date').fetch(10)
except IndexError:
self.render_404()
return

if issue.project.user == user or users.is_current_user_admin() or user.email() in issue.project.other_users:
on_list = False
try:
if user.email() in issue.project.other_users:
on_list = True
except:
pass

if issue.project.user == user or users.is_current_user_admin() or on_list:
owner = True
else:
owner = False
Expand Down Expand Up @@ -532,16 +558,23 @@ def post(self):
return

name = self.request.get("name")
if Project.all().filter('name =', name).count() == 0:
try:
project = Project(
name=name,
user=users.get_current_user(),
)
project.put()
logging.info("project added: %s" % project.name)
except db.BadValueError, e:
logging.error("error adding project: %s" % e)

# check we have a value
if name:
# then check we have a value which isn't just spaces
if name.strip():
if Project.all().filter('name =', name).count() == 0:
# we also need to check if we have something with the same slug
if Project.all().filter('slug =', slugify(unicode(name))).count() == 0:
try:
project = Project(
name=name,
user=users.get_current_user(),
)
project.put()
logging.info("project added: %s" % project.name)
except db.BadValueError, e:
logging.error("error adding project: %s" % e)
self.redirect('/')

class ProjectsJsonHandler(BaseRequest):
Expand Down Expand Up @@ -606,7 +639,7 @@ def post(self, slug):

key = self.request.get("key")

if key == project.__key__:
if key == project.key():
try:
payload = self.request.get("payload")
representation = simplejson.loads(payload)
Expand Down Expand Up @@ -656,7 +689,7 @@ def get(self):
memcache.add("faq", output, 3600)
self.response.out.write(output)

def main():
def application():
"Run the application"
# wire up the views
ROUTES = [
Expand All @@ -677,7 +710,12 @@ def main():
('/.*', NotFoundPageHandler),
]
application = webapp.WSGIApplication(ROUTES, debug=settings.DEBUG)
run_wsgi_app(application)
return application

def main():
"Run the application"
run_wsgi_app(application())


if __name__ == '__main__':
main()
Empty file modified middleware.py 100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion models.py 100644 → 100755
Expand Up @@ -11,6 +11,8 @@ class Project(db.Model):
"Represents a single project"
name = db.StringProperty(required=True)
url = db.LinkProperty()
description = db.TextProperty()
html = db.TextProperty()
slug = db.StringProperty()
created_date = db.DateTimeProperty(auto_now_add=True)
user = db.UserProperty(required=True)
Expand All @@ -29,6 +31,7 @@ def closed_issues(self):
def put(self):
# we set the slug on the first save
# after which it is never changed
self.html = textile(unicode(self.description))
if not self.slug:
self.slug = slugify(unicode(self.name))
super(Project, self).put()
Expand All @@ -44,7 +47,7 @@ class Counter(db.Model):
class Issue(search.SearchableModel):
"Issue or bug representation"
name = db.StringProperty(required=True)
description = db.TextProperty(required=True)
description = db.TextProperty()
html = db.TextProperty()
created_date = db.DateTimeProperty(auto_now_add=True)
email = db.EmailProperty()
Expand Down
10 changes: 8 additions & 2 deletions settings.py 100644 → 100755
@@ -1,9 +1,15 @@
import os

DEBUG = os.environ['SERVER_SOFTWARE'].startswith('Dev')
# when running the tests we don't have the environment variable available
try:
debug = os.environ['SERVER_SOFTWARE'].startswith('Dev')
except KeyError:
debug = False

DEBUG = debug

# enable or disable the memcache here, useful for debugging
CACHE = not os.environ['SERVER_SOFTWARE'].startswith('Dev')
CACHE = not debug

# URL of the current system, used in feeds
SYSTEM_URL = "http://gitbug.appspot.com"
Empty file modified templates/403.html 100644 → 100755
Empty file.
Empty file modified templates/404.html 100644 → 100755
Empty file.
Empty file modified templates/500.html 100644 → 100755
Empty file.
Empty file modified templates/_issues.html 100644 → 100755
Empty file.
Empty file modified templates/_issues_list.html 100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion templates/_projects.html 100644 → 100755
@@ -1,7 +1,8 @@
{% if projects %}
<ul class="projects">
{% for project in projects %}
<li><a href="/projects/{{project.slug}}/">{{project.name}}</a> <span>Created on {{project.created_date|date:"jS F Y"}} | Issues: {{project.open_issues.count}}</span></li>
<li><a href="/projects/{{project.slug}}/">{{project.name}}</a> <span>Created on {{project.created_date|date:"jS F Y"}} | Issues: {{project.open_issues.count}}</span>
</li>
{% endfor %}
</ul>
{% endif %}
Empty file modified templates/admin.html 100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions templates/base.html 100644 → 100755
@@ -1,5 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<title>{% block title %}{% endblock %}</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
Expand Down

0 comments on commit 0f47913

Please sign in to comment.