Page 1 of 1

How to add author information in generated webhelp

Posted: Fri Jan 29, 2021 6:46 am
by catherine
Hi,
I found this page has author information (including author name, date and time) under the topic title.
https://blog.oxygenxml.com/topics/all_a ... _ons.html

"Contributed by: Radu Coravu on 2020-01-18"

How we can achieve this by Oxygen XML Editor.
Thanks.

Catherine
Best Regards

Re: How to add author information in generated webhelp

Posted: Fri Jan 29, 2021 10:49 am
by Radu
Hi Catherine,

The first side to this is to add the author name and modification time to the DITA topic when I create it:

Code: Select all

topic id="welcome">
    <title>Welcome to the <ph keyref="oxygen"/> Blog !</title>
    <prolog>
        <author>Radu Coravu</author>
        <copyright>
            <copyryear year="2020"/>
            <copyrholder>Syncro Soft</copyrholder>
        </copyright>
        <critdates>
            <created date="2020-01-14"/>
        </critdates>
For the Oxygen XML Blog I have a Schematron schema which reminds me to do that and a quick fix to quickly add this information to a newly created topic:

https://github.com/oxygenxml/blog/blob/ ... /rules.sch

Now for displaying this information in the WebHelp output, I'm using a publishing template which you can download from here, it's a zip file:
https://github.com/oxygenxml/blog/tree/ ... publishing

I pass a reference to this publishing template as a parameter to the WebHelp Responsive transformation:

https://github.com/oxygenxml/blog/blob/ ... roject.xml

More about publishing templates:
https://www.oxygenxml.com/doc/versions/ ... tents.html

Inside the "Oxygen XML Blog WebHelp Template.opt" from the zip I add a custom XSLT extension:

Code: Select all

<extension file="xslt/prolog-show.xsl" id="com.oxygenxml.webhelp.xsl.dita2webhelp"/>
which matches the DITA prolog element and generates an HTML <div> from it:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/prolog ')]">
        <div style="width:100%; text-align: right; font-style:italic; color:gray;">Contributed by: <xsl:value-of select="*[contains(@class, ' topic/author ')]"/>
            <xsl:if test="exists(.//*[contains(@class, ' topic/created ')]/@date)">
                on <xsl:value-of select=".//*[contains(@class, ' topic/created ')]/@date"/>    
            </xsl:if>
            </div>
    </xsl:template>
Regards,
Radu

Re: How to add author information in generated webhelp

Posted: Fri Jan 29, 2021 11:37 am
by catherine
Thanks so much, Radu. :D
We will try it.

Re: How to add author information in generated webhelp

Posted: Fri Jan 29, 2021 4:51 pm
by chrispitude
Hi catherine,

I recall there is also an Oxygen plugin that automates the creation/updating of this metadata:

https://github.com/oxygenxml/oxygen-dita-prolog-updater