13 Replies Latest reply on Oct 21, 2010 1:06 PM by sschultz lr3

    Show local html file

    sschultz lr3

      How do you do this. I tried the following which works nice on Windows but fails on MacOSX:

      LrHttp.openUrlInBrowser(_PLUGIN:resourceId "doc.html")

       

      Ho do YOU show a local helpfile (pdf or html) cross-platform-compatible? Thanks in advance.

        • 1. Re: Show local html file
          areohbee Level 5

          local path = LrPathUtils.child(  _PLUGIN.path, "doc.html" )

          LrHttp.openUrlInBrowser( "file://" .. path )

          • 2. Re: Show local html file
            sschultz lr3 Level 1

            Thank you. But the browser window does not open at all (MacOSX). On the other hand, an http-URL opens without any problem.

             

            My code:

             

            local LrHttp = import "LrHttp"

            local LrPathUtils = import "LrPathUtils"

            local LrDialogs = import 'LrDialogs'

            local LrFunctionContext = import 'LrFunctionContext'

             

            local function showHelp(context)

              LrDialogs.attachErrorDialogToFunctionContext(context)

              local path = LrPathUtils.child(_PLUGIN.path, "help.html" )

              --LrHttp.openUrlInBrowser("file://" .. path )

              LrHttp.openUrlInBrowser("http://www.heise.de" )

            end

             

            LrFunctionContext.callWithContext("HelpContext", showHelp)

            • 3. Re: Show local html file
              areohbee Level 5

              Huh - works for me, try this: . Its not a combo-box bug test at the moment .

               

              R

              1 person found this helpful
              • 4. Re: Show local html file
                johnrellis Most Valuable Participant

                Rob's test program worked on my Mac too (10.6.4), with Safari as the default browser.

                • 5. Re: Show local html file
                  sschultz lr3 Level 1

                  Rob's test program shows the correct path in the messagebox but nothing happens there after.

                  (10.6.4 and Safari as default)

                   

                  On XP it runs fine. Seems to have something to do with my local installation

                  Any hint?

                  • 6. Re: Show local html file
                    sschultz lr3 Level 1

                    Configured FF as default. Even this does not work.

                    • 7. Re: Show local html file
                      sschultz lr3 Level 1

                      It seems to have something to do with the String length that is passed to LrHttp.

                      In my documents folder the test-plugin does work, but not deep inside /Users/username/Library/Application Support/Adobe/Lightroom/Plugins/PluginName.lrdevplugin

                       

                      Can anyone reproduce?

                      • 8. Re: Show local html file
                        areohbee Level 5

                        Haven't had a chance to try the long path on Mac. But something else you might try if you haven't already is LrTasks.execute( htmlFilePath ) - should do the same thing, plus if it doesn't work you can check the return code.

                         

                        ??

                        • 9. Re: Show local html file
                          sschultz lr3 Level 1

                          I did not try "execute" yet, because I had in my mind that in windows the parameter for the application can be omitted and on a Mac you must give the application to execute. Maybe I mixed something up and this statement is wrong.

                          As a workaround I uploaded my files to my webspace and have an onlinedocumentation instead an offlinedocumentation.

                          • 10. Re: Show local html file
                            areohbee Level 5

                            More than one way to skin a grape...

                             

                            Could it be the spaces and not the path length?

                             

                            I tried putting quotes in the string here and there on windows but it didn't like them, but that does not mean mac wouldn't. Although, using execute, I have to ditch a pair of quotes for mac that windows does prefer. But thats a different command.

                             

                            Anyway, next time I'm on the mac I'll give it another test for ya - unless you really dont care anymore... Something to be said for getting it off the web anyway as long as your users will have a web connection when they need it...

                             

                            EDIT: I wonder if URL encoding would help - ya-know: %20 for the spaces and such?

                             

                            Ciao,

                            Rob

                            • 11. Re: Show local html file
                              sschultz lr3 Level 1

                              I am still interested in a solution - the onlinedoc is just a temporary workaround.

                              Thank you for testing it out. I also tried with URL-Encoding* the path, but it dif not work either.

                               

                              *http://lua-users.org/wiki/StringRecipes

                              • 12. Re: Show local html file
                                johnrellis Most Valuable Participant
                                I did not try "execute" yet, because I had in my mind that in windows the parameter for the application can be omitted and on a Mac you must give the application to execute.

                                That's correct.  On the Mac, you need to use the "open" program, which will open any file in its native application, e.g.

                                 

                                open "/Users/username/Library/Application Support/Adobe/Lightroom/Plugins/PluginName.lrdevplugin/help.html"

                                 

                                Here is the code my Any File plugin uses to open any arbitrary file in its native application:

                                 

                                        if WIN_ENV then
                                            LrShell.openFilesInApp ({""}, file)
                                        else
                                            LrShell.openFilesInApp ({file}, "open")
                                            end

                                It occurs to me that I may not have explicitly tested this with filenames containing spaces on the Mac, so I don't know if the openFilesInApp() function handles spaces correclty.   If it doesn't, then you can always drop down and call LrTasks.execute() directly.

                                • 13. Re: Show local html file
                                  sschultz lr3 Level 1

                                  Thank you, it works well on the Mac!

                                  Edit: it works fine on Windows 7, too.

                                  Thank you very, very much for sharing your code.