right install method + fixed hedgedoc bugs
This commit is contained in:
parent
8df8d6eee6
commit
665b9ba013
25
shell.nix
Normal file
25
shell.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{pkgs ? import <nixpkgs> {}}: 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}";
|
||||||
|
}
|
|
@ -156,9 +156,9 @@ impl HedgeDoc {
|
||||||
|
|
||||||
pub fn rotate(config: &KeyValueStore, is_dry_run: bool) -> Result<String, Box<dyn Error>> {
|
pub fn rotate(config: &KeyValueStore, is_dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||||
let hold_pad_id = &config["hedgedoc-next-id"];
|
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()?;
|
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)
|
Ok(new_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -3,7 +3,7 @@
|
||||||
use cccron_lib::config_spec::{self, CfgField, CfgGroup, CfgSpec};
|
use cccron_lib::config_spec::{self, CfgField, CfgGroup, CfgSpec};
|
||||||
use cccron_lib::date;
|
use cccron_lib::date;
|
||||||
use cccron_lib::email::{self, Email, SimpleEmail};
|
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::is_dry_run;
|
||||||
use cccron_lib::key_value::{KeyValueStore as KV, KeyValueStore};
|
use cccron_lib::key_value::{KeyValueStore as KV, KeyValueStore};
|
||||||
use cccron_lib::matrix::{self, MatrixClient};
|
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) {
|
fn get_pad_info(config: &KV, hedgedoc: &HedgeDoc) -> (String, String, String, usize) {
|
||||||
let current_pad_id = &config["hedgedoc-last-id"];
|
let current_pad_id = &config["hedgedoc-last-id"];
|
||||||
let pad_content = hedgedoc.download(current_pad_id).expect("Hedgedoc: Download-Fehler");
|
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());
|
verboseln!("Zusammenfassung des aktuellen Plenum-Pads:\n{}", toc.cyan());
|
||||||
let n_topics = toc.lines().count();
|
let n_topics = toc.lines().count();
|
||||||
verboseln!("(Also {}.)", topic_count(n_topics, false).cyan());
|
verboseln!("(Also {}.)", topic_count(n_topics, false).cyan());
|
||||||
|
@ -436,7 +436,7 @@ fn do_protocol(
|
||||||
nyi!("trace/verbose annotations");
|
nyi!("trace/verbose annotations");
|
||||||
let (_current_pad_id, pad_content_without_cleanup, toc, n_topics) =
|
let (_current_pad_id, pad_content_without_cleanup, toc, n_topics) =
|
||||||
get_pad_info(config, hedgedoc);
|
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"] {
|
let ollama_enabled: bool = match &config["hedgedoc-ollama-summaries-enabled"] {
|
||||||
"True" => true,
|
"True" => true,
|
||||||
"False" => false,
|
"False" => false,
|
||||||
|
@ -449,12 +449,7 @@ fn do_protocol(
|
||||||
let ollama_port: &u16 = &config["hedgedoc-ollama-port"]
|
let ollama_port: &u16 = &config["hedgedoc-ollama-port"]
|
||||||
.parse::<u16>()
|
.parse::<u16>()
|
||||||
.expect("The ollama port wasn't given a valid u16 port, please check the config");
|
.expect("The ollama port wasn't given a valid u16 port, please check the config");
|
||||||
match hedgedoc::summarize_with_ollama(
|
match HedgeDoc::summarize_with_ollama(&pad_content, &config["hedgedoc-ollama-pre-prompt"], &config["hedgedoc-ollama-address"], ollama_port) {
|
||||||
&pad_content,
|
|
||||||
&config["hedgedoc-ollama-pre-prompt"],
|
|
||||||
&config["hedgedoc-ollama-address"],
|
|
||||||
ollama_port,
|
|
||||||
) {
|
|
||||||
Ok(ollama_summary) => ollama_summary,
|
Ok(ollama_summary) => ollama_summary,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Ollama failed, continuing with standard toc. This was the error Message: {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)?;
|
let _message_id = send_email(&subject, &body, email, config)?;
|
||||||
mediawiki::pad_ins_wiki(pad_content, wiki, plenum_day)?;
|
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);
|
println!("Generated new pad with id '{}'", new_id);
|
||||||
config.set("state-name", &ProgramState::Logged.to_string()).ok();
|
config.set("state-name", &ProgramState::Logged.to_string()).ok();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,5 +15,5 @@ git pull
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt upgrade -y
|
sudo apt upgrade -y
|
||||||
sudo apt install gcc libssl-dev pandoc pkg-config libsqlite3-dev
|
sudo apt install gcc libssl-dev pandoc pkg-config libsqlite3-dev
|
||||||
cargo build --release
|
cargo install --path .
|
||||||
sudo ./update_or_create_systemd_service.sh
|
sudo ./update_or_create_systemd_service.sh
|
Loading…
Reference in a new issue