Added gitpod config
This commit is contained in:
parent
ce0c5f1d07
commit
68c6966136
|
@ -0,0 +1,12 @@
|
||||||
|
ports:
|
||||||
|
- port: 3000
|
||||||
|
onOpen: open-preview
|
||||||
|
- port: 3001
|
||||||
|
onOpen: ignore
|
||||||
|
tasks:
|
||||||
|
- init: cargo build
|
||||||
|
command: >
|
||||||
|
cd ./book-example &&
|
||||||
|
../target/debug/mdbook serve \
|
||||||
|
--hostname 0.0.0.0 \
|
||||||
|
--websocket-url $(echo $GITPOD_WORKSPACE_URL | sed 's/https:\/\//wss:\/\/3001-/g')
|
13
README.md
13
README.md
|
@ -17,6 +17,7 @@
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<a href="https://crates.io/crates/mdbook"><img src="https://img.shields.io/crates/v/mdbook.svg"></a>
|
<a href="https://crates.io/crates/mdbook"><img src="https://img.shields.io/crates/v/mdbook.svg"></a>
|
||||||
<a href="LICENSE"><img src="https://img.shields.io/github/license/rust-lang-nursery/mdBook.svg"></a>
|
<a href="LICENSE"><img src="https://img.shields.io/github/license/rust-lang-nursery/mdBook.svg"></a>
|
||||||
|
<a href="https://gitpod.io/from-referrer/"><img src="https://img.shields.io/badge/setup-automated-blue?logo=gitpod"></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -79,8 +80,11 @@ There are multiple ways to install mdBook.
|
||||||
|
|
||||||
4. **For Contributions**
|
4. **For Contributions**
|
||||||
|
|
||||||
If you want to contribute to mdBook you will have to clone the repository on
|
If you want to contribute to mdBook you have two options:
|
||||||
your local machine:
|
|
||||||
|
***Local Development***
|
||||||
|
|
||||||
|
Clone the repository on your local machine:
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/rust-lang-nursery/mdBook.git
|
git clone https://github.com/rust-lang-nursery/mdBook.git
|
||||||
|
@ -95,6 +99,11 @@ There are multiple ways to install mdBook.
|
||||||
The resulting binary can be found in `mdBook/target/debug/` under the name
|
The resulting binary can be found in `mdBook/target/debug/` under the name
|
||||||
`mdBook` or `mdBook.exe`.
|
`mdBook` or `mdBook.exe`.
|
||||||
|
|
||||||
|
***Online Development***
|
||||||
|
|
||||||
|
You can start a readily configured online workspace using Gitpod.
|
||||||
|
|
||||||
|
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/rust-lang-nursery/mdBook)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,13 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||||
.empty_values(false)
|
.empty_values(false)
|
||||||
.help("Port to use for WebSockets livereload connections"),
|
.help("Port to use for WebSockets livereload connections"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("websocket-url")
|
||||||
|
.long("websocket-url")
|
||||||
|
.takes_value(true)
|
||||||
|
.empty_values(false)
|
||||||
|
.help("URL to use for WebSockets livereload connections (Defaults to 'ws://{websocket-hostname}:{websocket-port})')"),
|
||||||
|
)
|
||||||
.arg_from_usage("-o, --open 'Opens the book server in a web browser'")
|
.arg_from_usage("-o, --open 'Opens the book server in a web browser'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,17 +74,21 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
let mut book = MDBook::load(&book_dir)?;
|
let mut book = MDBook::load(&book_dir)?;
|
||||||
|
|
||||||
let port = args.value_of("port").unwrap();
|
let port = args.value_of("port").unwrap();
|
||||||
let ws_port = args.value_of("websocket-port").unwrap();
|
|
||||||
let hostname = args.value_of("hostname").unwrap();
|
let hostname = args.value_of("hostname").unwrap();
|
||||||
let public_address = args.value_of("websocket-hostname").unwrap_or(hostname);
|
let ws_port = args.value_of("websocket-port").unwrap();
|
||||||
|
let ws_hostname = args.value_of("websocket-hostname").unwrap_or(hostname);
|
||||||
|
let ws_url = match args.value_of("websocket-url") {
|
||||||
|
Some(url) => String::from(url),
|
||||||
|
None => format!("ws://{}:{}", ws_hostname, ws_port)
|
||||||
|
};
|
||||||
|
let ws_url = &ws_url[..];
|
||||||
let open_browser = args.is_present("open");
|
let open_browser = args.is_present("open");
|
||||||
|
|
||||||
let address = format!("{}:{}", hostname, port);
|
let address = format!("{}:{}", hostname, port);
|
||||||
let ws_address = format!("{}:{}", hostname, ws_port);
|
let ws_address = format!("{}:{}", hostname, ws_port);
|
||||||
|
|
||||||
let livereload_url = format!("ws://{}:{}", public_address, ws_port);
|
|
||||||
book.config
|
book.config
|
||||||
.set("output.html.livereload-url", &livereload_url)?;
|
.set("output.html.livereload-url", &ws_url)?;
|
||||||
|
|
||||||
if let Some(dest_dir) = args.value_of("dest-dir") {
|
if let Some(dest_dir) = args.value_of("dest-dir") {
|
||||||
book.config.build.build_dir = dest_dir.into();
|
book.config.build.build_dir = dest_dir.into();
|
||||||
|
@ -117,7 +128,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
let result = MDBook::load(&book_dir)
|
let result = MDBook::load(&book_dir)
|
||||||
.and_then(|mut b| {
|
.and_then(|mut b| {
|
||||||
b.config
|
b.config
|
||||||
.set("output.html.livereload-url", &livereload_url)?;
|
.set("output.html.livereload-url", &ws_url)?;
|
||||||
Ok(b)
|
Ok(b)
|
||||||
})
|
})
|
||||||
.and_then(|b| b.build());
|
.and_then(|b| b.build());
|
||||||
|
|
Loading…
Reference in New Issue