xwiki

How can I use a path to a directory on linux in XWiki?


I would like to put a path to a file on an XWiki page.

For a Windows file share this works:

[[For Windows>>unc://filehare/directory$/index.html]] 

For linux:

When I enter file:///mnt/directory/index.html in Firefox, the index.html page is displayed.

But when I use any of these syntaxes in XWiki, nothing happens.

[[For Linux>>file:///mnt/directory/index.html]] 
[[For Linux>>file:mnt/directory/index.html]] 
[[For Linux>>file:/mnt/directory/index.html]] 
[[For Linux>>unc:mnt/directory/index.html]] 
[[For Linux>>unc:/mnt/directory/index.html]] 
[[For Linux>>unc:///mnt/directory/index.html]] 

Can anyone tell me what the correct syntax is?


Solution

  • First of all, you need to clearly understand the fact that the UNC protocol (and links using it) is used to address/reference files on other computers in your local network only. They can also be links to your own computer (using your computer's "name", but most of the time they refer to other computers). Some more details about UNC: https://whatis.techtarget.com/definition/Universal-Naming-Convention-UNC

    Second: It is not clear what you mean by "on Windows" vs "on Linux". Is the XWiki server running on Windows in the first case and, in the second case it is a different XWiki server that is running on Linux? What I actually think you mean is that you tried to access the same XWiki server from 2 different computers: first you were using a computer with Windows operating system (possibly on Internet Explorer/Edge) and in the second case you switched to a different computer that was running a Linux distribution with the Firefox browser. I will assume you are in this latter situation, as it is the one that makes most sense. Please note that UNC links will only work for people that are using a Windows computer when viewing the XWiki page.

    Third: Your first example unc://filehare/directory$/index.html is a reference to a file on the fileshare computer (which is somewhere on the Network, other than the current computer you are using right now to test, referenced with the UNC protocol mentioned in my first point). However, your second example file:///mnt/directory/index.html, which is not working, is a reference to a file that is on your local computer, the one you are testing with ("mnt" is a folder on your computer). In this second example, your particular usecase is no longer allowed since a good couple of years ago by modern web browsers (including Firefox, the browser you are testing with) because of security problems. Internet Explorer (being an old browser), might still work by default, but you should not really be using it in 2018 anymore. Feel free to read more about this subject on http://kb.mozillazine.org/Links_to_local_pages_don%27t_work

    In XWiki, any of the following links are equivalent:

    [[UNC file on the "server" computer>>unc:\\server\folder\file.ext]]
    [[UNC file on the "server" computer>>url:file://///server/folder/file.ext]]
    [[UNC file on the "server" computer>>file://///server/folder/file.ext]]
    

    ...however, is not really something related to XWiki, but to the capacity of your current browser to interpreting those links. By default, as said, this is no longer supported or simply disabled. Some browsers might still support disabling this protection, either by some advanced setting or by installing a browser add-on:

    ...but you would have to do this change and install this type of add-ons on all the computers that you wish to use when reading that page, which is not very practical.