-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* merge fixes and cleanup * adding setter and resetter functions for *_DIR * attempt to fix #135 in depth * removing debug code * some cleanup + notes * joining across substring for 1.6 * fix joinpath over vector * nth attempt at closing #135 * redirect with query or anchor * cleaning up with uri.path * remove 'append_slash' test
- Loading branch information
Showing
14 changed files
with
178 additions
and
102 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
name = "LiveServer" | ||
uuid = "16fef848-5104-11e9-1b77-fb7a48bbb589" | ||
authors = ["Jonas Asprion <[email protected]", "Thibaut Lienart <[email protected]>"] | ||
version = "1.0.0" | ||
version = "1.0.1" | ||
|
||
[deps] | ||
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" | ||
FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" | ||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" | ||
MIMEs = "6c6e2e6c-3030-632d-7369-2d6c69616d65" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
Crayons = "4" | ||
HTTP = "1" | ||
MIMEs = "0.1" | ||
julia = "1.6" | ||
|
||
[extras] | ||
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test", "Crayons"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,30 @@ | |
[![codecov](https://codecov.io/gh/tlienart/LiveServer.jl/branch/master/graph/badge.svg?token=mNry6r2aIn)](https://codecov.io/gh/tlienart/LiveServer.jl) | ||
[![dev-doc](https://img.shields.io/badge/docs-dev-blue.svg)](https://tlienart.github.io/LiveServer.jl/dev/) | ||
|
||
This is a simple and lightweight development web-server written in Julia, based on [HTTP.jl](https://github.com/JuliaWeb/HTTP.jl). | ||
It has live-reload capability, i.e. when modifying a file, every browser (tab) currently displaying the corresponding page is automatically refreshed. | ||
This is a simple and lightweight development web-server written in Julia, | ||
based on [HTTP.jl](https://github.com/JuliaWeb/HTTP.jl). | ||
It has live-reload capability, i.e. when modifying a file, every browser (tab) | ||
currently displaying the corresponding page is automatically refreshed. | ||
|
||
LiveServer is inspired from Python's [`http.server`](https://docs.python.org/3/library/http.server.html) and Node's [`browsersync`](https://www.browsersync.io/). | ||
LiveServer is inspired from Python's [`http.server`](https://docs.python.org/3/library/http.server.html) | ||
and Node's [`browsersync`](https://www.browsersync.io/). | ||
|
||
## Installation | ||
|
||
To install it in Julia ≥ 1.3, use the package manager with | ||
To install it in Julia ≥ 1.6, use the package manager with | ||
|
||
```julia-repl | ||
pkg> add LiveServer | ||
``` | ||
|
||
### Legacy notes | ||
|
||
For Julia `< 1.6`, you can use LiveServer's version 0.9.2: | ||
|
||
```julia-repl | ||
pkg> add [email protected] | ||
``` | ||
|
||
For Julia `[1.0, 1.3)`, you can use LiveServer's version 0.7.4: | ||
|
||
```julia-repl | ||
|
@@ -25,20 +36,24 @@ pkg> add [email protected] | |
|
||
### Make it a shell command | ||
|
||
LiveServer is a small package and fast to load with one main functionality (`serve`), it can be convenient to make it a shell command: (I'm using the name `lss` here but you could use something else): | ||
LiveServer is a small package and fast to load with one main functionality (`serve`), | ||
it can be convenient to make it a shell command: (I'm using the name `lss` here but | ||
you could use something else): | ||
|
||
``` | ||
alias lss='julia -e "import LiveServer as LS; LS.serve(launch_browser=true)"' | ||
``` | ||
|
||
you can then use `lss` in any directory to show a directory listing in your browser, and if the directory has an `index.html` then that will be rendered in your browser. | ||
you can then use `lss` in any directory to show a directory listing in your browser, | ||
and if the directory has an `index.html` then that will be rendered in your browser. | ||
|
||
## Usage | ||
|
||
The main function `LiveServer` exports is `serve` which starts listening to the current folder and makes its content available to a browser. | ||
The main function `LiveServer` exports is `serve` which starts listening to the current | ||
folder and makes its content available to a browser. | ||
The following code creates an example directory and serves it: | ||
|
||
```julia | ||
```julia-repl | ||
julia> using LiveServer | ||
julia> LiveServer.example() # creates an "example/" folder with some files | ||
julia> cd("example") | ||
|
@@ -47,7 +62,8 @@ julia> serve() # starts the local server & the file watching | |
(use CTRL+C to shut down) | ||
``` | ||
|
||
Open a Browser and go to `http://localhost:8000/` to see the content being rendered; try modifying files (e.g. `index.html`) and watch the changes being rendered immediately in the browser. | ||
Open a Browser and go to `http://localhost:8000/` to see the content being rendered; | ||
try modifying files (e.g. `index.html`) and watch the changes being rendered immediately in the browser. | ||
|
||
In the REPL: | ||
```julia-repl | ||
|
@@ -58,21 +74,25 @@ julia> serve(host="0.0.0.0", port=8001, dir=".") # starts the remote server & th | |
``` | ||
|
||
In the terminal: | ||
```julia-repl | ||
```bash | ||
julia -e 'using LiveServer; serve(host="0.0.0.0", port=8001, dir=".")' | ||
``` | ||
|
||
Open a browser and go to https://localhost:8001/ to see the rendered content of index.html or, if it doesn't exist, the content of the directory. | ||
Open a browser and go to https://localhost:8001/ to see the rendered content of index.html or, | ||
if it doesn't exist, the content of the directory. | ||
You can set the port to a custom number. | ||
This is similar to the [`http.server`](https://docs.python.org/3/library/http.server.html) in Python. | ||
|
||
### Serve docs | ||
|
||
`servedocs` is a convenience function that runs `Documenter` along with `LiveServer` to watch your doc files for any changes and render them in your browser when modifications are detected. | ||
`servedocs` is a convenience function that runs `Documenter` along with `LiveServer` to watch | ||
your doc files for any changes and render them in your browser when modifications are detected. | ||
|
||
Assuming you are in `directory/to/YourPackage.jl`, that you have a `docs/` folder as prescribed by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) and `LiveServer` installed in your global environment, you can run: | ||
Assuming you are in `directory/to/YourPackage.jl`, that you have a `docs/` folder as | ||
prescribed by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) and `LiveServer` | ||
installed in your global environment, you can run: | ||
|
||
```julia | ||
```julia-repl | ||
$ julia | ||
pkg> activate docs | ||
|
@@ -88,12 +108,23 @@ julia> servedocs() | |
(use CTRL+C to shut down) | ||
``` | ||
|
||
Open a browser and go to `http://localhost:8000/` to see your docs being rendered; try modifying files (e.g. `docs/index.md`) and watch the changes being rendered in the browser. | ||
Open a browser and go to `http://localhost:8000/` to see your docs being rendered; | ||
try modifying files (e.g. `docs/index.md`) and watch the changes being rendered in the browser. | ||
|
||
To run the server with one line of code, run: | ||
|
||
``` | ||
$ julia --project=docs -ie 'using YourPackage, LiveServer; servedocs()' | ||
``` | ||
|
||
**Note**: this works with [Literate.jl](https://github.com/fredrikekre/Literate.jl) as well. See [the docs](https://tlienart.github.io/LiveServer.jl/dev/man/ls+lit/). | ||
**Note**: this works with [Literate.jl](https://github.com/fredrikekre/Literate.jl) as well. | ||
See [the docs](https://tlienart.github.io/LiveServer.jl/dev/man/ls+lit/). | ||
|
||
|
||
## DEV/Path testing | ||
|
||
See also issue #135 and related PRs. | ||
|
||
* `servedocs()`, navigate to literate, images should show | ||
* `serve()` navigate manually to `docs/build/` should show, remove trailing slash in URL `docs/build` should redirect to `docs/build/` | ||
* `serve(dir=...)` should work + when navigating to assets etc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,5 +78,5 @@ LiveServer.scan_docs! | |
|
||
```@docs | ||
LiveServer.example | ||
LiveServer.setverbose | ||
LiveServer.set_verbose | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
34c74e0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
34c74e0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/68249
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: