aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/bibiman.rs4
-rw-r--r--src/bibiman/entries.rs115
-rw-r--r--tests/multi-files/bibfile1.bib24
-rw-r--r--tests/multi-files/bibfile2.bib11
6 files changed, 29 insertions, 129 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 51cf869..8135696 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -86,7 +86,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bibiman"
-version = "0.9.3"
+version = "0.10.0"
dependencies = [
"arboard",
"biblatex",
diff --git a/Cargo.toml b/Cargo.toml
index 6323ac2..baa65b9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bibiman"
-version = "0.9.3"
+version = "0.10.0"
authors = ["lukeflo <lukeflo_git@posteo.de>"]
license = "GPL-3.0-or-later"
repository = "https://codeberg.org/lukeflo/bibiman"
diff --git a/src/bibiman.rs b/src/bibiman.rs
index ee769c4..71288ce 100644
--- a/src/bibiman.rs
+++ b/src/bibiman.rs
@@ -332,9 +332,9 @@ impl Bibiman {
.citekey
.clone();
- // Add curly brace as prefix and comma as suffix that only
+ // Add comma as suffix that only
// main citekeys are matched, not other fields like crossref
- let citekey_pattern: String = format!("{{{},", citekey);
+ let citekey_pattern: String = format!("{},", citekey);
// Check if multiple files were passed to bibiman and
// return the correct file path
diff --git a/src/bibiman/entries.rs b/src/bibiman/entries.rs
index 961e66d..b7c7c9b 100644
--- a/src/bibiman/entries.rs
+++ b/src/bibiman/entries.rs
@@ -15,8 +15,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/////
-use std::ffi::{OsStr, OsString};
-
use crate::bibiman::bibisetup::BibiData;
use ratatui::widgets::{ScrollbarState, TableState};
@@ -44,8 +42,9 @@ pub struct EntryTable {
impl EntryTable {
pub fn new(entry_list: Vec<BibiData>) -> Self {
- // let entry_table_items = Self::set_entry_table(entry_list);
- let entry_table_items = entry_list;
+ let mut entry_table_items = entry_list;
+ entry_table_items.sort_by(|a, b| a.authors.to_lowercase().cmp(&b.authors.to_lowercase()));
+ // entry_table
let entry_table_state = TableState::default()
.with_selected(0)
.with_selected_column(0)
@@ -65,29 +64,6 @@ impl EntryTable {
}
}
- // pub fn set_entry_table(entry_list: &[BibiData]) -> Vec<EntryTableItem> {
- // let mut entry_table: Vec<EntryTableItem> = entry_list
- // .iter()
- // .map(|e| EntryTableItem {
- // id: e.id,
- // authors: &e.authors,
- // short_author: String::new(),
- // title: &e.title,
- // year: &e.year,
- // pubtype: &e.pubtype,
- // keywords: &e.keywords,
- // citekey: &e.citekey,
- // abstract_text: &e.abstract_text,
- // doi_url: e.doi_url.as_deref(),
- // filepath: e.filepath.clone(),
- // subtitle: e.subtitle.as_deref(),
- // })
- // .collect();
-
- // entry_table.sort_by(|a, b| a.authors.to_lowercase().cmp(&b.authors.to_lowercase()));
- // entry_table
- // }
-
pub fn sort_by_id(&mut self) {
if self.entry_table_sorted_by_col.is_some() {
self.entry_table_reversed_sort = false
@@ -152,91 +128,6 @@ impl EntryTable {
}
}
-// // Define contents of each entry table row
-// #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
-// pub struct EntryTableItem {
-// pub id: u32,
-// pub authors: String,
-// pub short_author: String,
-// pub title: String,
-// pub year: String,
-// pub pubtype: String,
-// pub keywords: String,
-// pub citekey: String,
-// pub abstract_text: String,
-// pub doi_url: Option<String>,
-// pub filepath: Option<OsString>,
-// pub subtitle: Option<String>,
-// }
-
-// impl EntryTableItem {
-// // This functions decides which fields are rendered in the entry table
-// // Fields which should be usable but not visible can be left out
-// pub fn ref_vec(&mut self) -> Vec<&str> {
-// self.short_author = match self.authors.split_once(",") {
-// Some((first, _rest)) => {
-// if self.authors().contains("(ed.)") {
-// let first_author = format!("{} et al. (ed.)", first);
-// first_author
-// } else {
-// let first_author = format!("{} et al.", first);
-// first_author
-// }
-// }
-// None => String::from(""),
-// };
-
-// vec![
-// {
-// if self.short_author.is_empty() {
-// self.authors()
-// } else {
-// &self.short_author
-// }
-// },
-// self.title(),
-// self.year(),
-// self.pubtype(),
-// ]
-// }
-
-// pub fn entry_id(&self) -> &u32 {
-// &self.id
-// }
-
-// pub fn authors(&self) -> &str {
-// &self.authors
-// }
-
-// pub fn title(&self) -> &str {
-// &self.title
-// }
-
-// pub fn year(&self) -> &str {
-// &self.year
-// }
-
-// pub fn pubtype(&self) -> &str {
-// &self.pubtype
-// }
-
-// pub fn citekey(&self) -> &str {
-// &self.citekey
-// }
-
-// pub fn doi_url(&self) -> &str {
-// self.doi_url.as_ref().unwrap()
-// }
-
-// pub fn filepath(&self) -> &OsStr {
-// self.filepath.as_ref().unwrap()
-// }
-
-// pub fn subtitle(&self) -> &str {
-// self.subtitle.as_ref().unwrap()
-// }
-// }
-
#[cfg(test)]
mod tests {
use crate::bibiman::BibiData;
diff --git a/tests/multi-files/bibfile1.bib b/tests/multi-files/bibfile1.bib
index 230a517..9239626 100644
--- a/tests/multi-files/bibfile1.bib
+++ b/tests/multi-files/bibfile1.bib
@@ -12,16 +12,14 @@
annotation = {A \texttt{collection} entry providing the excerpt information for the \texttt{doody} entry. Note the format of the \texttt{pages} field},
}
-@book{
- Bernal_2001,
- title={Black Athena Writes Back: Martin Bernal Responds to His Critics},
- ISBN={9780822380078},
- url={http://dx.doi.org/10.1515/9780822380078},
- DOI={10.1515/9780822380078},
- publisher={Duke University Press},
- author={Bernal, Martin},
- editor={Moore, David Chioni},
- year={2001},
- month=sep,
- file = {}
-} \ No newline at end of file
+@book{Bernal_2001,
+ title = {Black Athena Writes Back: Martin Bernal Responds to His Critics},
+ author = {Bernal, Martin},
+ year = {2001},
+ month = sep,
+ publisher = {Duke University Press},
+ doi = {10.1515/9780822380078},
+ isbn = {9780822380078},
+ url = {http://dx.doi.org/10.1515/9780822380078},
+ editor = {Moore, David Chioni},
+}
diff --git a/tests/multi-files/bibfile2.bib b/tests/multi-files/bibfile2.bib
index 85038d2..465d048 100644
--- a/tests/multi-files/bibfile2.bib
+++ b/tests/multi-files/bibfile2.bib
@@ -8,3 +8,14 @@
date = {2006},
indextitle = {Effect of immobilization on catalytic characteristics},
}
+
+@article{https://doi.org/10.34780/3zczgz54,
+ title = {Between Legacy and Innovation – Archaeological Data Re-use and Integration},
+ author = {Ward, Chloë},
+ year = {2024},
+ publisher = {Journal of Global Archaeology},
+ doi = {10.34780/3ZCZGZ54},
+ url = {https://publications.dainst.org/journals/joga/article/view/4578},
+ keywords = {Sudan Archaeology, Nubia Archaeology, Legacy Data, Data Re-use},
+ language = {en},
+}