skandasoft / open-in-browsers

Open in Different Browsers - IE/Chrome/Firefox/Opera/BrowserPlus
MIT License
21 stars 7 forks source link

Concatenate paths to include the root folder opened in Atom. #17

Closed JohnLukeBentley closed 7 years ago

JohnLukeBentley commented 8 years ago

Open-in-browsers generally works well if I have something like ...

LocalHost Url: http://localhost:8080/web

... and if, in Atom, the root folder (File > Open Folder ...) is web (in my local file system at C:\Users\John\Documents\Sda\Code\web\) and I'm loading a file

C:\Users\John\Documents\Sda\Code\web\Libraries\Html5Library\example.xhtml

... then the resulting path sent to browser works as desired:

http://localhost:8080/web/Libraries/Html5Library/example.xhtml

However, if I open a different root folder in Atom. E.g. C:\Users\John\Documents\Sda\Code\EcmaScript then I'm forced to edit LocalHost Url to ...

LocalHost Url: http://localhost:8080/EcmaScript

... in order to get

`C:\Users\John\Documents\Sda\Code\EcmaScript\Examples\dateTimeDemo.xhtml`

... to open as ...

http://localhost:8080/EcmaScript/Examples/dateTimeDemo.xhtml

My suggestion is for open-in-browsers to build the resulting path with the root folder included. That is, so that when I switch to a different folder in atom everything is handled without having to manually edit LocalHost Url.

That is, in my case I'd like everything to work with:

LocalHost Url: http://localhost:8080
skandasoft commented 8 years ago

I think I understand what you are sayng..I might need to have a project level setting so that when ever you open a different project the base url would be specific for that project...it has to be an enhancement..

JohnLukeBentley commented 8 years ago

What I'm suggesting in an enhancement, yes.

But the suggestion is to, by default, facilitate keeping the base url fixed, the value you enter in LocalHost Url, as you switch between projects.

I'll use some more generic paths, and order the example, which might make things a bit clearer.

Imagine your Windows login name is "John" and you have a local path:

C:\Users\John\Documents\MyWebServerDocumentRoot\

In your Apache httpdf.conf (for example) you target this local path with

DocumentRoot "C:/Users/John/Documents/MyWebServerDocumentRoot"

And you have several different web projects stored underneath their own folder as follows

 C:\Users\John\Documents\MyWebServerDocumentRoot\WebProject01
 C:\Users\John\Documents\MyWebServerDocumentRoot\WebProject02

Assume those folders are also the folders you open, one at a time, in Atom with File > Open Folder ....

When serving these projects you'll want something like

 http://localhost:8080/WebProject01/
 http://localhost:8080/WebProject02/

And using open-in-browsers from Atom you want to build the path as (using WebProject01 as the example)

 LocalHost Url: http://localhost:8080
 plus
 Project specific path, e.g.: /WebProject01/...

In other words, what you are doing right now, expect including the root folder that you open in Atom as part of the project specific path.

Now a further idea is to allow different base URLs on a project dependent basis. That's not part of my suggestion but it sounds like that's what you mistook my suggestion for. There is sometimes a need for this. E.g. Sometimes you might be using different local servers, different ports, http V https, etc; depending on the project...

 https://localhost:6230
 http://drupalcopy.localhost:8080

At the moment I have no need for this, so don't build it on my account. But it would round out your tool. At any rate, for me, the more important enhancement is making the baseURL project independent.

I happened to write some code for a different Atom plugin, to achieve what I am suggesting, at https://github.com/brycefranzen/local-server-web-view/issues/3 . With my modifications (not yet folded into the plugin but mentioned in the post) local-server-web-view affords both: project independent base urls; and project dependent base urls. But the limitation with local-server-web-view is that it operates on only one browser.

It's probably be easier to modify your existing code (I haven't looked at it), but by all means take whatever code of mine if saves any time.

skandasoft commented 7 years ago

check the latest patch..with the ability to add localhost

skandasoft commented 7 years ago

Feel free to reopen if still problems exist