Skip to content

Rhaptos Software Development

Personal tools
You are here: Home » Developer Blog » Brian's Sooth » Module Web Rendering Pipeline

Module Web Rendering Pipeline Module Web Rendering Pipeline

Document Actions
Submitted by bnwest. on 2009-05-27 14:51. DevelopmentDocumentation
Discussion of how CNX module get rendered for browsers.

Here is a rough outline of the moving pieces that we use to render HTML for our modules:

  1. The default action for a ModuleView object is to call index_html() (Zope/Plone convetion, the python convention is __call__()).  index_html() calls the defualt() method.
  2. ModuleView::default() calls self.module_render().  See RhaptosModuleStorage/ModuleView.py.
  3. module_render is not a member of the ModuleView class.  Its source is located dynamically by acquisition.
  4. CNXPloneSite/skins/cnx_overrides/module_render.py
    1. Add the course parameters to kw[].
    2. source = context.module_export_template(**kw).
    3. kw['stylesheet'] = MODULE_XSL (which is content_render.xsl)
    4. body = context.cnxml_transform(source, **kw)
    source is an XML string which contains the module's metadata and CNXML.
  5. CNXMLDocument/skins/CNXMLFile/cnxml_transform.py
    1. stylesheets = [stylesheet]
    2. parse the source: doc = XMLService.parseString(source)
    3. extract a list of document namespaces
    4. set sensible defaults for params['doctype'] and params['mimetype'] and ns (xhtml namespace)
    5. use browser specific logic to change the above three parameters so that MathML gets correctly displayed
    6. if MathML is not supported in the browser, add pmathmlcss.xs to stylesheets[].l
    7. RAINMAKER: result = XMLService.xsltPipeline(doc, stylesheets, **params)
    8. set the mimetype and charset for the REQUEST response header
    9. header = context.xmlheader(params['doctype'])
    10. return header+'\n'+result
    pmathmlcss.xsl will transform P-MathML into HTML styled with CSS and is only added to the XSLT pipeline when the target browser does not support displaying MathML.

    CNXML plus module metadata will be transformed into HTML and placed into result.
  6. RhaptosContent/www/content_render.xsl imports cnxml/style/cnxml_render.xsl.
    TBD: The labor breakout bewteen content_render.xsl and cnxml_render.xsl.
  7. cnxml/style/cnxml_render.xsl includes/imports
    • CNXMLDocument/www/ident.xsl
    • cnxml/style/cnxmll10n.xsl
    • mathml2/style/cnxmathmlc2p.xsl (originally from Xerox circa 2001)
    • bibtexml/style/bibtexml.xsl
    • qml/style/qml.xsl
    • cnxml/style/table.xsl
    • cnxml/style/media.xsl

    cnxmathmlc2p.xsl transforns Content-MathML into Presentation-MathML. The browsers, Firefox and IE with MathPlayer plugin, can display Presentation-MathML; all other browsers can not.  No browser can display Content-MathML.

    cnxmathmlc2p.xsl was made to run stand alone, but we only wanted one XSLT for converting CNXML, so we included it into our "master" XSLT instead of making it its own stage in the pipeline.

In addition to the HTML served to the browser for a module, other files are served as well.

Images are served from our site as well as others.  Images with relative addresses in their links are server from our site with the module's context.

We serve CSS files, which include one for the browser (@media='screen') and one for browser print via Cntl-p (@media='print').  (As an aside hopefully users interested in printing their modules will print via our supplied PDF versus directly via the browser's Cntl-p.)


JavaScript files are also served.

Our web site is designed to support browsers which do not include JavaScript support. We set a cookie when JavaScript is supported, which is passed along with server requests. When rendering a module, some of the portlets surrounding the module content (CNXML) uses JavaScript if available. A reasonable default is substituted when JavaScript is not available.


To see what module_export_template produces, add 'module_export_template' to the URL, e.g.

http://cnx.org/content/m9004/latest/module_export_template


Re: Module Web Rendering Pipeline

Posted by jccooper at 2009-05-28 18:15
ModuleView's default, like all Zope objects, is 'index_html'. It handles end-slash redirect, if necessary, otherwise calls 'default'.

'default' calls 'module_render', a skin script, which is acquired, eventually, from the skins tool. A CNX site gets the over-ride one from CNXPloneSite, but a Rhaptos site will get the one from RhaptosSite.