Skip to content

Commit

Permalink
Merge pull request #96 from out-of-cheese-error/feat/search_title
Browse files Browse the repository at this point in the history
Feat/search title
  • Loading branch information
Ninjani authored Apr 25, 2021
2 parents a14fa71 + b43b065 commit afc0085
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Separate make and index commands, allow filtering annotations in both (
Issue [#90](https://github.com/out-of-cheese-error/gooseberry/issues/90))
- Better and more filtering options (Issue [#92](https://github.com/out-of-cheese-error/gooseberry/issues/92))
- Search by document title (Issue [#93](https://github.com/out-of-cheese-error/gooseberry/issues/93))

## [0.8.1] - 2021-03-14
### Changed
Expand Down
32 changes: 26 additions & 6 deletions src/gooseberry/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,36 @@ impl Gooseberry {

let (tx_item, rx_item): (SkimItemSender, SkimItemReceiver) = unbounded();
for annotation in &annotations {
let highlight = format!(
"{} | {} |{}| {}",
style(&utils::get_quotes(&annotation).join(" ").replace("\n", " ")),
annotation.text.replace("\n", " "),
style(&annotation.tags.join("|")).fg(dialoguer::console::Color::Red),
let mut title = String::from("Untitled document");
if let Some(document) = &annotation.document {
if !document.title.is_empty() {
title = document.title[0].to_owned();
}
}
let mut highlight = format!(
"{}",
style(title.replace("\n", " ")).fg(dialoguer::console::Color::Green)
);
let quote = utils::get_quotes(&annotation).join(" ").replace("\n", " ");
if !quote.is_empty() {
highlight.push_str(&format!("| {}", quote));
}
if !annotation.text.is_empty() {
highlight.push_str(&format!("| {}", annotation.text.replace("\n", " ")));
}
if !annotation.tags.is_empty() {
highlight.push_str(&format!(
"|{}",
style(&annotation.tags.join("|")).fg(dialoguer::console::Color::Red)
));
}
highlight.push_str(&format!(
"| {}",
style(&annotation.uri)
.fg(dialoguer::console::Color::Cyan)
.italic()
.underlined()
);
));
let _ = tx_item.send(Arc::new(SearchAnnotation {
highlight,
markdown: hbs.render(
Expand Down

0 comments on commit afc0085

Please sign in to comment.