Insert ate in webhelp output

Post here questions and problems related to editing and publishing DITA content.
urbanrobots
Posts: 86
Joined: Sun May 03, 2015 7:34 pm
Location: San Francisco

Insert ate in webhelp output

Post by urbanrobots »

Hi,
Is there a variable to capture the date that a file was last edited to show it in output? I guess the published date would also be ok.

Thanks,
-Nicholas
alin
Site Admin
Posts: 268
Joined: Thu Dec 24, 2009 11:21 am

Re: Insert ate in webhelp output

Post by alin »

Hello,

The WebHelp Responsive System provides various placeholders where you can include custom content in the output via transformation parameters.
You cand find the complete list of predefined placeholders here:
https://www.oxygenxml.com/doc/ug-editor ... ation.html

For example, if you want to add the publishing date in the footer of your HTML pages, you will have to edit the transformation scenario and set the webhelp.fragment.footer parameter to ${date(yyyy-MM-dd)}.

Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Insert ate in webhelp output

Post by shudson310 »

I have the same need to insert the publication date. I tried setting

Code: Select all

<param name="webhelp.fragment.footer"
desc="Specifies the path to the HTML file that contains the content for the WebHelp footer. It can also be an XML fragment."
type="file">
<val default="true">${date(yyyy-MM-dd)}
</val>
</param>
But it does not evaluate it as a variable? How are you supposed to insert the current date?

I have also tried using:

Code: Select all

<xsl:value-of select="format-date(current-date(), '[D01] [MNn,3-3] [Y0001]')"/>
but cannot find the proper place to override the default footer to insert this.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Insert ate in webhelp output

Post by shudson310 »

btw, this is using the webhelp-responsive plugin on oxygen 18.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Insert ate in webhelp output

Post by shudson310 »

nvrmind. setting the transform scenario as described works!
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
urbanrobots
Posts: 86
Joined: Sun May 03, 2015 7:34 pm
Location: San Francisco

Re: Insert ate in webhelp output

Post by urbanrobots »

Hi Alin,
Sorry for the late reply. So, we can add the current date no problem. The issue is how to capture the date that a file was modified. Thoughts? We'd like each HTML page to have the date a file was modified so that engineers know how out-of-date the content is. If it's just the published date, then all files look equally up-to-date.

Thanks!
-Nicholas
alin
Site Admin
Posts: 268
Joined: Thu Dec 24, 2009 11:21 am

Re: Insert ate in webhelp output

Post by alin »

Hello,

There might be a solution for your use case but you should store your DITA project on a SVN repository.

You will have to declare a custom meta data property in each topic file with the value set to "$Date$". For example:

Code: Select all


<topic id="topic1">
<title>Topic 1</title>
<prolog>
<metadata>
<othermeta name="last-changed" content="$Date$"/>
</metadata>
</prolog>
<body>
<p></p>
</body>
</topic>
The version control system will replace the $Date$ keyword with the last time the file was known to have been changed in the repository. For example:

Code: Select all

$Date: 2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006) $
To enable the version control system to process the $Date$ keyword in a file, you should set the svn:keywords property to "Date" for that file.
You can read more about SVN keywords here: http://svnbook.red-bean.com/en/1.7/svn. ... words.html

The custom meta data property will be transferred in the output HTML file as follows:

Code: Select all


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
............................................................
<meta name="last-changed" content="$Date: 2017-03-14 15:02:16 +0200 (Tue, 14 Mar 2017) $" />
.......................
</head>
..............................................................
</html>
You can now contribute a custom JavaScript code that reads the information from the meta element and inserts it in the footer section.
You can use the following JavaScript snippet as a starting point:

Code: Select all


var date = $('meta[name=last-changed]').attr('content');
$('.footer-container').text(date);
The procedure can be found here: https://www.oxygenxml.com/doc/versions/ ... -html.html

You can use the XML Refactoring Tool to insert the metadata content into your DITA topics (see the Insert XML Fragment operation).

Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
catherine
Posts: 158
Joined: Fri Nov 10, 2017 8:16 am

Re: Insert ate in webhelp output

Post by catherine »

Hi,
Is there any way to insert the Oxygen default variable ${date(yyyy-MM-dd)} in my customized html fragment?

I need to insert a date&time in each topic page, after I generate the webhelp, this date& time should be displayed on all the topic pages.

Can I use the variable ${date(yyyy-MM-dd)} ?
If yes, how to insert the variable in my html fragment?
If not, should I need to add a customized variable, and insert to my html fragment, and how?

Thanks!
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Insert ate in webhelp output

Post by radu_pisoi »

Hi,

Oxygen editor variables, like ${date(yyyy-MM-dd)}, are not available in WebHelp HTML fragments.

Instead, you can use one of the available webhelp macros. For the current case, you can use the $timestamp macro:

Code: Select all

<div class="generation_time">
        <whc:macro value="${timestamp([h1]:[m01] [P] [M01]/[D01]/[Y0001])}"/>.
</div>
You can find a sample publishing template that appends the current date in the output footer using the $timestamp macro here:
https://github.com/oxygenxml/oxygen-pub ... ith-macros
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
catherine
Posts: 158
Joined: Fri Nov 10, 2017 8:16 am

Re: Insert ate in webhelp output

Post by catherine »

Hi, Radu
Thanks for your help.
I tested the webhelp macro on both Oxygen V20 and Oxygen V21.
Seems the macro is not supported on Oxygen V20.

And, For Oxygen V21, still has a problem.
I set my html fragment as the following :

Code: Select all

<div xmlns:whc="http://www.oxygenxml.com/webhelp/components">
  <div class="generation_time">
                    Update Time: <whc:macro value="${timestamp([Y0001]-[M01]-[D01])}"/>
                    </div>        
</div> 
If I set the webhelp.fragment.footer to the HTML fragment, it works, and the date and time was displayed!! That's awesome!

And then, I tried to copy the codes to the page template wt_topic.html, and published webhelp using my customized template.
The date and time was displayed on each topic page.
However, the index page, search page, and term page in the published webhlep folder were blank!
I went to check my page templates, the wt_search.html, wt_terms.html, and wt_index.html, the page templates were not blank.
I guess the macro defined in the wt_topic.html would affect the other page templates.

Is there any way to fix it?

Regards,
Catherine
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Insert ate in webhelp output

Post by radu_pisoi »

Hi,
catherine wrote: Mon Dec 30, 2019 3:38 pm Seems the macro is not supported on Oxygen V20.
The WebHelp Responsive macros are available starting with 20.1 version, see What's New in Oxygen XML Webhelp 20.1.
catherine wrote: Mon Dec 30, 2019 3:38 pm If I set the webhelp.fragment.footer to the HTML fragment, it works, and the date and time was displayed!! That's awesome!
This is the recommended method to modify the content of the generated HTML files. By modifying the page template files, you will not benefit for the changes we make in the template files when you update the WebHelp plugin.
catherine wrote: Mon Dec 30, 2019 3:38 pm However, the index page, search page, and term page in the published webhlep folder were blank!
I went to check my page templates, the wt_search.html, wt_terms.html, and wt_index.html, the page templates were not blank.
We are not aware of a such issue. Could you send us on support@oxygenxml.com a test publishing template to reproduce the issue?
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
catherine
Posts: 158
Joined: Fri Nov 10, 2017 8:16 am

Re: Insert ate in webhelp output

Post by catherine »

Hi, Radu
Thanks for your help and advise!
I will check my templates again.
Post Reply