# HG changeset patch # User k0s # Date 1256520993 14400 # Node ID 1554cb56aa2f66e5bdfd7d7aa56254b99228d34e # Parent 8931c5b7e632f521ed88153801d1aa4d68a33560 got index working, just doesnt do anything diff -r 8931c5b7e632 -r 1554cb56aa2f bitsyblog/bitsyblog.py --- a/bitsyblog/bitsyblog.py Sun Oct 25 21:30:42 2009 -0400 +++ b/bitsyblog/bitsyblog.py Sun Oct 25 21:36:33 2009 -0400 @@ -106,6 +106,12 @@ res = Response(content_type=content_type, body=text) return res + def logo(self, request): + _logo = 'bitsyblog.png' # TODO: should go to self.logo + logo = os.path.join(self.file_dir, _logo) + if os.path.exists(logo): + return self.link(request, _logo) + def get_index(self, request): """returns material pertaining to the root of the site""" @@ -114,7 +120,7 @@ ### the front page if not path: - return self.get_response(self.index(n_links)) + return self.get_response(self.index(request, n_links)) ### feeds @@ -146,7 +152,7 @@ # logo if path == 'bitsyblog.png': logo = os.path.join(self.file_dir, 'bitsyblog.png') - if not os.path.exists(logo): + if not self.logo(request): raise exc.HTTPNotFound return self.get_response(file(logo, 'rb').read(), content_type='image/png') # should use FileApp @@ -233,7 +239,7 @@ request.environ['data'] = { 'site_name': self.site_name, 'request': request, 'link': self.link, - 'escape': cgi.escape } + 'logo': self.logo(request) } # front matter of the site index = self.get_index(request) @@ -552,7 +558,7 @@ user = self.authenticated(request) if user: links.extend([(self.user_url(request, user), user), - (self.user_url(request, user, 'post'), user), + (self.user_url(request, user, 'post'), 'post'), (self.user_url(request, user, 'preferences'), 'preferences'), (self.link(request, 'logout'), 'logout')]) else: @@ -566,30 +572,34 @@ def index(self, request, n_links): - - retval = StringIO() - print >> retval, '

bitsyblog

' + data = request.environ['data'] + self.site_nav(request) + template = self.loader.load('index.html') + return template.generate(**request.environ['data']).render() - # get the blogs - blogs = {} - for user in self.users: - blog = self.blog(user, ('public',), n_links) - if blog: - blogs[user] = blog - users = blogs.keys() +# retval = StringIO() +# print >> retval, '

bitsyblog

' - # display latest active user first - users.sort(key=lambda user: blogs[user][0].date, reverse=True) +# # get the blogs +# blogs = {} +# for user in self.users: +# blog = self.blog(user, ('public',), n_links) +# if blog: +# blogs[user] = blog +# users = blogs.keys() - # display users' blogs - for user in users: - print >> retval, '
' % user - print >> retval, '%s' % (user, user) - blog = blogs[user] - print >> retval, self.navigation(user, blog, '/%s' % user, n_links) - print >> retval, '
' +# # display latest active user first +# users.sort(key=lambda user: blogs[user][0].date, reverse=True) - return self.render(request, retval.getvalue(), feedtitle=self.site_name) +# # display users' blogs +# for user in users: +# print >> retval, '
' % user +# print >> retval, '%s' % (user, user) +# blog = blogs[user] +# print >> retval, self.navigation(user, blog, '/%s' % user, n_links) +# print >> retval, '
' + +# return self.render(request, retval.getvalue(), feedtitle=self.site_name) def navigation(self, user, blog, path, n_links, n_char=80): prefs = self.users[user].settings @@ -848,7 +858,7 @@ request.environ['data'] = { 'site_name': self.site_name, 'request': request, 'link': self.link, - 'escape': cgi.escape } + 'logo': self.logo(request) } ### user space user, path = self.userpath(request) diff -r 8931c5b7e632 -r 1554cb56aa2f bitsyblog/templates/index.html --- a/bitsyblog/templates/index.html Sun Oct 25 21:30:42 2009 -0400 +++ b/bitsyblog/templates/index.html Sun Oct 25 21:36:33 2009 -0400 @@ -1,8 +1,16 @@ - + + + ${site_name} + - -

${site_name}

+ + +

${site_name}