On 21 July 2013 15:29, Paul Boddie <paul@boddie.org.uk> wrote:
On Sunday 21 July 2013 06:36:01 Emmanuel Mayssat wrote:
> I would like to change the style of headers for a subset of pages.
> How can I inject my css stylesheet in a particular page?

For all pages, you can obviously change the "stylesheets" configuration
setting like this (not tested):

  stylesheets = [("screen", "/css/mystyles.css")]

This augments the stylesheets mentioned in the theme class. See the ThemeBase
class in MoinMoin/theme/__init__.py for the default definitions.

To affect only some pages, it might be necessary to change the theme code or
to override a theme with extra code to insert references to styles and
scripts (with regard to your other question). 

How about using a macro for the some pages situation? E.g.

def macro_InjectJSorCSS(macro, _trailing_args=[]):

    args = {'jquery':'http://code.jquery.com/jquery.min.js',

    html = ''
    for arg in _trailing_args:
        src = args[arg]

        if src.endswith('js'):
            html += '<script type="text/javascript" src="%s"></script>' % src
            html += '<style type="text/css">' + open(src, 'r').read() + '</style>'

    return macro.formatter.rawHTML(html)

Thus, InjectJSorCSS(jquery,somejs,somecss)

The content of CSS files is injected into the page as the <link> statement is restricted to the head.