Relative path in HTML Fragment Extension Parameters?

Post here questions and problems related to editing and publishing DITA content.
kgajda
Posts: 32
Joined: Wed Aug 16, 2017 8:07 pm

Relative path in HTML Fragment Extension Parameters?

Post by kgajda »

I sent this question in to Support and never get a reply so hoping I can crowdsource an answer or workaround:

I have been updating our plugins to move to the latest DITA-OT, and in this version, rather than mucking about in the Oxygen templates, I injected each bit we wanted to add (like code for analytics and links to javascript) using the HTML Fragment Extension Parameters like (in build.xml)

Code: Select all

<!-- INJECTING STRINGS INTO FRAGMENTS -->
        <property name="webhelp.fragment.head" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/GA_and_css.xml"/> 
        <property name="webhelp.fragment.head.topic.page" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/ZOOMRESTART.xml"/> 
        <property name="webhelp.fragment.before.body.topic.page" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/ZOOMSTOP.xml"/> 
        <property name="webhelp.fragment.after.publication.toc" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/ZOOMRESTART.xml"/> 
        <property name="webhelp.fragment.after.feedback" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/ZOOMSTOP.xml"/>
        <property name="webhelp.fragment.after.body" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/closing_js.xml"/>
        <property name="webhelp.fragment.footer" value="${dita.plugin.com.altair.webhelp.responsive.streamlined.dir}/altair-resources/xml/footer_st.htm"/>
        <property name="webhelp.fragment.after.logo_and_title" value="${webhelp.prod.version}"/>  
We have come up against a problem though, with the closing_js.xml that is being inserted after the body having relative paths to the js folder, but depending on where the page is inside the help, the static path is not correct (needs a few ../../ for example, if the topic is several layers down). I tried adding ${output.dir} before it, but it didn’t resolve. Is there a way to make these truly relative? Or do you have another suggestion?
image.png
image.png (296.87 KiB) Viewed 418 times
contents of closing_js.xml:

Code: Select all

<script src="${oxygen-webhelp-assets-dir}/lib/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<script  type="text/javascript" src="altair-resources/js/bootstrap-toc.js"></script>
<script type="text/javascript" src="altair-resources/js/breadcrumbs.js"></script>
<script type="text/javascript" src="altair-resources/js/splash.js"></script>
<script type="text/javascript" src="altair-resources/js/homepage.js"></script>
<script type="text/javascript" src="altair-resources/js/topics.js"></script>
<script type="text/javascript" src="altair-resources/js/googleAnalytics.js"></script>
<script type="text/javascript" src="altair-resources/js/offlinecheck.js"></script>
<script type="text/javascript" src="altair-resources/js/moreoptions.js"></script>
<script type="text/javascript" src="altair-resources/js/collapsibles.js"></script>
<script type="text/javascript" src="altair-resources/js/version-navigator.js"></script>
Edited to add: Looking for something like "${oxygen-webhelp-assets-dir}/" from the first line , have tried preprending the paths with "${PATH2PROJ}/" and "${output.dir}/", but they are not resolved.
kgajda
Posts: 32
Joined: Wed Aug 16, 2017 8:07 pm

Re: Relative path in HTML Fragment Extension Parameters?

Post by kgajda »

I found a solution. Adding ${oxygen-webhelp-output-dir}/ to the paths does it.
xephon
Posts: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: Relative path in HTML Fragment Extension Parameters?

Post by xephon »

Thank you for posting the solution here. We have the same problem.
stefan-jung.org – Your DITA/DITA-OT XML consultant
beniamin_savu
Posts: 31
Joined: Fri Jan 22, 2021 11:05 am

Re: Relative path in HTML Fragment Extension Parameters?

Post by beniamin_savu »

Hi,

Please note that we replied to your email on October 26.

The email may have ended-up in your Spam/Junk folders, so we suggest to double check those ones too.
If you cannot find our email at all, then you should reach to the system administrator in your company, as they may be using third party spam filtering software deployed in your company email, which incorrectly considers the emails from us as spam and filters them from reaching your inbox.

In the email we also attached a zip file containing a publishing template example. It could be possible that your email server blocks emails that contain attachments?

I will copy the message from the email sent on October 26:
To customize the WebHelp Responsive output we recommend to use the Publishing Templates. More details about the Publishing Templates can be found using the following links:
https://www.oxygenxml.com/doc/versions/ ... plate.html
https://www.oxygenxml.com/doc/versions/ ... llery.html
https://www.oxygenxml.com/doc/versions/ ... tents.html

Using the publishing template you can create the altair-resources/js folder structure and add all your js files in that folder. You can also have a folder named html-fragments where you will have all the html-fragments files. Your publishing template should look something like this:
dRiLbL0PWZ2NUKvd.png
dRiLbL0PWZ2NUKvd.png (16.28 KiB) Viewed 364 times
In the publishing template descriptor file (the .opt file) you will need to specify that the files inside the altair-resources folder should to be copied to the output folder. Also you will need to specify the HTML fragment to inject in the output pages using the <html-fragment> element.
xE6BoTefjLk7qEJj.png
xE6BoTefjLk7qEJj.png (87.1 KiB) Viewed 364 times
Using the Publishing Template you can set all the transformation parameters that you need in the <parameters> element. Also you can use the Publishing Template to insert all you HTML fragments. In this sample Publishing Template I showcased how to insert only one fragment.

I attached this sample publishing template that inserts the js files at the end of the body for every HTML page in the WebHelp Responsive output. The js files only print some messages in the browser console. Running the WebHelp Responsive transformation with this publishing template you will see that the JavaScript files are executed on every page of the output. You can use it to further customize it according to your needs.
The Publishing Template sample can be obtained from the follwoing link:
altair-template-example.zip
(373.79 KiB) Downloaded 48 times
WebHelp Responsive offers the possibility to insert specific macros when inserting custom content using the HTML fragments. For example:
* oxygen-webhelp-output-dir - The path to the output directory. The path is relative to the current HTML file.
* oxygen-webhelp-assets-dir - The path to the oxygen-webhelp subdirectory from the output directory. The path is relative to the current HTML file.
* oxygen-webhelp-template-dir - The path to the template directory. The path is relative to the current HTML file.
More details can be found using the following link: https://www.oxygenxml.com/doc/versions/ ... -html.html

Best regards,
Beniamin Savu
Oxygen WebHelp Team
http://www.oxygenxml.com
Post Reply