diff options
Diffstat (limited to 'rust/wolfree_libredirect_patch/src/main.rs')
-rw-r--r-- | rust/wolfree_libredirect_patch/src/main.rs | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/rust/wolfree_libredirect_patch/src/main.rs b/rust/wolfree_libredirect_patch/src/main.rs deleted file mode 100644 index 65f1b93..0000000 --- a/rust/wolfree_libredirect_patch/src/main.rs +++ /dev/null @@ -1,95 +0,0 @@ -//! The Rust crate provides lightweight wrappers around the `fs::write` and `fs::remove_dir_all` functions from the standard library's `fs` module. -//! The crate is designed to simplify file writing and directory removal operations by encapsulating the error handling logic and providing a more convenient interface. -//! It is particularly useful for tasks that involve writing multiple files or removing directories with their contents. - -#![allow(clippy::blanket_clippy_restriction_lints)] -#![allow(clippy::exit)] -#![allow(clippy::print_stderr)] -#![allow(clippy::implicit_return)] - -/* SPDX-License-Identifier: AGPL-3.0-or-later - * This file is part of Wolfree. - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - */ - -use markdown::to_html_with_options; -use markdown::Options; -use std::fs; - -/// A lightweight wrapper around `fs::write`. -fn wolfree_write(file_path: &str, contents: &str) { - match fs::write(file_path, contents) { - Ok(_) => (), - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; -} - -/// A lightweight wrapper around `fs::remove_dir_all`. -fn wolfree_remove_dir_all(dir_path: &str) { - match fs::remove_dir_all(dir_path) { - Ok(_) => (), - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; -} - -/// A lightweight wrapper around `markdown::to_html_with_options`. -fn wolfree_to_html_with_options(value: &str) -> String { - match to_html_with_options(value, &Options::gfm()) { - Ok(result) => result, - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - } -} - -/// Entry point of the program. -fn main() { - wolfree_write( - "./docusaurus/build/ajax/libs/wolfree/23.7.8/js/Entrypoint.js", - "export default () => {}", - ); - wolfree_write( - "./docusaurus/build/index.html", - &format!( - "{}{}", - include_str!("head.html"), - wolfree_to_html_with_options(include_str!("body.md")), - ), - ); - wolfree_write( - "./docusaurus/build/instances.json", - include_str!("instances.json"), - ); - wolfree_write( - "./docusaurus/build/404.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/acknowledgment/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/community/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/dmca/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/mirror/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/source/index.html", - "<script>location='/'</script>", - ); - wolfree_remove_dir_all("./docusaurus/build/assets/"); -} |