diff --git a/Cargo.lock b/Cargo.lock index 553cd53..c54821b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,6 +1010,25 @@ dependencies = [ "serde", ] +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -1312,6 +1331,17 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "open" +version = "5.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43bb73a7fa3799b198970490a51174027ba0d4ec504b03cd08caf513d40024bc" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl" version = "0.10.75" @@ -1388,6 +1418,12 @@ dependencies = [ "windows-link", ] +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "percent-encoding" version = "2.3.2" @@ -1757,6 +1793,7 @@ dependencies = [ "ammonia", "clap", "crossterm", + "open", "ratatui", "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 4a80575..c74dec2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" ammonia = "4.1.2" clap = { version = "4.5.53", features = ["derive"] } crossterm = "0.29.0" +open = "5.3.3" ratatui = "0.30.0" reqwest = { version = "0.12.28", features = ["json"] } serde = { version = "1.0.228", features = ["derive"] } diff --git a/src/gui.rs b/src/gui.rs index 70aac14..68415f4 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -49,12 +49,36 @@ pub struct App { pub should_quit: bool, } +// TODO: The whole architecture of the app may be a bit unusual. Compare with +// example on https://ratatui.rs/examples/widgets/scrollbar/ +// TODO: Implement exclusion and inclusion of papers (e.g., X and Y chars) +// TODO: Implement moving through steps and iterations (populating pending papers) +// TODO: Implement input of seed papers using IDs +// TODO: Implement possibility of pushing excluded papers back into pending +// TODO: Implement export of included papers as csv for keywording with a spreadsheet +// TODO: Implement export of included papers into zotero (Use RIS format somehow) impl App { fn handle_key(&mut self, key: KeyCode) { match key { KeyCode::Char('q') => { self.should_quit = true; } + KeyCode::Enter => match self.active_pane { + ActivePane::IncludedPublications => { + open::that( + &self.included_publications[self.included_selected_idx] + .id, + ) + .unwrap(); + } + ActivePane::PendingPublications => { + open::that( + &self.pending_publications[self.pending_selected_idx] + .id, + ) + .unwrap(); + } + }, KeyCode::Char('h') => { self.active_pane = ActivePane::IncludedPublications; } @@ -113,6 +137,8 @@ where } } +// TODO: Implement scrolling. See +//https://ratatui.rs/examples/widgets/scrollbar/ fn ui(f: &mut Frame, app: &App) { // Root layout diff --git a/src/main.rs b/src/main.rs index 57b04c6..9fe972a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,9 @@ impl From for Error { } } +// TODO: The whole initialization and deinitialization and use of crossterm +// might be unnecessary. Compare with example on +// https://ratatui.rs/examples/widgets/scrollbar/ fn main() -> io::Result<()> { let args = Args::parse(); diff --git a/src/snowballing.rs b/src/snowballing.rs index 3536cbe..0b9cbcf 100644 --- a/src/snowballing.rs +++ b/src/snowballing.rs @@ -47,7 +47,7 @@ pub fn reconstruct_abstract(inverted_index: &HashMap>) -> Strin sanitized.replace("\u{a0}", " ").trim().to_string() } - +// TODO: Get all papers, not just the first page pub async fn get_citing_papers( target_id: &str, email: &str,