Project

General

Profile

« Previous | Next » 

Revision f9b5ab4b

Added by dsorber almost 12 years ago

Continuing to work on the web GUI a little at a time. A made an important modification to the way the controllers work so that you don't have to pass the template name into the controller instantiation in the .wsgi script and instead the template name is a parameter with a default value.

View differences:

software/bookmark_library/bmklib/web/controllers/bookmark.py
import sqlite3
from bmklib.lib.bookmark import Bookmark
from bmklib.web.base_controller import BaseHTMLController, DB_PATH
class BookmarkPageController(BaseHTMLController):
def __init__(self, environ, template_name='bookmark.html'):
super(BookmarkPageController, self).__init__(environ, template_name)
def build_content(self):
conn = sqlite3.connect(DB_PATH)
db = conn.cursor()
db.execute("SELECT id FROM bookmarks WHERE deleted=0")
bookmarks = [Bookmark(conn, id=row[0]) for row in db.fetchall()]
self.content['bookmarks'] = bookmarks
software/bookmark_library/bmklib/web/htdocs/css/bmk_main.css
body {
font-family: sans-serif;
font-size: 16px
}
h3 {
font-size: 24px;
}
table {
border: 1px solid #000;
border-spacing: 0px;
margin-left: auto;
margin-right: auto;
}
table a:link {
color: #000;
text-decoration: none;
}
table a:visited {
color: #000;
text-decoration: none;
}
table a:hover {
color: #000;
text-decoration: underline;
}
tr.even {
background-color: #FFF;
}
tr.odd {
background-color: #FFC;
}
th {
border: 1px solid #000;
padding: 10px;
border-spacing: 2px;
}
td {
border-top: 1px solid #000;
padding: 2px 5px;
}
software/bookmark_library/bmklib/web/templates/bookmark.html
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/">
<head>
<title>Bookmark Library</title>
<link rel="stylesheet" type="text/css" href="../htdocs/css/bmk_main.css"></link>
</head>
<body>
<h1>Bookmarks</h1>
<table>
<tr py:for="idx, bookmark in enumerate(bookmarks)" class="${idx % 2 == 1 and 'odd' or 'even'}">
<td>${bookmark.id}</td>
<td><a href="${bookmark.url}">${bookmark.title and bookmark.title or 'no title'}</a></td>
<td><py:for each="tag in bookmark.category_tags"><div class="tag">${tag.value}</div></py:for></td>
<td><py:for each="tag in bookmark.description_tags"><div class="tag">${tag.value}</div></py:for></td>
</tr>
</table>
</body>
</html>

Also available in: Unified diff