aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukeflo2025-10-05 11:59:24 +0200
committerlukeflo2025-10-05 11:59:24 +0200
commit606716f064c1151ab9e8617ff76fd4b95f4a2c57 (patch)
tree3fe84b1e98b3f0a549f701b1a43b654849069ef4
parentf5adcd0fad71828646b5047c661a0d8524a3fc9c (diff)
downloadbibiman-606716f064c1151ab9e8617ff76fd4b95f4a2c57.tar.gz
bibiman-606716f064c1151ab9e8617ff76fd4b95f4a2c57.zip
add functions to make sanitized data from PR #57 visible in the information tab too
-rw-r--r--src/bibiman/bibisetup.rs22
-rw-r--r--src/tui/ui.rs6
2 files changed, 22 insertions, 6 deletions
diff --git a/src/bibiman/bibisetup.rs b/src/bibiman/bibisetup.rs
index 37b0b01..b3f788c 100644
--- a/src/bibiman/bibisetup.rs
+++ b/src/bibiman/bibisetup.rs
@@ -173,7 +173,11 @@ impl BibiData {
}
pub fn title(&self) -> &str {
- &self.title
+ if let Some(sani_data) = &self.sanitized_bibi_data {
+ &sani_data.title
+ } else {
+ &self.title
+ }
}
pub fn year(&self) -> &str {
@@ -204,8 +208,20 @@ impl BibiData {
.collect_vec()
}
- pub fn subtitle(&self) -> &str {
- self.subtitle.as_ref().unwrap()
+ pub fn subtitle(&self) -> Option<&str> {
+ if let Some(sani_data) = &self.sanitized_bibi_data {
+ sani_data.subtitle.as_ref().map(|s| s.as_str())
+ } else {
+ self.subtitle.as_ref().map(|s| s.as_str())
+ }
+ }
+
+ pub fn get_abstract(&self) -> &str {
+ if let Some(sani_data) = &self.sanitized_bibi_data {
+ &sani_data.abstract_text
+ } else {
+ &self.abstract_text
+ }
}
fn create_symbols(&self, cfg: &BibiConfig) -> [Option<String>; 3] {
diff --git a/src/tui/ui.rs b/src/tui/ui.rs
index 3e6e24c..87d8c29 100644
--- a/src/tui/ui.rs
+++ b/src/tui/ui.rs
@@ -894,7 +894,7 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame,
Style::new().fg(cfg.colors.author_color),
),
]));
- if cur_entry.subtitle.is_some() {
+ if let Some(subtitle) = cur_entry.subtitle() {
lines.push(Line::from(vec![
Span::styled("Title: ", style_value),
Span::styled(
@@ -910,7 +910,7 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame,
.add_modifier(Modifier::ITALIC),
),
Span::styled(
- cur_entry.subtitle(),
+ subtitle,
Style::new()
.fg(cfg.colors.title_color)
.add_modifier(Modifier::ITALIC),
@@ -999,7 +999,7 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame,
}
lines.push(Line::from(""));
lines.push(Line::from(vec![Span::styled(
- cur_entry.abstract_text.clone(),
+ cur_entry.get_abstract(),
Style::new().fg(cfg.colors.main_text_color),
)]));
lines