aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/bib.rs15
-rw-r--r--src/backend/search.rs29
2 files changed, 38 insertions, 6 deletions
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 <https://www.gnu.org/licenses/>.
/////
-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
}
}
}
diff --git a/src/backend/search.rs b/src/backend/search.rs
index 7319acc..2c11355 100644
--- a/src/backend/search.rs
+++ b/src/backend/search.rs
@@ -26,7 +26,7 @@ impl Default for BibiSearch {
impl BibiSearch {
// Stringify inner Vec<String> by joining/concat
fn convert_to_string(inner_vec: &Vec<String>) -> String {
- inner_vec.join(" ")
+ inner_vec[0..6].join(" ")
}
// Return a filtered entry list
@@ -89,3 +89,30 @@ impl BibiSearch {
filtered_list
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_vector_join() {
+ let bibvec = vec![
+ "Author".to_string(),
+ "Title".to_string(),
+ "1999".to_string(),
+ "article".to_string(),
+ "hello, bye".to_string(),
+ "author_1999".to_string(),
+ "An abstract with multiple sentences. Sometimes thats necessary".to_string(),
+ "www.bibiman.org".to_string(),
+ "/home/file/path.pdf".to_string(),
+ ];
+
+ let joined_vec = BibiSearch::convert_to_string(&bibvec);
+
+ assert_eq!(
+ joined_vec,
+ "Author Title 1999 article hello, bye author_1999"
+ )
+ }
+}