From 2efc03456f342499a80bf9a2b2cb021f2dc04f77 Mon Sep 17 00:00:00 2001 From: Ethan Jucovy Date: Sun, 19 Aug 2012 11:11:23 -0400 Subject: [PATCH] don't use cut/paste/buffer -- it seems to break trac's add_stylesheet() for subsequent plugins. instead, use two banner_wrapper divs, and use css tricks to merge them visually into a single block --- lightertheme/__init__.py | 23 ++++++++++++----------- lightertheme/htdocs/theme.css | 26 +++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/lightertheme/__init__.py b/lightertheme/__init__.py index 9ca54c7..8205f36 100644 --- a/lightertheme/__init__.py +++ b/lightertheme/__init__.py @@ -10,21 +10,22 @@ from trac.web.api import IRequestFilter, ITemplateStreamFilter class Theme(Component): - implements(IRequestFilter, ITemplateStreamFilter, ITemplateProvider) - - def pre_process_request(self, req, handler): - add_stylesheet(req, 'http://fonts.googleapis.com/css?family=Ubuntu') - add_stylesheet(req, 'lightertheme/theme.css') - return handler - - def post_process_request(self, req, template, data, content_type): - return template, data, content_type + implements(ITemplateStreamFilter, ITemplateProvider) def filter_stream(self, req, method, filename, stream, data): """ Wrap the banner and mainnav in a single banner_wrapper div """ - buffer = StreamBuffer() + + add_stylesheet(req, 'http://fonts.googleapis.com/css?family=Ubuntu') + add_stylesheet(req, 'lightertheme/theme.css') + + stream |= Transformer("//div[@id='banner']").wrap(tag.div(class_="banner_wrapper banner_wrapper_first")) + stream |= Transformer("//div[@id='mainnav']").wrap(tag.div(class_="banner_wrapper banner_wrapper_second")) + stream |= Transformer("//div[@class='banner_wrapper banner_wrapper_first']").append(tag.hr()) + return stream + + filter = Transformer("//div[@id='banner']") stream |= filter.wrap(tag.div(id="banner_wrapper")).end( ).select("//div[@id='mainnav']").cut(buffer, accumulate=True).end().buffer( @@ -43,7 +44,7 @@ def get_htdocs_dirs(self): The `abspath` is the absolute path to the directory containing the resources on the local file system. """ - return [("lightertheme", resource_filename(__name__, 'htdocs'))] + yield "lightertheme", resource_filename(__name__, 'htdocs') def get_templates_dirs(self): """Return a list of directories containing the provided template diff --git a/lightertheme/htdocs/theme.css b/lightertheme/htdocs/theme.css index 6889f1f..25f6c39 100644 --- a/lightertheme/htdocs/theme.css +++ b/lightertheme/htdocs/theme.css @@ -1,10 +1,10 @@ -#banner_wrapper { +.banner_wrapper { width: 1200px; margin-left: auto; margin-right: auto; background-color: #eef; - -mox-border-radius: 10px; + -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; background-clip: padding-box; @@ -14,9 +14,29 @@ padding-right: 10px; padding-bottom: 10px; } -#banner_wrapper hr { +.banner_wrapper hr { margin: 0; } +.banner_wrapper_first { + margin-bottom: 5px; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; + -webkit-border-bottom-left-radius: 0px; + -webkit-border-bottom-right-radius: 0px; + -moz-border-bottom-left-radius: 0px; + -moz-border-bottom-right-radius: 0px; +} +.banner_wrapper_second { + padding-top: 0px; + margin-top: -10px; + border-top-left-radius: 0px; + border-top-right-radius: 0px; + -webkit-border-top-left-radius: 0px; + -webkit-border-top-right-radius: 0px; + -moz-border-top-left-radius: 0px; + -moz-border-top-right-radius: 0px; +} + #main { width: 940px; margin-left: auto;