# HG changeset patch # User k0s # Date 1256510148 14400 # Node ID e5cbc53cacf83d45c51d3b3b5420f99cd9372789 # Parent 2bd6b2b543dcc08a7b4a207e78a5f207285a835f now have stylesheets diff -r 2bd6b2b543dc -r e5cbc53cacf8 bitsyblog/bitsyblog.py --- a/bitsyblog/bitsyblog.py Sun Oct 25 18:11:25 2009 -0400 +++ b/bitsyblog/bitsyblog.py Sun Oct 25 18:35:48 2009 -0400 @@ -511,9 +511,8 @@ def render(self, request, body, title=None, feedtitle=None): """layout the page in a unified way""" - stylesheets = () + _title = [ self.site_name ] user = getattr(request, 'user', None) - _title = [ self.site_name ] if user: stylesheets = request.user['CSS'] stylesheets = [ (("/%s" % self.user_url(request, user.name, 'css', css['filename'])), @@ -533,6 +532,17 @@ return markup.wrap(self.site_nav(request)+body, title, stylesheets, head_markup=head_markup) + def stylesheets(self, request): + user = getattr(request, 'user', None) + if user: + stylesheets = request.user['CSS'] + stylesheets = [ (self.user_url(request, user.name, 'css', css['filename']), + css['name']) for css in stylesheets ] + else: + stylesheets = [(self.link(request, "css/site.css"), "Default")] + return stylesheets + + def site_nav(self, request): """returns HTML for site navigation""" @@ -605,44 +615,6 @@ print >> retval, '' return retval.getvalue() -# def blog_entry(self, request, user, entry): -# """given the content string, return a marked-up blog entry""" -# # XXX no need to pass user - -# # user preferences -# prefs = request.user.settings -# format = prefs.get('Date format', self.date_format) -# subject = prefs.get('Subject', self.subject) - -# role = self.role(user, request) - -# subject = subject % { 'date' : entry.date.strftime(format) } -# subject = cgi.escape(subject) -# html = StringIO() -# blog_id = entry.datestamp() -# print >> html, '
' % blog_id -# print >> html, '' % blog_id -# print >> html, '
' -# print >> html, '%s' % (self.user_url(request, user, blog_id), subject) -# if (entry.privacy == 'secret') and (role == 'friend'): -# print >> html, 'secret' -# print >> html, '
' -# print >> html, self.cooker(entry.body) - -# if role == 'author': -# print >> html, '
' % self.user_url(request, entry.user, blog_id) -# print >> html, self.privacy_settings(entry.privacy) -# print >> html, '' -# print >> html, '
' -# if entry.privacy != 'public': -# title = "You can give this URL so people may see this %s post without logging in" % entry.privacy -# print >> html, '
' -# print >> html, 'Mangled URL:' % title -# print >> html, markup.link(self.mangledurl(request, entry)) -# print >> html, '
' - -# print >> html, '
' -# return html.getvalue() def write_blog(self, user, blog, path, n_links, request): """return the user's blog in HTML""" @@ -662,7 +634,7 @@ data = request.environ['data'] data['user'] = user data['role'] = self.role(user, request) - data['stylesheets'] = () # TODO + data['stylesheets'] = self.stylesheets(request) data['subject'] = request.user.settings.get('Subject', self.subject) data['date_format'] = request.user.settings.get('Date format', self.date_format) data['user_url'] = self.user_url @@ -675,22 +647,10 @@ # render the template template = self.loader.load('blog.html') return template.generate(**data).render() - -# # XXX no need to pass path or user! -# retval = StringIO() -# print >> retval, self.navigation(user, blog, path, n_links, 0) -# for entry in blog: -# print >> retval, self.blog_entry(request, user, entry) -# feedtitle=None -# if request.path_info.strip('/') == user: -# feedtitle = "%s's blog" % user -# title = None -# if len(blog) == 1: -# format = request.user.settings.get('Date format', self.date_format) -# title = blog[0].date.strftime(format) -# return self.render(request, retval.getvalue(), title=title, feedtitle=feedtitle) def restructuredText(self, string): + """renders a string with restructured text""" + origstring = string settings = { 'report_level': 5 } string = string.strip() diff -r 2bd6b2b543dc -r e5cbc53cacf8 bitsyblog/templates/blog.html --- a/bitsyblog/templates/blog.html Sun Oct 25 18:11:25 2009 -0400 +++ b/bitsyblog/templates/blog.html Sun Oct 25 18:35:48 2009 -0400 @@ -8,11 +8,11 @@ ${user} - ${site_name} - - + + title="${sheet}"/> @@ -28,7 +28,7 @@ more diff -r 2bd6b2b543dc -r e5cbc53cacf8 bitsyblog/user.py --- a/bitsyblog/user.py Sun Oct 25 18:11:25 2009 -0400 +++ b/bitsyblog/user.py Sun Oct 25 18:35:48 2009 -0400 @@ -97,9 +97,10 @@ css_files.insert(0, css_files.pop(index)) except ValueError: pass - return [ dict(filename=i, name=i.rsplit('.css',1)[0], - css=file(os.path.join(css_dir, i)).read()) - for i in css_files ] + retval = [ dict(filename=i, name=i.rsplit('.css',1)[0], + css=file(os.path.join(css_dir, i)).read()) + for i in css_files ] + return retval ### interfaces for BitsyUsers