Closed cryobry closed 4 years ago
Hi! This seems like an interesting feature we could make work for a lot of scenarios. I've opened a PR with a way to add URL overwrites. Under experimental features you'll find URL Overwrites. In this you can defined the initial file path when you right click to preview your php file and replace it with localhost:8080
This is a good start for a single directory, but it's not quite a complete solution until the "replace" block can be automatically generated based on the active file path. This way the setting will not need to be manually changed each time we open files from a different webroot.
Example:
[ { "replace": "{FILE_ACTIVE_PATH}", "with": "localhost:12345/" } ]
where {FILE_ACTIVE_PATH}
is something like "file:///path/to/the/" for the file: /path/to/the/file.php.
To prevent this setting from overriding the default behavior, maybe we could specify where the overwrite setting should be enabled based on a user supplied list of applicable directories (all child directories would be subject to the overwrite rule).
If this is not clear I will try to rephrase.
@cryobry Yes, can you provide more real world example of what you are trying to do / what your expectation is? Also maybe some details of what your folder structure looks like. We can probably figure out a way to do this!
Say I have a bunch of html/php webpages in a project folder, some may be in the webroot directory and some may be in a scripts or other subdirectories within the subroot. I have a webserver serving the webroot.
Example directory tree:
webroot
├── scripts
│ ├── comments.php
│ ├── concat.php
│ ├── constants.php
│ └── test.php
├── other-scripts
│ ├── html
│ │ ├── activate.php
│ │ ├── change_password.php
│ │ ├── forgot_password.php
│ │ ├── includes
│ │ │ ├── config.inc.php
│ │ │ ├── footer.html
│ │ │ ├── header.html
│ │ │ └── layout.css
│ │ ├── login.php
│ │ ├── logout.php
│ │ └── register.php
│ ├── php
│ │ ├── mysqli_connect.php
│ │ └── process.php
├── license.txt
├── README.md
├── sql.sql
├── index.php
├── 404.php
└── logout_alt.php
I would like to be able to open any of these files, make edits, and have Atom Browser display the file without editing the url manually in Atom Browser. Currently, I need to manually edit the url in Atom Browser every time I open a new file in order to view it. This is very cumbersome.
What I would like is a way to set the relative webroot == to my web server's url prefix (e.g. http://localhost:12345 on my dev machine) and then have the url change in Atom Browser according to the active file. It could be possible to handle this automatically by assuming that the project folder is the webroot (or users could specify the webroot manually and use an overwrite, similar to the idea that you have already implemented). Thus when I open the file ./webroot/other-scripts/includes/footer.html in Atom, I would like Atom Browser to open the address http://localhost:12345/webroot/other-scripts/includes/footer.html.
Does this make sense?
@cryobry I think this feature does solve your scenario. If you put in your webroot folder path as the replace and localhost:12345 as the with. When you right click and preview those files it will fix the path to your webroot. Can you try that?
[ { "replace": "file:///Users/username/Desktop/webroot", "with": "localhost:12345" } ]
When I tested this if I right click one of those files I get the url prefixed
Thanks, I was activating the browser using the command palette but I will use this method in the meantime.
My initial url is a local web server
localhost:8080
that is serving files from the current working directory. I would like to be able to start Atom Browser and have it load the current file (localhost:8080/myfile.php) automatically.So the file name just needs to be appended to the initial url.