From 657905ed6e70c35f2e17a1e589217cd197d4aa69 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 22 Dec 2020 21:35:15 +0100 Subject: [PATCH] Remove watch-only --- CHANGELOG.md | 1 + components/site/tests/site.rs | 2 +- src/cli.rs | 4 ---- src/cmd/serve.rs | 40 +++++++++++++++-------------------- src/main.rs | 6 ++---- test_site/config.staging.toml | 3 +++ test_site/config.toml | 7 +++--- test_site_i18n/config.toml | 8 +++---- 8 files changed, 32 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b05fcd0..c0afe8aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 content - 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) diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index a925a96c..e5d34437 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -669,7 +669,7 @@ fn can_build_with_extra_syntaxes() { assert!(file_contains!( public, "posts/extra-syntax/index.html", - r#"test"# + r#" App<'static, 'static> { .default_value("127.0.0.1") .takes_value(true) .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") .long("drafts") .takes_value(false) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 4f1d4dbd..c580d29e 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -145,25 +145,23 @@ fn not_found(content: Option) -> Response { .expect("Could not build Not Found response") } -fn rebuild_done_handling(broadcaster: &Option, res: Result<()>, reload_path: &str) { +fn rebuild_done_handling(broadcaster: &Sender, res: Result<()>, reload_path: &str) { match res { Ok(_) => { - if let Some(broadcaster) = broadcaster.as_ref() { - broadcaster - .send(format!( - r#" - {{ - "command": "reload", - "path": "{}", - "originalPath": "", - "liveCSS": true, - "liveImg": true, - "protocol": ["http://livereload.com/protocols/official-7"] - }}"#, - reload_path - )) - .unwrap(); - } + broadcaster + .send(format!( + r#" + {{ + "command": "reload", + "path": "{}", + "originalPath": "", + "liveCSS": true, + "liveImg": true, + "protocol": ["http://livereload.com/protocols/official-7"] + }}"#, + reload_path + )) + .unwrap(); } Err(e) => console::unravel_errors("Failed to build the site", &e), } @@ -217,7 +215,6 @@ pub fn serve( output_dir: Option<&Path>, base_url: &str, config_file: &Path, - watch_only: bool, open: bool, include_drafts: 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 // http closure to avoid contention. let static_root = output_path.clone(); - let broadcaster = if !watch_only { + let broadcaster = { thread::spawn(move || { let addr = address.parse().unwrap(); @@ -347,10 +344,7 @@ pub fn serve( ws_server.run().unwrap(); }); - Some(broadcaster) - } else { - println!("Watching in watch only mode, no web server will be started"); - None + broadcaster }; println!("Listening for changes in {}{{{}}}", root_dir.display(), watchers.join(", ")); diff --git a/src/main.rs b/src/main.rs index 2936354c..7bff8282 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,18 +61,17 @@ fn main() { ::std::process::exit(1); } }; - let watch_only = matches.is_present("watch_only"); let open = matches.is_present("open"); let include_drafts = matches.is_present("drafts"); let fast = matches.is_present("fast"); // 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"); ::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) { p } else { @@ -90,7 +89,6 @@ fn main() { output_dir, base_url, &config_file, - watch_only, open, include_drafts, fast, diff --git a/test_site/config.staging.toml b/test_site/config.staging.toml index b15e8dae..fb45e955 100644 --- a/test_site/config.staging.toml +++ b/test_site/config.staging.toml @@ -3,6 +3,9 @@ base_url = "https://staging.com" highlight_code = true theme = "sample" +[markdown] +highlight_code = true + [extra.author] name = "Vincent Prouillet" diff --git a/test_site/config.toml b/test_site/config.toml index 3efcd691..cf989d60 100644 --- a/test_site/config.toml +++ b/test_site/config.toml @@ -1,6 +1,5 @@ title = "My site" base_url = "https://replace-this-with-your-url.com" -highlight_code = true compile_sass = true generate_feed = true theme = "sample" @@ -10,10 +9,12 @@ taxonomies = [ {name = "podcast_authors", feed = true}, ] -extra_syntaxes = ["syntaxes"] - ignored_content = ["*/ignored.md"] +[markdown] +highlight_code = true +extra_syntaxes = ["syntaxes"] + [slugify] paths = "on" taxonomies = "on" diff --git a/test_site_i18n/config.toml b/test_site_i18n/config.toml index 2d6d34ab..e1c692f4 100644 --- a/test_site_i18n/config.toml +++ b/test_site_i18n/config.toml @@ -4,10 +4,6 @@ base_url = "https://example.com" # Whether to automatically compile all Sass files in the sass directory 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 build_search_index = true @@ -27,5 +23,9 @@ languages = [ {code = "it", feed = false, search = true }, ] +[markdown] +highlight_code = false + + [extra] # Put all your custom variables here