Skip to content

Commit

Permalink
Rework with new settings format, and addressing #19 with hanging edit…
Browse files Browse the repository at this point in the history
…or instances
  • Loading branch information
adampresley committed Oct 7, 2014
1 parent 5671586 commit 1f7ea59
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 356 deletions.
135 changes: 41 additions & 94 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -1,96 +1,43 @@
[
{
"caption": "Tools",
"mnemonic": "T",
"id": "tools",
"children":
[
{
"command": "view_in_browser",
"caption": "View in Browser"
}
]
},
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "View in Browser",
"children":
[
{
"command": "open_file",
"args": {"file": "${packages}/View In Browser/View In Browser.sublime-settings"},
"caption": "Settings – Default"
},
{
"command": "open_file",
"args": {"file": "${packages}/User/View In Browser.sublime-settings"},
"caption": "Settings – User"
},
{ "caption": "-" },
{
"command": "open_file",
"args": {
"file": "${packages}/View in Browser/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings – Default"
},
{
"command": "open_file",
"args": {
"file": "${packages}/View in Browser/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings – Default"
},
{
"command": "open_file",
"args": {
"file": "${packages}/View in Browser/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings – Default"
},
{
"command": "open_file",
"args": {
"file": "${packages}/User/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings – User"
},
{
"command": "open_file",
"args": {
"file": "${packages}/User/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings – User"
},
{
"command": "open_file",
"args": {
"file": "${packages}/User/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings – User"
},
{ "caption": "-" }
]
}
]
}
]
}
{
"caption": "Tools",
"mnemonic": "T",
"id": "tools",
"children": [
{
"command": "view_in_browser",
"caption": "View in Browser"
}
]
},
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children": [
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children": [
{
"caption": "View in Browser",
"children": [
{
"command": "open_file",
"args": {"file": "${packages}/View In Browser/View In Browser.sublime-settings"},
"caption": "Settings – Default"
},
{
"command": "open_file",
"args": {"file": "${packages}/User/View In Browser.sublime-settings"},
"caption": "Settings – User"
},
{ "caption": "-" }
]
}
]
}
]
}
]
60 changes: 21 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,35 @@
# Sublime Text - View In Browser

*<a href="http://adampresley.github.io/sublime-view-in-browser/">View In Browser</a>* is a Sublime Text plugin that will open whatever is in your
current view/tab. If the file current open is new and has not been saved a temporary
file is created (in your default temp directory for your OS) with the extension of
**.htm** and your browser will open it. However if the current open file is saved
and has a name this plugin will open it in whatever you have set to handle
its type.
current view/tab. If the file current open is new and has not been saved a temporary file is created (in your default temp directory for your OS) with the extension of **.htm** and your browser will open it. However if the current open file is saved and has a name this plugin will open it in whatever you have set to handle its type.

By default the keystroke assigned to this plugin is *CTRL + ALT + V*.

## Installation
Using the Sublime Text Package Control plugin (http://wbond.net/sublime_packages/package_control)
press *CTRL + SHIFT + P* and find **Package Control: Install Package** and press *Enter*.
Find this plugin in the list by name **View In Browser**.
Using the Sublime Text Package Control plugin (http://wbond.net/sublime_packages/package_control) press *CTRL + SHIFT + P* and find **Package Control: Install Package** and press *Enter*. Find this plugin in the list by name **View In Browser**.

## Configuring Browsers
By default this plugin will open files in Firefox. You can configure it to open
using another browser of your choice. To do this, choose *Settings - User* from *Preferences > Package Settings > View In Browser*.

The browser you wish to use to open files is set in the key named **selectedBrowser**. The list of browsers
you can use and configure are in the key named **supportedBrowsers**.
The browser you wish to use to open files is set in the key named **browser**. The following is a list of browsers configured for use out of the box.

The **supportedBrowsers** values can be configured to have paths to your browser installations.
Each browser listed is an array (list) of configurations that allow you to setup a browser
for multiple operating systems. For example under *chrome* there are two configurations.
The first is for your average Linux system. The second is for Windows.
* Firefox - Mac OS, Linux, Windows
* Chrome - Mac OS, Linux, Windows
* Chrome64 - Windows
* Safari - Mac OS
* Internet Explorer - Windows
* Chromium - Linux

## Other Browsers
View In Browser also provides key bindings to open your current view in browser other than
your **selectedBrowser**. Below is a listing of the keys and what browser open with
those key bindings.
View In Browser also provides key bindings to open your current view in browser other than your **browser** setting. Below is a listing of the keys and what browser open with those key bindings.

* *CTRL + ALT + F* - Firefox
* *CTRL + ALT + C* - Chrome
* *CTRL + ALT + I* - Internet Explorer
* *CTRL + ALT + S* - Safari

Like any other key binding in Sublime these can be changed. Below is an example of the
key configuration. You can remap these in your User key bindings configuration file.
Like any other key binding in Sublime these can be changed. Below is an example of the key configuration. You can remap these in your User key bindings configuration file.

```javascript
[
Expand All @@ -50,11 +42,7 @@ key configuration. You can remap these in your User key bindings configuration f
```

### Windows Considerations
One of the things you may notice in the Windows configuration for *chrome* is a variable in
the command path that looks like: **%Local AppData%**. This is a reference to your Windows
installation's **AppData** folder in your user profile directory. There is a variable
there because this value will differ for each user on your computer, and Chrome installs
to your **AppData** folder.
One of the things you may notice in the Windows configuration for *chrome* is a variable in the command path that looks like: **%Local AppData%**. This is a reference to your Windows installation's **AppData** folder in your user profile directory. There is a variable there because this value will differ for each user on your computer, and Chrome installs to your **AppData** folder.

Here is a list of supported variables:

Expand All @@ -67,19 +55,12 @@ Here is a list of supported variables:
* **My Pictures** - Path to your pictures location
* **My Music** - Path to your music location

Note that many of these are not terribly useful for determining browser location, unless you
have decided to install Firefox in your My Music folder.

Note that many of these are not terribly useful for determining browser location, unless you have decided to install Firefox in your My Music folder.

## Configure to View on Local Server
The View In Browser plugin also supports the ability to view files in the context of
a local server. So if you have a local Apache, Tomcat, or some other server application running
you can configure this plugin to open your file prefixed with a URL.
The View In Browser plugin also supports the ability to view files in the context of a local server. So if you have a local Apache, Tomcat, or some other server application running you can configure this plugin to open your file prefixed with a URL.

To configure this the View In Browser plugin reads the configuration of your currently
loaded project. You can edit a project file by opening the *sublime-project* file
by choosing **Project** -> **Edit Project**. In your project file you will need to specify
two things:
To configure this the View In Browser plugin reads the configuration of your currently loaded project. You can edit a project file by opening the *sublime-project* file by choosing **Project** -> **Edit Project**. In your project file you will need to specify two things:

* **baseUrl** - The root URL to prefix files with
* **basePath** - The base path where your site/application lives
Expand All @@ -103,15 +84,16 @@ Here's how that looks.
}
```

Notice the key named **settings** which is a dictionary that contains another key named
**sublime-view-in-browser**. This is where you will put your **baseUrl** and **basePath**
settings.
Notice the key named **settings** which is a dictionary that contains another key named **sublime-view-in-browser**. This is where you will put your **baseUrl** and **basePath** settings.

Now when you activate View In Browser your file will open with the HTTP protocol instead
of the FILE protocol.
Now when you activate View In Browser your file will open with the HTTP protocol instead of the FILE protocol.

## Change History

* 10/06/2014:
* Rewrite for version 2.0.0
* Using subprocess instead of webbrowser. Seems to solve #19
* Smaller, simplier sublime-settings file
* 05/15/2014:
* Current view only saves if there are modifications
* 07/03/2013:
Expand Down
80 changes: 23 additions & 57 deletions View In Browser.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,61 +1,27 @@
{
"supportedBrowsers": {
"firefox": [
{
"osname": "posix",
"platform": ".*",
"command": "firefox"
},
{
"osname": "posix",
"platform": "darwin",
"command": "open -a \"/Applications/Firefox.app\""
},
{
"osname": "nt",
"platform": "win32",
"command": "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
}
],
"safari": [
{
"osname": "posix",
"platform": "darwin",
"command": "open -a \"/Applications/Safari.app\""
}
],
"iexplore": [
{
"osname": "nt",
"platform": "win32",
"command": "C:/Program Files/Internet Explorer/iexplore.exe"
}
],
"chrome": [
{
"osname": "posix",
"platform": "darwin",
"command": "open -a \"/Applications/Google Chrome.app\""
},
{
"osname": "posix",
"platform": "linux.*",
"command": "google-chrome"
},
{
"osname": "nt",
"platform": "win32",
"command": "%Local AppData%/Google/Chrome/Application/chrome.exe"
}
],
"chromium": [
{
"osname": "posix",
"platform": "linux.*",
"command": "chromium"
}
]
"posix": {
"linux": {
"firefox": "firefox -new-tab",
"chrome": "google-chrome",
"chrome64": "google-chrome",
"chromium": "chromium"
},

"darwin": {
"firefox": "open -a \"/Applications/Firefox.app\"",
"safari": "open -a \"/Applications/Safari.app\"",
"chrome": "open -a \"/Applications/Google Chrome.app\"",
"chrome64": "open -a \"/Applications/Google Chrome.app\""
}
},
"nt": {
"win32": {
"firefox": "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -new-tab",
"iexplore": "C:\\Program Files\\Internet Explorer\\iexplore.exe",
"chrome": "%Local AppData%\\Google\\Chrome\\Application\\chrome.exe",
"chrome64": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
}
},

"selectedBrowser": "firefox"
"browser": "firefox"
}
2 changes: 1 addition & 1 deletion ViewInBrowser.sublime-commands
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
{ "caption": "View In Browser", "command": "view_in_browser" }
{ "caption": "View In Browser", "command": "view_in_browser" }
]
Loading

0 comments on commit 1f7ea59

Please sign in to comment.