Home Download Buy Blog Forum Support

Preview in browser on local test server with localhost?

Preview in browser on local test server with localhost?

Postby Fatbat on Wed Mar 21, 2012 1:11 pm

I've been searching and searching for a way to do this, but I haven't been able to figure it out yet. Is there some way to preview files in your default (or alternative) browser with localhost/ ?

Currently if you hit F12 some documents, .html, .pngs, etc will open with their respective default programs. It would be nice to be able to hit F12 or another hotkey combo to preview a file from it's directory location on localhost/.

Is there a way to do this?
Fatbat
 
Posts: 71
Joined: Sun Feb 19, 2012 6:54 pm

Re: Preview in browser on local test server with localhost?

Postby skube on Wed Mar 21, 2012 1:31 pm

Perhaps using the Prevu package?
https://github.com/Nijikokun/Prevu
skube
 
Posts: 88
Joined: Tue Feb 28, 2012 8:42 pm

Re: Preview in browser on local test server with localhost?

Postby Fatbat on Wed Mar 21, 2012 1:55 pm

Yeah, that's cool and all and I have it installed, but if I'm understanding things properly, you need to add a comment to every single document you want to preview which doesn't do a whole lot for streamlining the workflow. Ideally you would just want to be able to specify the root folder in the test server settings for the project like you can in (ugh) Dreamweaver. Hit F12 to preview in your default brower (or alt/F12 in an secondary browser) any document that falls within that folder or subfolder.
Fatbat
 
Posts: 71
Joined: Sun Feb 19, 2012 6:54 pm

Re: Preview in browser on local test server with localhost?

Postby tito on Wed Mar 21, 2012 2:17 pm

This is added by "SideBarEnhancements" package
quote:

F12 key allows you to open the current file in browser.
If you want to add a url to that feature: Right click the sidebar -> project -> edit project

There add the new preferences:

Code: Select all
, "url":"http://localhost/"
, "url_production":"http://domain.test/"

"url" allows you to set the url of your local server, opened via F12
"url_production" allows you to set the url of your production server, opened via ALT+F12


an example of my project file

Code: Select all
{
   "folders":
   [
      {
         "path": "/C/Documents and Settings/tito/Datos de programa/Sublime Text 2/Packages"
      }
   ],
   "url":"http://localhost/",
   "url_production":"http://example.test/"
}



This will only work with the latest version, update and be sure to restart sublime.

There is also other packages which add a more convenient "browser preview", for when you needing to check a lot the result.

[edited] for clarification
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Preview in browser on local test server with localhost?

Postby Fatbat on Wed Mar 21, 2012 9:42 pm

You're a champ tito! Works perfectly :) Thank you.
Fatbat
 
Posts: 71
Joined: Sun Feb 19, 2012 6:54 pm

Re: Preview in browser on local test server with localhost?

Postby randalldon on Fri Apr 27, 2012 11:07 am

Hi There,

I've followed the instructions above to get this working and it does so fine when i first open the project. If i don't 'save' the file i can preview on both the localhost and production urls without issue but if i actually 'save' the document after any changes this functionality fails and previewing in any way, shape or form cannot be performed unless i restart Sublime. Is this an issue anybody has had? Naturally this makes working very difficult if in order to preview files effectively i have to restart Sublime after each file 'save'.

I'm using Sublime Text 2 on Windows 7.

Any help or advice would be greatly appreciated.

Regards

Brendan
randalldon
 
Posts: 1
Joined: Fri Apr 27, 2012 11:01 am

Re: Preview in browser on local test server with localhost?

Postby pentool on Mon Jul 23, 2012 11:04 pm

Hello,

I've installed SublimeText a day ago. I have installed the SideBarEnhancements plugin and it's working ok, but following this thread I am not able to open the htm files on localhost using F12. They are opening in local file mode (file://D:/...). I have no clue why.

Furthermore, I have my default system browser set to Firefox and I like it this way. However, I am developing mobile apps using SenchaTouch. That framework requires to preview the files using a webkit browser (Chrome or Safari). So I'd like to somehow specify to open my htm files using a specific browser and NOT my default browser when I press F12. Is that possible? Can someone tell me how?

And then there's still the missing question, why my localhost is not previewing, but only local files (as I mentioned above).

Thank you!
pentool
 
Posts: 9
Joined: Mon Jul 23, 2012 10:58 pm

Re: Preview in browser on local test server with localhost?

Postby tito on Wed Jul 25, 2012 3:38 pm

Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests