incubator-bloodhound-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matevz Bradac <mate...@gmail.com>
Subject Re: Genshi XHTML + HTML 5
Date Mon, 03 Dec 2012 21:54:25 GMT
Hi,

Below is a patch for the doctype changes in trac and Bloodhound. I
added a new class variable (default_html_doctype)
to trac's Chrome, which defaults to XHTML Strict and is overridden to
HTML5 in the BloodhoundTheme.


Index: bloodhound_theme/bhtheme/theme.py
===================================================================
--- bloodhound_theme/bhtheme/theme.py	(revision 1416651)
+++ bloodhound_theme/bhtheme/theme.py	(working copy)
@@ -18,6 +18,7 @@

 from genshi.builder import tag
 from genshi.filters.transform import Transformer
+from genshi.output import DocType

 from trac.core import *
 from trac.mimeview.api import get_mimetype
@@ -31,7 +32,7 @@
 from trac.versioncontrol.web_ui.browser import BrowserModule
 from trac.web.api import IRequestFilter, IRequestHandler, ITemplateStreamFilter
 from trac.web.chrome import (add_script, add_stylesheet,
INavigationContributor,
-                             ITemplateProvider, prevnext_nav)
+                             ITemplateProvider, prevnext_nav, Chrome)

 from themeengine.api import ThemeBase, ThemeEngineSystem

@@ -118,6 +119,8 @@
     implements(IRequestFilter, INavigationContributor, ITemplateProvider,
                ITemplateStreamFilter)

+    Chrome.default_html_doctype = DocType.HTML5
+
     # ITemplateStreamFilter methods

     def filter_stream(self, req, method, filename, stream, data):
Index: trac/trac/web/chrome.py
===================================================================
--- trac/trac/web/chrome.py	(revision 1416651)
+++ trac/trac/web/chrome.py	(working copy)
@@ -479,6 +479,9 @@

     templates = None

+    #default doctype for 'text/html' output
+    default_html_doctype = DocType.XHTML_STRICT
+
     # A dictionary of default context data for templates
     _default_context_data = {
         '_': translation.gettext,
@@ -936,8 +939,8 @@

         The `content_type` argument is used to choose the kind of template
         used (`NewTextTemplate` if `'text/plain'`, `MarkupTemplate` otherwise),
-        and tweak the rendering process (use of XHTML Strict doctype if
-        `'text/html'` is given).
+        and tweak the rendering process. Doctype for `'text/html'` can be
+        specified by setting the default_html_doctype (default is XHTML Strict)

         When `fragment` is specified, the (filtered) Genshi stream is
         returned.
@@ -975,7 +978,7 @@
             stream.render('text', out=buffer, encoding='utf-8')
             return buffer.getvalue()

-        doctype = {'text/html': DocType.XHTML_STRICT}.get(content_type)
+        doctype = {'text/html': Chrome.default_html_doctype}.get(content_type)
         if doctype:
             if req.form_token:
                 stream |= self._add_form_token(req.form_token)

--
matevz

On Mon, Dec 3, 2012 at 5:01 PM, Olemis Lang <olemis@gmail.com> wrote:
> On 12/3/12, Matevz Bradac <matevzb@gmail.com> wrote:
>> Hi,
>>
>> Great, thanks for all the suggestions. =)
>
> :)
>
>> I'll start working on trac changes then,
>
> good
>
>> it would make more sense to
>> make trac itself more configurable
>> than to create workarounds within bloodhound (and possibly other
>> projects based on trac).
>>
>
> In this case you've proven it's worthy .
>
> FWIW I share some ideas for you to consider :
>
>   1. to move doctype selection dict and make it become
>       a class or instance method that can be easily changed
>       at run-time.
>   2. add doctype param to render_template
>
>
> --
> Regards,
>
> Olemis.
>
> Blog ES: http://simelo-es.blogspot.com/
> Blog EN: http://simelo-en.blogspot.com/
>
> Featured article:

Mime
View raw message