aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/bib.rs74
-rw-r--r--src/frontend/entries.rs6
-rw-r--r--src/frontend/ui.rs5
-rw-r--r--src/main.rs1
4 files changed, 31 insertions, 55 deletions
diff --git a/src/backend/bib.rs b/src/backend/bib.rs
index 29ce22e..a7df951 100644
--- a/src/backend/bib.rs
+++ b/src/backend/bib.rs
@@ -17,7 +17,6 @@
use biblatex::{self, Bibliography};
use biblatex::{ChunksExt, Type};
-use hayagriva::io::from_yaml_str;
use itertools::Itertools;
use std::{fs, path::PathBuf};
@@ -62,7 +61,7 @@ impl BibiMain {
let bibliography = biblatex::Bibliography::parse(&bibfilestring).unwrap();
let citekeys = Self::get_citekeys(&bibliography);
let keyword_list = Self::collect_tag_list(&citekeys, &bibliography);
- let entry_list = Self::create_entry_list(&citekeys, &bibliography, &bibfile_format);
+ let entry_list = Self::create_entry_list(&citekeys, &bibliography);
Self {
bibfile,
bibfile_format,
@@ -74,14 +73,6 @@ impl BibiMain {
}
}
- fn parse_bibliography(format: &FileFormat, bibfilestring: &str) -> Bibliography {
- if let FileFormat::BibLatex = format {
- biblatex::Bibliography::parse(bibfilestring).unwrap()
- } else if let FileFormat::Hayagriva = format {
- from_yaml_str(&bibfilestring).unwrap()
- }
- }
-
// Check which file format the passed file has
fn check_file_format(main_bibfile: &PathBuf) -> FileFormat {
let extension = main_bibfile.extension().unwrap().to_str();
@@ -95,15 +86,11 @@ impl BibiMain {
}
}
- fn create_entry_list(
- citekeys: &[String],
- bibliography: &Bibliography,
- format: &FileFormat,
- ) -> Vec<BibiData> {
+ fn create_entry_list(citekeys: &[String], bibliography: &Bibliography) -> Vec<BibiData> {
citekeys
.into_iter()
.map(|k| BibiData {
- authors: Self::get_authors(&k, &bibliography, format),
+ authors: Self::get_authors(&k, &bibliography),
title: Self::get_title(&k, &bibliography),
year: Self::get_year(&k, &bibliography),
pubtype: Self::get_pubtype(&k, &bibliography),
@@ -158,41 +145,38 @@ impl BibiMain {
keyword_list
}
- pub fn get_authors(citekey: &str, biblio: &Bibliography, format: &FileFormat) -> String {
- if let FileFormat::BibLatex = format {
- if biblio.get(&citekey).unwrap().author().is_ok() {
- let authors = biblio.get(&citekey).unwrap().author().unwrap();
- if authors.len() > 1 {
- let all_authors = authors.iter().map(|a| &a.name).join(", ");
- all_authors
- } else if authors.len() == 1 {
- let authors = authors[0].name.to_string();
- authors
- } else {
- let editors_authors = format!("empty");
- editors_authors
- }
+ pub fn get_authors(citekey: &str, biblio: &Bibliography) -> String {
+ if biblio.get(&citekey).unwrap().author().is_ok() {
+ let authors = biblio.get(&citekey).unwrap().author().unwrap();
+ if authors.len() > 1 {
+ let all_authors = authors.iter().map(|a| &a.name).join(", ");
+ all_authors
+ } else if authors.len() == 1 {
+ let authors = authors[0].name.to_string();
+ authors
} else {
- if !biblio.get(&citekey).unwrap().editors().unwrap().is_empty() {
- let editors = biblio.get(&citekey).unwrap().editors().unwrap();
- if editors[0].0.len() > 1 {
- // let editors = format!("{} (ed.) et al.", editors[0].0[0].name);
- let mut editors = editors[0].0.iter().map(|e| &e.name).join(", ");
- editors.push_str(" (ed.)");
- editors
- } else if editors[0].0.len() == 1 {
- let editors = format!("{} (ed.)", editors[0].0[0].name);
- editors
- } else {
- let editors_authors = format!("empty");
- editors_authors
- }
+ let editors_authors = format!("empty");
+ editors_authors
+ }
+ } else {
+ if !biblio.get(&citekey).unwrap().editors().unwrap().is_empty() {
+ let editors = biblio.get(&citekey).unwrap().editors().unwrap();
+ if editors[0].0.len() > 1 {
+ // let editors = format!("{} (ed.) et al.", editors[0].0[0].name);
+ let mut editors = editors[0].0.iter().map(|e| &e.name).join(", ");
+ editors.push_str(" (ed.)");
+ editors
+ } else if editors[0].0.len() == 1 {
+ let editors = format!("{} (ed.)", editors[0].0[0].name);
+ editors
} else {
let editors_authors = format!("empty");
editors_authors
}
+ } else {
+ let editors_authors = format!("empty");
+ editors_authors
}
- } else if let FileFormat::Hayagriva = format {
}
}
diff --git a/src/frontend/entries.rs b/src/frontend/entries.rs
index dea970e..6c227df 100644
--- a/src/frontend/entries.rs
+++ b/src/frontend/entries.rs
@@ -17,11 +17,7 @@
use super::app::App;
use super::tui::Tui;
-use crate::backend::{
- bib::{BibiData, BibiMain, FileFormat},
- search::BibiSearch,
-};
-use biblatex::Bibliography;
+use crate::backend::{bib::BibiData, search::BibiSearch};
use color_eyre::eyre::{Context, Ok, Result};
use core::panic;
use editor_command::EditorBuilder;
diff --git a/src/frontend/ui.rs b/src/frontend/ui.rs
index d94a654..4ea275d 100644
--- a/src/frontend/ui.rs
+++ b/src/frontend/ui.rs
@@ -28,10 +28,7 @@ use ratatui::{
},
};
-use crate::{
- backend::bib::BibiMain,
- frontend::{app::App, keywords::TagListItem},
-};
+use crate::frontend::{app::App, keywords::TagListItem};
use super::app::{CurrentArea, FormerArea};
diff --git a/src/main.rs b/src/main.rs
index b90aeea..979c4cf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,7 +17,6 @@
use backend::cliargs::{self, CLIArgs};
use color_eyre::eyre::Result;
-use core::panic;
use errorsetup::init_error_hooks;
use frontend::app::App;