Work in progress - yet incomplete

Proposal: Page Fragment Context Editing

Note: This proposal is closely linked to the ProposalXIncludeAggregation but might be valid in other scenarios as well.

Understanding the need

If you implement the ProposalXIncludeAggregation (or use a different way to aggregate page fragements from different files into one page) you need a way to edit the individual page fragment.

(Be a bit more verbose here.)

Implementing

The Context Menu

In file lenya/pubs/<your-pub>/xslt/xhtml2xhtml.xsl:

    <xsl:if test="$area != 'live'" >
    <p>This is only visible if not live:<br/>
    rendertype: <xsl:value-of select="$rendertype" /><br/>
    nodeid: <xsl:value-of select="$nodeid" /><br/>
    area: <xsl:value-of select="$area" /><br/>
    documenturl: <xsl:value-of select="$documenturl" /><br/>
    document-url: <xsl:value-of select="$document-url" /><br/>
    server-uri: <xsl:value-of select="$server-uri" /><br/>
    document-path: <xsl:value-of select="$document-path" /><br/>
    </p>
    <p><a href="{$server-uri}{$document-path}.xml?&amp;lenya.event=edit&amp;lenya.usecase=kupu&amp;lenya.step=open">Edit</a></p>
    </xsl:if>

Usecases for editing page fragments

(All these changes go into usecase.xmap)

            <map:match pattern="*/authoring/**.xml">
              <!-- Check for Kupu-->
              <map:act type="resource-exists" src="resources/kupu/common/kupueditor.js">

                <map:act type="reserved-checkout">
                  <map:generate type="serverpages" src="content/rc/{exception}.xsp">
                    <map:parameter name="user" value="{user}"/>
                    <map:parameter name="filename" value="{filename}"/>
                    <map:parameter name="date" value="{date}"/>
                    <map:parameter name="message" value="{message}"/>
                  </map:generate>
                  <map:transform src="xslt/rc/rco-exception.xsl"/>
                  <map:call resource="style-cms-page"/>
                </map:act>

                <map:generate src="resources/kupu/apache-lenya/kupumacros.html"/>
                <map:transform src="resources/kupu/apache-lenya/kupumacros-xhtml.xsl">
                  <map:parameter name="contentfile" value="{page-envelope:context-prefix}/{../1}/authoring/{../2}.xml?lenya.usecase=kupu&amp;lenya.step=content"/>
                  <map:parameter name="context" value="{request:contextPath}"/>
                  <map:parameter name="document-path" value="{page-envelope:document-path}"/>
                  <map:parameter name="root" value="{page-envelope:context-prefix}"/>
                  <map:parameter name="save-destination" value="{page-envelope:context-prefix}/{../1}/authoring/{../2}.xml?lenya.usecase=kupu&amp;lenya.step=save"/>
                  <map:parameter name="reload-on-save" value="0"/> <!-- 1 means you can see the saving -->
                  <map:parameter name="use-css" value="1"/>
                  <map:parameter name="redirect-to" value="{page-envelope:document-name}.html"/>
                </map:transform>
                <map:serialize type="html"/>
              </map:act>
              <map:generate src="resources/misc/kupu/download.xhtml"/>
              <map:call resource="style-cms-page"/>
            </map:match>
          </map:match>

          <map:match pattern="content" type="step">
            <map:match pattern="*/authoring/**.xml">
              <map:generate src="pubs/{1}/content/authoring/{2}.xml"/>
              <map:transform src="resources/kupu/apache-lenya/kupucontent-xhtml.xsl">
                <map:parameter name="css" value="{page-envelope:context-prefix}/{1}/authoring/css/page.css"/>
              </map:transform>
              <map:transform src="xslt/util/strip_namespaces.xsl"/>
                <!-- <map:serialize type="xml"/> -->
                 <map:serialize type="xhtml"/>
            </map:match>
          </map:match>

                <map:act type="reserved-checkin">
                  <map:generate src="content/rc/{exception}.xsp" type="serverpages">
                    <map:parameter name="user" value="{user}"/>
                    <map:parameter name="filename" value="{filename}"/>
                    <map:parameter name="checkType" value="{checkType}"/>
                    <map:parameter name="date" value="{date}"/>
                    <map:parameter name="message" value="{message}"/>
                  </map:generate>
                  <map:transform src="xslt/rc/rco-exception.xsl"/>
                  <map:serialize/>
                </map:act>

                <!-- BEGIN CHANGED -->

                <map:match pattern="*/authoring/**.xml">
                  <map:transform src="xslt/authoring/edit/addSourceTags.xsl">
                    <map:parameter name="source" value="pubs/{page-envelope:publication-id}/content/authoring/{2}.xml"/>
                  </map:transform>
                  <map:transform type="write-source"/>
                </map:match>

                <map:match pattern="*/authoring/**.html">
                  <map:transform src="xslt/authoring/edit/addSourceTags.xsl">
                    <map:parameter name="source" value="pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}"/>
                  </map:transform>
                  <map:transform type="write-source"/>
                </map:match>

                <!-- END CHANGED -->

                <!-- Trigger workflow with *edit* action -->
                <map:act type="workflow">
                  <map:parameter name="area" value="{page-envelope:area}"/>
                  <map:parameter name="document-id" value="{page-envelope:document-id}"/>
                  <map:parameter name="language" value="{page-envelope:document-language}"/>
                  <map:parameter name="event" value="edit"/>
                </map:act>

Open Issues

See also:

ProposalPageFragmentEditing (last edited 2009-09-20 23:27:18 by localhost)