On 21 July 2013 15:29, Paul Boddie <p...@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',
            'somejs':/server/path/to/somejs.js',
            'somecss':'/filesystem/path/to/somecss.css'}

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

        if src.endswith('js'):
            html += '<script type="text/javascript" src="%s"></script>' %
src
        else:
            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.

Jim
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Moin-user mailing list
Moin-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/moin-user

Reply via email to