Return-Path: X-Original-To: apmail-incubator-bloodhound-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EBEA3E0FC for ; Mon, 3 Dec 2012 21:55:32 +0000 (UTC) Received: (qmail 78096 invoked by uid 500); 3 Dec 2012 21:55:32 -0000 Delivered-To: apmail-incubator-bloodhound-dev-archive@incubator.apache.org Received: (qmail 78074 invoked by uid 500); 3 Dec 2012 21:55:32 -0000 Mailing-List: contact bloodhound-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bloodhound-dev@incubator.apache.org Delivered-To: mailing list bloodhound-dev@incubator.apache.org Received: (qmail 78063 invoked by uid 99); 3 Dec 2012 21:55:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2012 21:55:32 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URIBL_BLACK X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of matevzb@gmail.com designates 209.85.214.175 as permitted sender) Received: from [209.85.214.175] (HELO mail-ob0-f175.google.com) (209.85.214.175) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2012 21:55:27 +0000 Received: by mail-ob0-f175.google.com with SMTP id vb8so3002346obc.6 for ; Mon, 03 Dec 2012 13:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=bBrXInW5U8X057IuG8TgG+JZOqHBCNjb6bCGOTMZqME=; b=yCTYK+I0wuelb4LYkeNb401ir8lFTdrxmIZeQSCmSJON2xcChKGddadNvfTU0emEAM qZ3HCF87CbNHlMwR5xsfrjMfl7n4zGzCSR+v0u4uTvvd7+BCGZqP47cbCCkPdJizLs7G sWTWMUvNhKfNXHIfvj3Pcv164CYRDihWG/n3s2bd8J+iBaJ7XFPbnlWzmeqCJlYe5rdL WkDGhc+qY++QpkknQgGC4YPzqRWWxTGug7Qt2j4jZ/GJJLz5i02QnOj7t9plU0Y0GLnQ mFOE+OKm64vruP1mVlRYQOSC8nokcURDojdSP9jl326D0jlk2KnYKahhjmsts/QPIdxS E4Kg== Received: by 10.60.171.133 with SMTP id au5mr9554075oec.90.1354571707272; Mon, 03 Dec 2012 13:55:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.73.138 with HTTP; Mon, 3 Dec 2012 13:54:25 -0800 (PST) In-Reply-To: References: <2BA32F18-E010-433A-8E9F-359192ABA8F8@wandisco.com> From: Matevz Bradac Date: Mon, 3 Dec 2012 22:54:25 +0100 Message-ID: Subject: Re: Genshi XHTML + HTML 5 To: bloodhound-dev@incubator.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org 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 wrote: > On 12/3/12, Matevz Bradac 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: