Create a new HTML resource and insert a reference to it

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Create a new HTML resource and insert a reference to it

Post by NicoAMP »

Hello,

I manage a HTML table of content and I would like to implement an action that permit to create a new file and insert a reference on it in the TOC content.
I saw that following dialog exist, but I don't know how to invoke it in javascript in my framework and get the result URL.
It's a similar behavior than when you click on "Create a new DITA resource and insert a reference to it" in DITA toolbar.
image.png
image.png (84.32 KiB) Viewed 1835 times
Thanks for any help.

Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Create a new HTML resource and insert a reference to it

Post by mihaela »

Hello,

The dialog displayed when the "Create a new DITA resource and insert a reference to it" action is invoked is not API but you can create your own dialog. You can use the "Template Chooser" component that is provided in template-chooser.html resource. For example, you can see it on our demo server here (you can also find it on your server at the similar location):
https://www.oxygenxml.com/oxygen-xml-we ... ooser.html

In your dialog you can insert the Template Chooser in an iframe, and then listen to the CustomEvent (of 'templateChooserEvent' type) that is triggered when the user selects a template. This event will provide you details about the selected template and its content request URL.

The dialog should also contain the field for file name. When the dialog is closed you can invoke an operation that inserts a fragment in the document.
ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation
To invoke the operation you can use the following API:
https://www.oxygenxml.com/maven/com/oxy ... on__anchor

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: Create a new HTML resource and insert a reference to it

Post by NicoAMP »

Hello Mihaela,

Thanks a lot for your answer.

Now I understand well how to insert a template chooser, get the URL and insert a reference.
What I don't understand is how create the new file in my CCMS?

Thanks.
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
cristi_talau
Posts: 495
Joined: Thu Sep 04, 2014 4:22 pm

Re: Create a new HTML resource and insert a reference to it

Post by cristi_talau »

Hello,

Once you have the URL of the file to be created and the content of the template, you can invoke a Java AuthorOperation that creates the file.

We have a sample plugin that reads a file from the CMS [1]. This code can be adapted to write the file instead of reading it [2].

Best,
Cristian

[1] https://github.com/oxygenxml/web-author ... le-as-text
[2] https://github.com/oxygenxml/web-author ... e.java#L32
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: Create a new HTML resource and insert a reference to it

Post by NicoAMP »

Thanks Cristian for your answer.
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Post Reply