Project

General

Profile

« Previous | Next » 

Revision bf2beea6

Added by dsorber almost 12 years ago

Whoops, I forgot that I have to manually add files that I modified to commits with git. Guess I'm a bit of a git...

View differences:

software/bookmark_library/bmklib/web/base_controller.py
class BaseHTMLController(object):
def __init__(self, template_name, environ):
def __init__(self, environ, template_name=None):
self.environ = environ
software/bookmark_library/bmklib/web/bmklib.wsgi
from bmklib.web.controllers.bookmark import BookmarkPageController
from bmklib.web.controllers.main import MainPageController
# It accepts two arguments:
......
if not environ['PATH_INFO'] or environ['PATH_INFO'] == '/':
controller = MainPageController('main.html', environ)
controller = MainPageController(environ)
response_headers, response_body = controller.generate_response()
elif environ['PATH_INFO'].startswith('/bookmark'):
controller = BookmarkPageController(environ)
response_headers, response_body = controller.generate_response()
else:
# User supplied an invalid URL
response_body = 'Invalid URL "%s"' % environ['PATH_INFO']
software/bookmark_library/bmklib/web/controllers/main.py
class MainPageController(BaseHTMLController):
def __init__(self, environ, template_name='main.html'):
super(MainPageController, self).__init__(environ, template_name)
def build_content(self):
conn = sqlite3.connect(DB_PATH)
software/bookmark_library/bmklib/web/templates/main.html
xmlns:py="http://genshi.edgewall.org/">
<head>
<title>Bookmark Library</title>
<style type="text/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;
}
</style>
<link rel="stylesheet" type="text/css" href="../htdocs/css/bmk_main.css"></link>
</head>
<body>
<h1>Bookmark Library</h1>
There are currently ${total_num_bmks} bookmarks in the library.
<ul>
<li><a href="bookmark">All bookmarks</a></li>
<li>All tags</li>
</ul>
</body>
</html>

Also available in: Unified diff