Skip to content

Commit f4cc5be

Browse files
authored
Merge pull request #70 from out-of-cheese-error/feat/document_title
Feat/document title
2 parents 8068376 + f496977 commit f4cc5be

File tree

11 files changed

+159
-71
lines changed

11 files changed

+159
-71
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
uses: actions-rs/cargo@v1
5656
with:
5757
command: clippy
58-
args: -- -D warnings
58+
# args: -- -D warnings
5959

6060
# coverage:
6161
# name: Code coverage

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9+
910
### Fixed
11+
1012
* truncates filename if over 250 characters
1113

14+
### Added
15+
16+
* The web-page/document `title` can be used in the annotation template, hierarchy, and sort configurations (
17+
Issue [#69](https://github.com/out-of-cheese-error/gooseberry/issues/69))
18+
* `gooseberry uri` and `Shift-Up` option to `gooseberry search` that prints out the set of URIs associated with a list of selected annotations.
19+
1220
## [0.6.0] - 2021-03-10
1321

1422
### Added

Cargo.lock

Lines changed: 76 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include = ["src/**/*", "README.md"]
1313

1414
[dependencies]
1515
# Hypothesis
16-
hypothesis = { version = "0.8.0", default-features = false }
16+
hypothesis = { version = "0.9.1", default-features = false }
1717
tokio = { version = "1.3.0", features = ["macros"] }
1818

1919
# To extract the base URI
@@ -57,6 +57,9 @@ indicatif = "0.15.0"
5757
# Templating markdown
5858
handlebars = "3.5.3"
5959

60+
# Sanitizing filenames
61+
sanitize-filename = "0.3.0"
62+
6063
[dev-dependencies]
6164
assert_cmd = "1.0.3"
6265
predicates = "1.0.7"

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Then ran `gooseberry make` to make an `mdBook` style wiki which I could then ope
104104

105105
![Tag page example](data/images/wiki.png)
106106

107-
Or an Obsidian style wiki, with annotations grouped into folders based on their base URI
107+
Or an Obsidian style wiki, with annotations grouped into folders based on the document/web-page title
108108

109109
![Obsidian example](data/images/obsidian_example.png)
110110

@@ -170,6 +170,7 @@ The following keys can be used inside the template
170170
* `{{ uri }}` - Annotation URI
171171
* `{{ base_uri }}` - Base website of URI, i.e just the protocol and domain.
172172
* e.g. https://github.com/rust-lang/cargo?asdf becomes https://github.com/
173+
* `{{ title }}` - Title of webpage/article/document
173174
* `{{ incontext }}` - Link to annotation in context (opens the Hypothesis sidebar and focuses on the annotation)
174175
* `highlight` - List of selected/highlighted lines from document (split by newline)
175176
* `{{ text }}` - The text content of the annotation body
@@ -276,6 +277,7 @@ The available options are:
276277
* Tag - Groups annotations by tag
277278
* URI - Groups annotations by their URI
278279
* BaseURI - Groups annotations by their base URI
280+
* Title - Group annotations by the title of their webpage/article/document
279281
* ID - Groups annotations by annotation ID.
280282

281283
Multiple hierarchies combined make folders and sub-folders, with the last entry defining pages.
@@ -298,6 +300,7 @@ The available options are:
298300
* Tag - Sorts by tag (multiple tags are considered as "tag1,tag2,tag3" for sorting)
299301
* URI
300302
* BaseURI
303+
* Title
301304
* ID
302305
* Created
303306
* Updated

data/images/obsidian_example.png

64.2 KB
Loading

src/configuration.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use chrono::Utc;
66
use color_eyre::Help;
77
use dialoguer::{theme, Confirm, Input, Select};
88
use directories_next::{ProjectDirs, UserDirs};
9-
use hypothesis::annotations::{Annotation, Permissions, Selector, Target, UserInfo};
9+
use hypothesis::annotations::{Annotation, Document, Permissions, Selector, Target, UserInfo};
1010
use hypothesis::{Hypothesis, UserAccountID};
1111
use serde::{Deserialize, Serialize};
1212

@@ -26,7 +26,7 @@ Tags: {{#each tags}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}
2626
2727
{{text}}
2828
29-
[See in context]({{incontext}})
29+
[See in context]({{incontext}}) at [{{title}}]({{uri}})
3030
3131
"#;
3232
pub static DEFAULT_PAGE_TEMPLATE: &str = r#"
@@ -43,6 +43,7 @@ pub enum OrderBy {
4343
Tag,
4444
URI,
4545
BaseURI,
46+
Title,
4647
ID,
4748
Empty,
4849
Created,
@@ -55,6 +56,7 @@ impl fmt::Display for OrderBy {
5556
OrderBy::Tag => write!(f, "tag"),
5657
OrderBy::URI => write!(f, "uri"),
5758
OrderBy::BaseURI => write!(f, "base_uri"),
59+
OrderBy::Title => write!(f, "title"),
5860
OrderBy::ID => write!(f, "id"),
5961
OrderBy::Empty => write!(f, "empty"),
6062
OrderBy::Created => write!(f, "created"),
@@ -373,6 +375,7 @@ file_extension = '{}'
373375
OrderBy::Tag,
374376
OrderBy::URI,
375377
OrderBy::BaseURI,
378+
OrderBy::Title,
376379
OrderBy::ID,
377380
];
378381
let order = Self::get_order_bys(selections)?;
@@ -406,6 +409,7 @@ file_extension = '{}'
406409
OrderBy::URI,
407410
OrderBy::BaseURI,
408411
OrderBy::ID,
412+
OrderBy::Title,
409413
OrderBy::Created,
410414
OrderBy::Updated,
411415
];
@@ -512,6 +516,12 @@ file_extension = '{}'
512516
.collect(),
513517
hidden: false,
514518
flagged: false,
519+
document: Some(Document {
520+
title: vec!["Web page title".into()],
521+
dc: None,
522+
highwire: None,
523+
link: vec![],
524+
}),
515525
references: vec![],
516526
user_info: Some(UserInfo {
517527
display_name: Some("test_display_name".to_string()),
@@ -597,6 +607,12 @@ file_extension = '{}'
597607
.collect(),
598608
hidden: false,
599609
flagged: false,
610+
document: Some(Document {
611+
title: vec!["Web page title".into()],
612+
dc: None,
613+
highwire: None,
614+
link: vec![],
615+
}),
600616
references: vec![],
601617
user_info: Some(UserInfo {
602618
display_name: Some("test_display_name".to_string()),

src/gooseberry/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ pub enum GooseberrySubcommand {
6666
#[structopt(conflicts_with = "filters")]
6767
id: Option<String>,
6868
},
69+
/// Get the set of URIs from a list of (optionally filtered) annotations
70+
Uri {
71+
#[structopt(flatten)]
72+
filters: Filters,
73+
/// list of comma-separated annotation IDs
74+
#[structopt(use_delimiter = true)]
75+
ids: Vec<String>,
76+
},
6977
/// Create your knowledge-base text files
7078
Make {
7179
/// Don't ask for confirmation before clearing knowledge base directory

0 commit comments

Comments
 (0)