Open "user guide" HTML of tool for any OS?


(Raul (ulneiz)) #1

I am trying to create a simple function to invoke an html file saved in the root folder of the tool (…tool\user_guide\phrasetouch_user_guide_en.html), so that it opens automatically with the default Internet browser of the operating system.

I can only try this function with Windows 10. I do not have OSX or Linux.Could someone be ready to work correctly with OSX and Linux? Unfortunately I can not test it for both operating systems.

The function and the button to invoke:

------------------------------------------------------------------------------------------------
--user guide
local function pht_user_guide_path()
  local dir = os.currentdir() --dir for tool
  local html = "user_guide/phrasetouch_user_guide_en.html"
  local guide = "file:///"..dir..html
  return guide
end
---
local PHT_USER_GUIDE = vb:column { spacing = 3,
  vb:text {
    font = "big",
    text = "PhraseTouch User Guide"
  },
  vb:row { style = "plain", margin = 5,
    vb:text {
      height = 25,
      width = 300,
      text = "Use a browser to read the HTML PhraseTouch User Guide:"
    },
    vb:button {
      height = 25,
      width = 250,
      text = "Show PhraseTouch User Guide",
      notifier = function() renoise.app():open_url( pht_user_guide_path() ) end,
      tooltip = ""..pht_user_guide_path()
    }
  }
}
  • The functionpht_user_guide_path() work correctly on all 3 operating systems? It is invoked from “notifier = function() renoise.app():open_url( pht_user_guide_path() ) end
  • file:/// is also necessary for the 3 operating systems?

With Windows 10, the local guide return:

file:///C:\Users\NAME_USER\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ulneiz.PhraseTouch_v1.0.xrnx\user_guide/phrasetouch_user_guide_en.html

Can anybody help me?


New Tool (3.1): GT16-Colors v1.2a1 (updated 12 June 2017)
(danoise) #2

That would work on my system (win8.1) as well, and probably across most other platforms:
https://stackoverflow.com/questions/12711584/how-to-specify-a-local-file-within-html-using-the-file-scheme

Re HTML: as long as you don’t rely on any javascript, it should work - but for security reasons, things are quite restricted in browsers when using the file:// protocol.


(Raul (ulneiz)) #3

That would work on my system (win8.1) as well, and probably across most other platforms:
https://stackoverflow.com/questions/12711584/how-to-specify-a-local-file-within-html-using-the-file-scheme

Re HTML: as long as you don’t rely on any javascript, it should work - but for security reasons, things are quite restricted in browsers when using the file:// protocol.

Thanks!

Ok!The code I use is simple. It’s just HTML, a common CSS3 file linked and links to PNG and animated GIF images.If in Windows 10 the function “pht_user_guide_path()” works correctly, as it does, I suppose that in the rest of the operating systems it will work fine as well.

If we analyze the structure of the function to define the complete address of the file to be executed:

  1. local dir = os.currentdir() This defines the complete address to the tool folder.
  2. local html = “user_guide/phrasetouch_user_guide_en.html” This defines the folder that is inside the root folder of the tool, and the name and extension of the file to invoke.But with a curious exception. The separation slash should look like this: / If you use **** it will not work because it disappears. It must be because of the LUA code, which seems to be reserving this bar for special uses.Then, when you read the full address in the address bar of the internet browser, this bar will appear like this / , but os.currentdir() return the bars like this Should not I return them like that …/…/…/…??? It seems that the browser itself makes several corrections with the bars.
  3. local guide = “file:///”…dir…html This defines the complete address, including file: //.Apparently, whether you use file:// or file:/// the browser will interpret it equally correctly, and it will read like this file:///…As I understood, file:// is to be able to access the file of the computer.It is necessary to include it.

The complete result is this (Windows 10):

  • with print():

file:///C:\Users\NAME_USER\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ulneiz.PhraseTouch_v1.0.xrnx\user_guide/phrasetouch_user_guide_en.html

  • with browser:

file:///C:/Users/NAME_USER/AppData/Roaming/Renoise/V3.1.1/Scripts/Tools/ulneiz.PhraseTouch_v1.0.xrnx/user_guide/phrasetouch_user_guide_en.html

If all the pieces that define the address are correct, it should work in any operating system, since in the background it seems that the Internet browser does the work…


(Raul (ulneiz)) #4

I put this matter as resolved. If later there is a problem detected, I will return to this thread to detail it.

I find it interesting to be able to click on a button of the tool and that I can directly invoke the documentation of the user guide. This is very easy.


(pat) #5

I’m really looking forward to seeing whatever this is you’ve been working on Raul!


(Raul (ulneiz)) #6

I’m really looking forward to seeing whatever this is you’ve been working on Raul!

Very soon it will be available for everyone in the tools section of www.renoise.com