From 665b9ba01306ce08e682840e1c6f41ede75f3e85 Mon Sep 17 00:00:00 2001 From: murmeldin Date: Sun, 9 Feb 2025 01:11:16 +0100 Subject: [PATCH] right install method + fixed hedgedoc bugs --- shell.nix | 25 +++++++++++++++++++++++++ src/hedgedoc.rs | 4 ++-- src/main.rs | 15 +++++---------- util/install_script_ubuntu.sh | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..42abca8 --- /dev/null +++ b/shell.nix @@ -0,0 +1,25 @@ +{pkgs ? import {}}: let + rust-toolchain = pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = with pkgs; [rustc cargo rustPlatform.rustcSrc rustfmt clippy]; + }; +in + pkgs.mkShell { + nativeBuildInputs = with pkgs.buildPackages; [ + rust-toolchain + + pkg-config + xe + xz + + cargo-tarpaulin + openssl + sqlite + gcc + gnumake + + # dotnet-sdk_8 + ]; + + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + } diff --git a/src/hedgedoc.rs b/src/hedgedoc.rs index 514f081..9c091e0 100644 --- a/src/hedgedoc.rs +++ b/src/hedgedoc.rs @@ -156,9 +156,9 @@ impl HedgeDoc { pub fn rotate(config: &KeyValueStore, is_dry_run: bool) -> Result> { let hold_pad_id = &config["hedgedoc-next-id"]; - config.set("hedgedoc-last-id", hold_pad_id); + config.set("hedgedoc-last-id", hold_pad_id)?; let new_id = HedgeDoc::new(&config.get("hedgedoc-server-url").unwrap(), is_dry_run).create_pad()?; - config.set("hedgedoc-next-id", &new_id); + config.set("hedgedoc-next-id", &new_id)?; Ok(new_id) } diff --git a/src/main.rs b/src/main.rs index f237b4f..7c7f1ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use cccron_lib::config_spec::{self, CfgField, CfgGroup, CfgSpec}; use cccron_lib::date; use cccron_lib::email::{self, Email, SimpleEmail}; -use cccron_lib::hedgedoc::{self, HedgeDoc}; +use cccron_lib::hedgedoc::{self, HedgeDoc,}; use cccron_lib::is_dry_run; use cccron_lib::key_value::{KeyValueStore as KV, KeyValueStore}; use cccron_lib::matrix::{self, MatrixClient}; @@ -306,7 +306,7 @@ fn topic_count(n: usize, dative: bool) -> String { fn get_pad_info(config: &KV, hedgedoc: &HedgeDoc) -> (String, String, String, usize) { let current_pad_id = &config["hedgedoc-last-id"]; let pad_content = hedgedoc.download(current_pad_id).expect("Hedgedoc: Download-Fehler"); - let toc = hedgedoc::summarize(pad_content.clone()); + let toc = hedgedoc.summarize(pad_content.clone()); verboseln!("Zusammenfassung des aktuellen Plenum-Pads:\n{}", toc.cyan()); let n_topics = toc.lines().count(); verboseln!("(Also {}.)", topic_count(n_topics, false).cyan()); @@ -436,7 +436,7 @@ fn do_protocol( nyi!("trace/verbose annotations"); let (_current_pad_id, pad_content_without_cleanup, toc, n_topics) = get_pad_info(config, hedgedoc); - let pad_content = hedgedoc::strip_metadata(pad_content_without_cleanup.clone()); + let pad_content = HedgeDoc::strip_metadata(pad_content_without_cleanup.clone()); let ollama_enabled: bool = match &config["hedgedoc-ollama-summaries-enabled"] { "True" => true, "False" => false, @@ -449,12 +449,7 @@ fn do_protocol( let ollama_port: &u16 = &config["hedgedoc-ollama-port"] .parse::() .expect("The ollama port wasn't given a valid u16 port, please check the config"); - match hedgedoc::summarize_with_ollama( - &pad_content, - &config["hedgedoc-ollama-pre-prompt"], - &config["hedgedoc-ollama-address"], - ollama_port, - ) { + match HedgeDoc::summarize_with_ollama(&pad_content, &config["hedgedoc-ollama-pre-prompt"], &config["hedgedoc-ollama-address"], ollama_port) { Ok(ollama_summary) => ollama_summary, Err(err) => { eprintln!("Ollama failed, continuing with standard toc. This was the error Message: {err}"); @@ -482,7 +477,7 @@ fn do_protocol( ); let _message_id = send_email(&subject, &body, email, config)?; mediawiki::pad_ins_wiki(pad_content, wiki, plenum_day)?; - let new_id = hedgedoc::rotate(config, is_dry_run())?; + let new_id = HedgeDoc::rotate(config, is_dry_run())?; println!("Generated new pad with id '{}'", new_id); config.set("state-name", &ProgramState::Logged.to_string()).ok(); } else { diff --git a/util/install_script_ubuntu.sh b/util/install_script_ubuntu.sh index 955e926..86e5d58 100644 --- a/util/install_script_ubuntu.sh +++ b/util/install_script_ubuntu.sh @@ -15,5 +15,5 @@ git pull sudo apt update sudo apt upgrade -y sudo apt install gcc libssl-dev pandoc pkg-config libsqlite3-dev -cargo build --release +cargo install --path . sudo ./update_or_create_systemd_service.sh \ No newline at end of file