From c9e749f811b16f7ec352d2aa8773105af046fad8 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 7 Oct 2024 16:15:49 +0200 Subject: add func for entry items, UI enhancement - add functions to get url/doi and filepath - get values for entry info from structs not by calling funcs again --- src/backend/bib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/backend/bib.rs') diff --git a/src/backend/bib.rs b/src/backend/bib.rs index 957adb1..3e0e844 100644 --- a/src/backend/bib.rs +++ b/src/backend/bib.rs @@ -15,10 +15,10 @@ // along with this program. If not, see . ///// -use std::{fs, path::PathBuf}; - use biblatex::{self, Bibliography}; use biblatex::{ChunksExt, Type}; +use color_eyre::eyre::ErrReport; +use std::{fs, path::PathBuf}; // Set necessary fields // TODO: can surely be made more efficient/simpler @@ -128,6 +128,8 @@ pub struct BibiEntry { pub pubtype: String, pub keywords: String, pub citekey: String, + pub weblink: String, + pub filepath: String, } impl BibiEntry { @@ -139,6 +141,9 @@ impl BibiEntry { Self::get_pubtype(&citekey, &biblio), Self::get_keywords(&citekey, &biblio), citekey.to_string(), + Self::get_abstract(&citekey, &biblio), + Self::get_weblink(&citekey, &biblio), + Self::get_filepath(&citekey, &biblio), ] } @@ -265,13 +270,13 @@ impl BibiEntry { } } - pub fn get_filepath(citekey: &str, biblio: &Bibliography) -> PathBuf { + pub fn get_filepath(citekey: &str, biblio: &Bibliography) -> String { if let true = biblio.get(&citekey).unwrap().file().is_ok() { let file = biblio.get(&citekey).unwrap().file().unwrap(); - file.into() + file } else { let file = "".to_string(); - file.into() + file } } } -- cgit v1.2.3