ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Preview

by iafan ST2

Map local files to URLs and preview them in browser (Sublime Text editor plugin)

Details

  • 2013.07.16.12.02.00
  • github.​com
  • github.​com
  • 12 years ago
  • 18 minutes ago
  • 13 years ago

Installs

  • Total 8K
  • Win 5K
  • Mac 3K
  • Linux 554
May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
01234May 17May 14May 11May 8May 5May 2Apr 29Apr 26Apr 23Apr 20Apr 17Apr 14Apr 11Apr 8Apr 5May 17 Linux: 0 Mac: 0 Windows: 0May 16 Linux: 0 Mac: 0 Windows: 0May 15 Linux: 0 Mac: 0 Windows: 0May 14 Linux: 0 Mac: 0 Windows: 0May 13 Linux: 0 Mac: 0 Windows: 0May 12 Linux: 0 Mac: 0 Windows: 0May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 0 Mac: 0 Windows: 0May 9 Linux: 0 Mac: 0 Windows: 0May 8 Linux: 0 Mac: 0 Windows: 0May 7 Linux: 0 Mac: 0 Windows: 0May 6 Linux: 0 Mac: 0 Windows: 0May 5 Linux: 0 Mac: 0 Windows: 0May 4 Linux: 0 Mac: 0 Windows: 0May 3 Linux: 0 Mac: 0 Windows: 0May 2 Linux: 0 Mac: 0 Windows: 0May 1 Linux: 0 Mac: 0 Windows: 0Apr 30 Linux: 0 Mac: 0 Windows: 0Apr 29 Linux: 0 Mac: 0 Windows: 0Apr 28 Linux: 0 Mac: 0 Windows: 0Apr 27 Linux: 0 Mac: 0 Windows: 0Apr 26 Linux: 0 Mac: 0 Windows: 0Apr 25 Linux: 0 Mac: 0 Windows: 0Apr 24 Linux: 0 Mac: 0 Windows: 0Apr 23 Linux: 0 Mac: 0 Windows: 0Apr 22 Linux: 0 Mac: 0 Windows: 0Apr 21 Linux: 0 Mac: 0 Windows: 0Apr 20 Linux: 0 Mac: 0 Windows: 0Apr 19 Linux: 0 Mac: 0 Windows: 0Apr 18 Linux: 0 Mac: 0 Windows: 0Apr 17 Linux: 0 Mac: 0 Windows: 0Apr 16 Linux: 0 Mac: 0 Windows: 0Apr 15 Linux: 0 Mac: 0 Windows: 0Apr 14 Linux: 0 Mac: 0 Windows: 0Apr 13 Linux: 0 Mac: 0 Windows: 0Apr 12 Linux: 0 Mac: 0 Windows: 0Apr 11 Linux: 0 Mac: 0 Windows: 0Apr 10 Linux: 0 Mac: 0 Windows: 0Apr 9 Linux: 0 Mac: 0 Windows: 0Apr 8 Linux: 0 Mac: 0 Windows: 0Apr 7 Linux: 0 Mac: 0 Windows: 0Apr 6 Linux: 0 Mac: 0 Windows: 0Apr 5 Linux: 0 Mac: 0 Windows: 0Apr 4 Linux: 0 Mac: 0 Windows: 0Apr 3 Linux: 0 Mac: 0 Windows: 0May 17 Linux: 0 Mac: 0 Windows: 0May 16 Linux: 0 Mac: 0 Windows: 0May 15 Linux: 0 Mac: 0 Windows: 0May 14 Linux: 0 Mac: 0 Windows: 0May 13 Linux: 0 Mac: 0 Windows: 0May 12 Linux: 0 Mac: 0 Windows: 0May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 0 Mac: 0 Windows: 0May 9 Linux: 0 Mac: 0 Windows: 0May 8 Linux: 0 Mac: 0 Windows: 0May 7 Linux: 0 Mac: 0 Windows: 0May 6 Linux: 0 Mac: 0 Windows: 0May 5 Linux: 0 Mac: 0 Windows: 0May 4 Linux: 0 Mac: 0 Windows: 0May 3 Linux: 0 Mac: 0 Windows: 0May 2 Linux: 0 Mac: 0 Windows: 0May 1 Linux: 0 Mac: 0 Windows: 0Apr 30 Linux: 0 Mac: 0 Windows: 0Apr 29 Linux: 0 Mac: 0 Windows: 0Apr 28 Linux: 0 Mac: 0 Windows: 0Apr 27 Linux: 0 Mac: 0 Windows: 0Apr 26 Linux: 0 Mac: 0 Windows: 0Apr 25 Linux: 0 Mac: 0 Windows: 0Apr 24 Linux: 0 Mac: 0 Windows: 0Apr 23 Linux: 0 Mac: 0 Windows: 0Apr 22 Linux: 0 Mac: 0 Windows: 0Apr 21 Linux: 0 Mac: 0 Windows: 0Apr 20 Linux: 0 Mac: 0 Windows: 0Apr 19 Linux: 0 Mac: 0 Windows: 0Apr 18 Linux: 0 Mac: 0 Windows: 0Apr 17 Linux: 0 Mac: 0 Windows: 0Apr 16 Linux: 0 Mac: 0 Windows: 0Apr 15 Linux: 0 Mac: 0 Windows: 0Apr 14 Linux: 0 Mac: 0 Windows: 0Apr 13 Linux: 0 Mac: 0 Windows: 0Apr 12 Linux: 0 Mac: 0 Windows: 0Apr 11 Linux: 0 Mac: 0 Windows: 0Apr 10 Linux: 0 Mac: 0 Windows: 0Apr 9 Linux: 0 Mac: 0 Windows: 0Apr 8 Linux: 0 Mac: 0 Windows: 0Apr 7 Linux: 0 Mac: 0 Windows: 0Apr 6 Linux: 0 Mac: 0 Windows: 0Apr 5 Linux: 0 Mac: 0 Windows: 0Apr 4 Linux: 0 Mac: 0 Windows: 0Apr 3 Linux: 0 Mac: 0 Windows: 0May 17 Linux: 0 Mac: 0 Windows: 0May 16 Linux: 0 Mac: 0 Windows: 0May 15 Linux: 0 Mac: 0 Windows: 0May 14 Linux: 0 Mac: 0 Windows: 0May 13 Linux: 0 Mac: 0 Windows: 0May 12 Linux: 0 Mac: 0 Windows: 0May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 0 Mac: 0 Windows: 0May 9 Linux: 0 Mac: 0 Windows: 0May 8 Linux: 0 Mac: 0 Windows: 0May 7 Linux: 0 Mac: 0 Windows: 0May 6 Linux: 0 Mac: 0 Windows: 0May 5 Linux: 0 Mac: 0 Windows: 0May 4 Linux: 0 Mac: 0 Windows: 0May 3 Linux: 0 Mac: 0 Windows: 0May 2 Linux: 0 Mac: 0 Windows: 0May 1 Linux: 0 Mac: 0 Windows: 0Apr 30 Linux: 0 Mac: 0 Windows: 0Apr 29 Linux: 0 Mac: 0 Windows: 0Apr 28 Linux: 0 Mac: 0 Windows: 0Apr 27 Linux: 0 Mac: 0 Windows: 0Apr 26 Linux: 0 Mac: 0 Windows: 0Apr 25 Linux: 0 Mac: 0 Windows: 0Apr 24 Linux: 0 Mac: 0 Windows: 0Apr 23 Linux: 0 Mac: 0 Windows: 0Apr 22 Linux: 0 Mac: 0 Windows: 0Apr 21 Linux: 0 Mac: 0 Windows: 0Apr 20 Linux: 0 Mac: 0 Windows: 0Apr 19 Linux: 0 Mac: 0 Windows: 0Apr 18 Linux: 0 Mac: 0 Windows: 0Apr 17 Linux: 0 Mac: 0 Windows: 0Apr 16 Linux: 0 Mac: 0 Windows: 0Apr 15 Linux: 0 Mac: 0 Windows: 0Apr 14 Linux: 0 Mac: 0 Windows: 0Apr 13 Linux: 0 Mac: 0 Windows: 0Apr 12 Linux: 0 Mac: 0 Windows: 0Apr 11 Linux: 0 Mac: 0 Windows: 0Apr 10 Linux: 0 Mac: 0 Windows: 0Apr 9 Linux: 0 Mac: 0 Windows: 0Apr 8 Linux: 0 Mac: 0 Windows: 0Apr 7 Linux: 0 Mac: 0 Windows: 0Apr 6 Linux: 0 Mac: 0 Windows: 0Apr 5 Linux: 0 Mac: 0 Windows: 0Apr 4 Linux: 0 Mac: 0 Windows: 0Apr 3 Linux: 0 Mac: 0 Windows: 0

Readme

Source
raw.​githubusercontent.​com

About

Preview is a Sublime Text 2/3 plugin that maps your local project files to URLs and opens them in your browser for preview.

Installation for Sublime Text 2

  • Install 'Package Control', then search for 'Preview' and install

Installation for Sublime Text 3

  • In Sublime Text 3, go to Preferences > Browse Packages, create a folder called Preview there and put the contents of the repo in this folder

Initial setup

Edit plugin settings (Preferences > Package Settings > Preview > Settings — User) and provide mapping rules, like this:

{
    "rules": [
        // prohibit previewing local files (i.e. files that don't match any rule)
        {
            "url": ""
        },

        // allow opening local .htm, .html and .xhtml in browser
        {
            "path_suffix": ".htm",
            "url_prefix": "file:///"
        },
        {
            "path_suffix": ".html",
            "url_prefix": "file:///"
        },
        {
            "path_suffix": ".xhtml",
            "url_prefix": "file:///"
        },

        // sample website
        {
            // for all files matching the path_prefix, construct URL using url_prefix
            "path_prefix": "C:/Work/www/",
            "url_prefix": "http://localhost/",
            // append this string to all URLs
            "url_append": "?debug"
        },
        {
            // files in /inc/ subdirectory can't be previewed directly, so just open the root URL
            "path_prefix": "C:/Work/www/inc/",
            "url": "http://localhost/"
        },
        {
            // when editing .htaccess files, just open the containing folder
            "path_prefix": "C:/Work/www/inc/",
            "path_suffix": "/.htaccess",
            "url_prefix": "http://localhost/",
            "url_suffix": "/"
        }
    ]
}

In addition to matching files by path_prefix and replacing this with url_prefix, you can also define path_suffix (for example, a file extension) and replace it with url_suffix. If url_suffix is not defined, then path_suffix will not be removed from a final URL.

In contrast to url_suffix, an optional url_append parameter allows to add some text to an end of the URL without having the matching path_suffix replaced.

path_prefix and path_suffix are case-sensitive. Mind the trailing slashes. Under Windows, you can use both \\ and / as path delimiters.

Rules are applied top to bottom. If file path matches several rules, the last rule is used. You can use this to define mapping overrides.

Usage

Pressing F12 will map current file to an URL and open this URL in your default browser. If no rule is matched, the file will be opened locally as file:///... in a program associated with this file extension (not necessarily a browser).

Version 1.1

Added compatibility with Sublime Text 3

Version 1.0

Initial release