Skip to content

Commit

Permalink
don't use cut/paste/buffer -- it seems to break trac's add_stylesheet…
Browse files Browse the repository at this point in the history
…() for subsequent plugins. instead, use two banner_wrapper divs, and use css tricks to merge them visually into a single block
  • Loading branch information
ejucovy committed Aug 19, 2012
1 parent 5d8c324 commit 2efc034
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
23 changes: 12 additions & 11 deletions lightertheme/__init__.py
Expand Up @@ -10,21 +10,22 @@
from trac.web.api import IRequestFilter, ITemplateStreamFilter from trac.web.api import IRequestFilter, ITemplateStreamFilter


class Theme(Component): class Theme(Component):
implements(IRequestFilter, ITemplateStreamFilter, ITemplateProvider) implements(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


def filter_stream(self, req, method, filename, stream, data): def filter_stream(self, req, method, filename, stream, data):
""" """
Wrap the banner and mainnav in a single banner_wrapper div 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']") filter = Transformer("//div[@id='banner']")
stream |= filter.wrap(tag.div(id="banner_wrapper")).end( stream |= filter.wrap(tag.div(id="banner_wrapper")).end(
).select("//div[@id='mainnav']").cut(buffer, accumulate=True).end().buffer( ).select("//div[@id='mainnav']").cut(buffer, accumulate=True).end().buffer(
Expand All @@ -43,7 +44,7 @@ def get_htdocs_dirs(self):
The `abspath` is the absolute path to the directory containing the The `abspath` is the absolute path to the directory containing the
resources on the local file system. resources on the local file system.
""" """
return [("lightertheme", resource_filename(__name__, 'htdocs'))] yield "lightertheme", resource_filename(__name__, 'htdocs')


def get_templates_dirs(self): def get_templates_dirs(self):
"""Return a list of directories containing the provided template """Return a list of directories containing the provided template
Expand Down
26 changes: 23 additions & 3 deletions lightertheme/htdocs/theme.css
@@ -1,10 +1,10 @@


#banner_wrapper { .banner_wrapper {
width: 1200px; width: 1200px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
background-color: #eef; background-color: #eef;
-mox-border-radius: 10px; -moz-border-radius: 10px;
-webkit-border-radius: 10px; -webkit-border-radius: 10px;
border-radius: 10px; border-radius: 10px;
background-clip: padding-box; background-clip: padding-box;
Expand All @@ -14,9 +14,29 @@
padding-right: 10px; padding-right: 10px;
padding-bottom: 10px; padding-bottom: 10px;
} }
#banner_wrapper hr { .banner_wrapper hr {
margin: 0; 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 { #main {
width: 940px; width: 940px;
margin-left: auto; margin-left: auto;
Expand Down

0 comments on commit 2efc034

Please sign in to comment.