How I use the existing .js modules in customization temlate?

Post here questions and problems related to editing and publishing DITA content.
tmakita
Posts: 100
Joined: Fri Apr 08, 2011 7:58 am

How I use the existing .js modules in customization temlate?

Post by tmakita »

Hi,

I'm developing Oxygen WebHelp custom template that uses external search engine (AWS Elasticsearch). Currently basic connection test has done successfully and I could get the search query results from external search engine by JSON format.

Then now is the time to develop search result pages. I started this work and found I need existing Oxygen JavaScript modules to develop search result pages. For instance following JavaScript module is needed.
  • webhelp-responsive/app/localization/localization.js
  • webhelp-responsive/app/search/searchHistoryItems.js


The former exists in the output directly so that I added it simply to [custom search template]/js/template-main.js, but the latter is not found in the output directly (may be because I'm developing alternative search templates), as the result I manually copied searchHistoryItems.js into the [custom search template]/js folder.

[custom search template]/js/template-main.js

Code: Select all

define(['require'], function (require) {
    require([
        './suggest',
        './search-es',
        './build-param',
        './searchHistoryItems',
        '../../../oxygen-webhelp/app/localization/localization'
    ]);
});
However I got the following error when I execute the search in the browser development console.
Failed to load resource: the server responded with a status of 404 (Not Found) http://wh/GR2-640/out/webhelp-responsiv ... 2021030218
require.js:5 Uncaught Error: Script error for "searchHistoryItems", needed by: template-base-dir/js/search-es
http://requirejs.org/docs/errors.html#scripterror
at makeError (require.js:5)
at HTMLScriptElement.onScriptError (require.js:5)
What is the right way to use (or load) existing Oxygen JavaScript modules from the custom template JavaScript?

Regards,
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
tmakita
Posts: 100
Joined: Fri Apr 08, 2011 7:58 am

Re: How I use the existing .js modules in customization temlate?

Post by tmakita »

temlate ⇒ template
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
tmakita
Posts: 100
Joined: Fri Apr 08, 2011 7:58 am

Re: How I use the existing .js modules in customization temlate?

Post by tmakita »

Solved!
  • Add extension plug-in that implements "ant.import" and changing "com.oxygenxml.responsive.internal.target.dependencies.topics.html"
  • Implement custom .js file "copy" in the added build process.
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
Post Reply