You are not logged in Log in Join
You are here: Home » Members » d2m » ReStructuredText Document for CMF » howto_view

Log in
Name

Password

 

ReStructuredText Document for CMF

 

Created by d2m . Last modified 2005-01-02 08:39:45.

reStructuredText is included now with the Zope2.7 release. The CMFDocument supports 'plain', 'structured-text' and 'html' - formatted content. By repurposing the 'Document' portal type we can easily use reStructedText with our content.

How To Use reStructuredText With CMF ( up to CMF1.4.x )

Enter portal_types tool and create a new portal type CMFreStructuredDocument, e.g.

copy/paste the Document type and rename it

or select Factory-based Type Information from the pull-down menue with

  • Id: CMFreStructuredDocument
  • Use default type information: CMFDefault:Document

back in the portal_types tool open CMFreStructuredDocument and select the 'Actions" tab

edit the Action expressions for View and Edit to select a different page template then the original Document, e.g.

  • View / Action: string:${object_url}/rst_document_view
  • Edit / Action: string:${object_url}/rst_document_edit_form

your done with the type creation - adjust the templates now:

  • customize zpt_content/document_view to custom/rst_document_view
  • customize zpt_content/document_edit_form to custom/rst_document_edit_form

edit the new page templates:

  • custom/rst_document_view

    we are rendering the plain body text as reStructuredText :

        change
        < div tal:replace="structure here/CookedBody">Cooked Body< /div>
    
        to
        < div tal:define="rest_txt here/EditableBody" 
              tal:replace="structure  
              python:modules['Products.PythonScripts.standard'].restructured_text(rest_txt)">
              Body< /div>
    

  • custom/rst_document_edit_form

    we only need the body text to be handled as plain text :

        change
        < input type="radio" name="text_format" value="structured-text" id="cb_stx"
                tal:attributes="
                checked python:path('here/text_format')=='structured-text'" />
        < label for="cb_stx" i18n:translate="">structured-text</label>
        < input type="radio" name="text_format" value="plain" id="cb_plain"
                tal:attributes="checked python:path('here/text_format')=='plain'" />
        < label for="cb_plain" i18n:translate="">plain text</label>
        < input type="radio" name="text_format" value="html" id="cb_html"
                tal:attributes="checked python:path('here/text_format')=='html'" />
        < label for="cb_html" i18n:translate="">html</label>
    
        to
        < input type="hidden" name="text_format" value="plain" id="cb_plain"
                checked />
        < label for="cb_plain" i18n:translate="">ReStructured text< /label>
    

enter your content space, add a new CMFreStructuredDocument object to a folder and insert some text.

Links:

Docutils: Python Documentation Utilities
The purpose of the Docutils project is to create a set of tools for processing plaintext documentation into useful formats, such as HTML, XML, and TeX.
DocFactory Editor
DocFactory is a kind of integrated publishing environment for documentation, tied to Docutils. In fact, the intention of DocFactory is to be a GUI for Docutils. At present it can be used to edit a set of one or more reStructuredText files simultaneously and publish them as HTML. Support for other markups and output formats is planned for future releases.
Comment

Discussion icon Typo for first fix...

Posted by: zot at 2004-05-06

The document_view_form (zope 2.7.0) line to be changed has no ending div tag, it does a />. So do not grab the ending div tag (< /div>) (no space in code) on the next line....