Remove watch-only

This commit is contained in:
Vincent Prouillet 2020-12-22 21:35:15 +01:00
parent 39870d8675
commit 657905ed6e
8 changed files with 32 additions and 39 deletions

View file

@ -18,6 +18,7 @@ into their typographic forms
- Add iteration count variable `nth` for shortcodes to know how many times a shortcode has been invoked in a given - Add iteration count variable `nth` for shortcodes to know how many times a shortcode has been invoked in a given
content content
- Update some highlighting syntaxes and the TS syntax will now be used instead of JS due to issues with it - Update some highlighting syntaxes and the TS syntax will now be used instead of JS due to issues with it
- Remove `zola serve --watch-only`: since we build the HTML in memory and not on disk, it doesn't make sense anymore
## 0.12.2 (2020-09-28) ## 0.12.2 (2020-09-28)

View file

@ -669,7 +669,7 @@ fn can_build_with_extra_syntaxes() {
assert!(file_contains!( assert!(file_contains!(
public, public,
"posts/extra-syntax/index.html", "posts/extra-syntax/index.html",
r#"<span style="color:#d08770;">test</span>"# r#"<span style="color:"#
)); ));
} }

View file

@ -75,10 +75,6 @@ pub fn build_cli() -> App<'static, 'static> {
.default_value("127.0.0.1") .default_value("127.0.0.1")
.takes_value(true) .takes_value(true)
.help("Changes the base_url"), .help("Changes the base_url"),
Arg::with_name("watch_only")
.long("watch-only")
.takes_value(false)
.help("Do not start a server, just re-build project on changes"),
Arg::with_name("drafts") Arg::with_name("drafts")
.long("drafts") .long("drafts")
.takes_value(false) .takes_value(false)

View file

@ -145,25 +145,23 @@ fn not_found(content: Option<String>) -> Response<Body> {
.expect("Could not build Not Found response") .expect("Could not build Not Found response")
} }
fn rebuild_done_handling(broadcaster: &Option<Sender>, res: Result<()>, reload_path: &str) { fn rebuild_done_handling(broadcaster: &Sender, res: Result<()>, reload_path: &str) {
match res { match res {
Ok(_) => { Ok(_) => {
if let Some(broadcaster) = broadcaster.as_ref() { broadcaster
broadcaster .send(format!(
.send(format!( r#"
r#" {{
{{ "command": "reload",
"command": "reload", "path": "{}",
"path": "{}", "originalPath": "",
"originalPath": "", "liveCSS": true,
"liveCSS": true, "liveImg": true,
"liveImg": true, "protocol": ["http://livereload.com/protocols/official-7"]
"protocol": ["http://livereload.com/protocols/official-7"] }}"#,
}}"#, reload_path
reload_path ))
)) .unwrap();
.unwrap();
}
} }
Err(e) => console::unravel_errors("Failed to build the site", &e), Err(e) => console::unravel_errors("Failed to build the site", &e),
} }
@ -217,7 +215,6 @@ pub fn serve(
output_dir: Option<&Path>, output_dir: Option<&Path>,
base_url: &str, base_url: &str,
config_file: &Path, config_file: &Path,
watch_only: bool,
open: bool, open: bool,
include_drafts: bool, include_drafts: bool,
fast_rebuild: bool, fast_rebuild: bool,
@ -284,7 +281,7 @@ pub fn serve(
// output path is going to need to be moved later on, so clone it for the // output path is going to need to be moved later on, so clone it for the
// http closure to avoid contention. // http closure to avoid contention.
let static_root = output_path.clone(); let static_root = output_path.clone();
let broadcaster = if !watch_only { let broadcaster = {
thread::spawn(move || { thread::spawn(move || {
let addr = address.parse().unwrap(); let addr = address.parse().unwrap();
@ -347,10 +344,7 @@ pub fn serve(
ws_server.run().unwrap(); ws_server.run().unwrap();
}); });
Some(broadcaster) broadcaster
} else {
println!("Watching in watch only mode, no web server will be started");
None
}; };
println!("Listening for changes in {}{{{}}}", root_dir.display(), watchers.join(", ")); println!("Listening for changes in {}{{{}}}", root_dir.display(), watchers.join(", "));

View file

@ -61,18 +61,17 @@ fn main() {
::std::process::exit(1); ::std::process::exit(1);
} }
}; };
let watch_only = matches.is_present("watch_only");
let open = matches.is_present("open"); let open = matches.is_present("open");
let include_drafts = matches.is_present("drafts"); let include_drafts = matches.is_present("drafts");
let fast = matches.is_present("fast"); let fast = matches.is_present("fast");
// Default one // Default one
if port != 1111 && !watch_only && !port_is_available(port) { if port != 1111 && !port_is_available(port) {
console::error("The requested port is not available"); console::error("The requested port is not available");
::std::process::exit(1); ::std::process::exit(1);
} }
if !watch_only && !port_is_available(port) { if !port_is_available(port) {
port = if let Some(p) = get_available_port(1111) { port = if let Some(p) = get_available_port(1111) {
p p
} else { } else {
@ -90,7 +89,6 @@ fn main() {
output_dir, output_dir,
base_url, base_url,
&config_file, &config_file,
watch_only,
open, open,
include_drafts, include_drafts,
fast, fast,

View file

@ -3,6 +3,9 @@ base_url = "https://staging.com"
highlight_code = true highlight_code = true
theme = "sample" theme = "sample"
[markdown]
highlight_code = true
[extra.author] [extra.author]
name = "Vincent Prouillet" name = "Vincent Prouillet"

View file

@ -1,6 +1,5 @@
title = "My site" title = "My site"
base_url = "https://replace-this-with-your-url.com" base_url = "https://replace-this-with-your-url.com"
highlight_code = true
compile_sass = true compile_sass = true
generate_feed = true generate_feed = true
theme = "sample" theme = "sample"
@ -10,10 +9,12 @@ taxonomies = [
{name = "podcast_authors", feed = true}, {name = "podcast_authors", feed = true},
] ]
extra_syntaxes = ["syntaxes"]
ignored_content = ["*/ignored.md"] ignored_content = ["*/ignored.md"]
[markdown]
highlight_code = true
extra_syntaxes = ["syntaxes"]
[slugify] [slugify]
paths = "on" paths = "on"
taxonomies = "on" taxonomies = "on"

View file

@ -4,10 +4,6 @@ base_url = "https://example.com"
# Whether to automatically compile all Sass files in the sass directory # Whether to automatically compile all Sass files in the sass directory
compile_sass = false compile_sass = false
# Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = false
# Whether to build a search index to be used later on by a JavaScript library # Whether to build a search index to be used later on by a JavaScript library
build_search_index = true build_search_index = true
@ -27,5 +23,9 @@ languages = [
{code = "it", feed = false, search = true }, {code = "it", feed = false, search = true },
] ]
[markdown]
highlight_code = false
[extra] [extra]
# Put all your custom variables here # Put all your custom variables here