Permalink
Browse files

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
  • Loading branch information...
1 parent 5d8c324 commit 2efc03456f342499a80bf9a2b2cb021f2dc04f77 @ejucovy ejucovy committed Aug 19, 2012
Showing with 35 additions and 14 deletions.
  1. +12 −11 lightertheme/__init__.py
  2. +23 −3 lightertheme/htdocs/theme.css
View
@@ -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
@@ -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;

0 comments on commit 2efc034

Please sign in to comment.