Page 1 of 1

Author: open link to local folder

Posted: Wed Nov 23, 2016 12:59 pm
by friedemann_bach
Dear Forum,

I am configuring the Author mode with less/css and I am trying to figure out a way to create a link that opens a local folder.

Lets assume that I have an element <localFolder>, which specifies the name of a local folder on a network drive.

To create a link to that folder, I tried this:

Code: Select all

localFolder:after {
link:oxy_xpath('concat("file:///Q:/Digitalisate/Bayreuth_Bamberg/_jpeg_Bayreuth Digi/",.)');
content:' Link';
color:@blue;
}
On clicking that link, Oxygen returns a message that access was denied. Can you help here? I would be glad if you could point me to a solution.

Re: Author: open link to local folder

Posted: Wed Nov 23, 2016 2:57 pm
by alex_jitianu
Hello,

I think you should compose the link like this:

Code: Select all

link: oxy_concat("file:///Q:/Digitalisate/Bayreuth_Bamberg/_jpeg_Bayreuth Digi/",oxy_xpath('./text()'));
You need oxy_xpath() to get the text of <localFolder> and you use oxy_concat() to merge the two parts together.

Best regards,
Alex

Re: Author: open link to local folder

Posted: Wed Nov 23, 2016 3:33 pm
by friedemann_bach
Thanks for the alternative approach! I tried that, but it produces the same response: Access is denied.

I believe that the address is determined correctly: Just for a test, I tried a wrong address that does not exist, which throws a file not found error. The correct address produces the "access denied" message.

Instead of folders, I also tried .odt or .docx files, which worked fine. With just a folder name given, I would expect the system to open it in the Explorer. Is there a way to specify the standard application? Or does the link need to be modified? I am glad for every hint.

Re: Author: open link to local folder

Posted: Wed Nov 23, 2016 4:16 pm
by alex_jitianu
Hi,

Ups, my bad! I mistook the XPath concat() function in your example for our oxy_concat() CSS function... Anyway, instead of relying on the link property you could use a button form control like this:

Code: Select all

localFolder:after {
content:oxy_button(action, oxy_action(
name, 'Open',
description, 'Open the folder',
operation, 'OpenInSystemAppOperation',
arg-resourcePath, 'concat("file:/D:/projects/eXml/samples/", .)'));
}
To make the button look prettier you can also give the action an image and make the button transparent.

Best regards,
Alex

Re: Author: open link to local folder

Posted: Wed Nov 23, 2016 5:48 pm
by friedemann_bach
Great idea, thanks! I tried it and Oxygen responds:
Couldn't execute operation: 'ro.sync.ecss.extensions.commons.operations.OpenInSystemAppOperation' for action: 'Open' because of: class java.security.AccessControlException - access denied ("java.io.FilePermission" "<<ALL FILES>>" "execute")
This seems to be a security issue and is independent of the correct address. Is there a way to influence this behaviour within Oxygen or do you think this is a general Java setting?

Best regards and many thanks for your hints so far!

Re: Author: open link to local folder

Posted: Thu Nov 24, 2016 10:35 am
by alex_jitianu
Hi,

What happens is that a rule from a CSS, for which Oxygen can't guarantee that it's safe, tries to perform an action which is potentially dangerous. The solution is to move this CSS in a "safe" location, meaning the frameworks. Do you have a framework (or document type) created for your documents? If you do, just put the CSS in the framework directory and associate it with your documents from the configuration. Please let me know if you need more information in this regard.

I'll add an issue to also improve the "link" property to detect a path to a directory in which case it should open that directory.

Best regards,
Alex

Re: Author: open link to local folder

Posted: Thu Nov 24, 2016 12:03 pm
by friedemann_bach
Hi Alex,

many thanks for the explanation. I do not use frameworks, but I have defined a document type and my xml files are associated with the LESS file. So I suppose I need to put it in a framework directory to make it work, or would it be sufficient to add the css directory to the list of additional frameworks directories?

Best regards!

Re: Author: open link to local folder

Posted: Thu Nov 24, 2016 12:20 pm
by alex_jitianu
Hi Oscar,

Well, both a framework and a document type refer to the same thing. We kind of use both terms to refer to the configuration associated with a specific XML vocabulary. So, if you've create a document type please make sure you set the Storage as External and select a directory from within the frameworks directory, something like this:

Code: Select all

{oxygenInstallDir}\frameworks\myDocumentType\myDocumentType.framework
The LESS file should reside in the same myDocumentType directory and, again in the Document Type configuration dialog, on the CSS Tab you can add a reference to that less file:

Code: Select all

${framework}/myCss.less
or would it be sufficient to add the css directory to the list of additional frameworks directories
That will also work, but the recommended approach would be the one above. To make your document type external and put all of your resources into its directory. That will also ensure you can easily give it to others.

Best regards,
Alex

Re: Author: open link to local folder

Posted: Thu Nov 24, 2016 1:00 pm
by friedemann_bach
Hi Alex,

many thanks for the solution! It means that I have to reorganize here and there, mainly concerning how project/framework information is shared, but it will be worth the effort.

Best regards and thanks again :)