Edgewall Software
Modify

Opened 18 years ago

Closed 17 years ago

#2873 closed enhancement (worksforme)

Provide "alternate stylesheets"

Reported by: anonymous Owned by: Jonas Borgström
Priority: normal Milestone:
Component: general Version: 0.9.2
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

It would be great if Trac provided alternate stylesheets in its generated html. (I didn't see anything similar in 0.9.4)

Here's a patch against trac-0.9.2/trac/web/chrome.py:

--- chrome.py.orig      2005-12-05 13:20:16.000000000 -0500
+++ chrome.py   2006-03-14 10:42:59.000000000 -0500
@@ -51,6 +51,15 @@
         href = Href(req.cgi_location).chrome
     add_link(req, 'stylesheet', href(filename), mimetype=mimetype)
 
+def add_alt_stylesheet(req, filename, mimetype='text/css'):
+       """Add a linke to an alternate stylesheet
+       """
+       if filename.startswith('common/') and 'htdocs_location' in req.hdf:
+               href = Href(req.hdf['htdocs_location'])
+               filename = filename[7:]
+       else:
+               href = Href(req.cgi_location).chrome
+       add_link(req, 'alternate stylesheet', href(filename), title='alt style', mimetype=mimetype)
 
 class INavigationContributor(Interface):
     """Extension point interface for components that contribute items to the
@@ -212,6 +221,7 @@
         add_link(req, 'search', self.env.href.search())
         add_link(req, 'help', self.env.href.wiki('TracGuide'))
         add_stylesheet(req, 'common/css/trac.css')
+        add_alt_stylesheet(req, 'common/css/trac-alt.css')
         icon = self.config.get('project', 'icon')
         if icon:
             if not icon.startswith('/') and icon.find('://') == -1:

Attachments (0)

Change History (7)

comment:1 by Emmanuel Blot, 18 years ago

Resolution: invalid
Status: newclosed

Alternate style sheets can be activated using and customizing the site_css.cs file.

comment:2 by anonymous, 18 years ago

Resolution: invalid
Status: closedreopened

Wrong. site_css.cs provides for a project specific style sheet. It does not provide an alternate style sheet as defined in HTML 4 / XHTML standard. Alternate style sheets are provided by content authors and allow for user selection via their browser. In order for an author to provide an alternate stylesheet, it must be linked to the document in a particularly <link> tag in the html. (Which in the case of Trac requires a patch like submitted above.)

comment:3 by Emmanuel Blot, 18 years ago

Ok, you're right, I misundertood the ticket description.

comment:4 by anonymous, 18 years ago

My fault. My initial description wasn't descriptive enough.

Thinking about it a bit more, this is a "nice to have feature". But, for this particular thing, where would one draw the line? One alternate stylesheet? Three? Twelve? Maybe, like in the patch, just add one, then in the docs (FAQ?) add a pointer to were to make the changes if the Trac admin wants more alternate stylesheets.

comment:5 by coderanger, 18 years ago

Sounds like it would be good to have as an option in trac.ini, just have a :-seperated list of files.

comment:6 by Christopher Lenz, 18 years ago

You still can add alternative style sheets using site_css.cs:

</style>
<link rel="alternate stylesheet" title="Cold Turkey" href="/path/to/stylesheet" type="text/css" />
<style type="text/css">

The hacky part is that you need to close and open the style tag to break out of the one contained in the master template.

comment:7 by Christian Boos, 17 years ago

Resolution: worksforme
Status: reopenedclosed

The above trick probably doesn't apply anymore, but now with Genshi it's possible to make more complex manipulations in the site.html file, see TracInterfaceCustomization#Trac0.11andabove.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.