From 202dc44a6dba403c5d13986fe4c3701a45a223c9 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Fri, 30 May 2025 17:18:13 +0200 Subject: update README: pdf_path variable --- README.md | 56 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index e39d8dd..01268a7 100644 --- a/README.md +++ b/README.md @@ -122,12 +122,16 @@ POSITIONAL ARGS: Path to directory containing .bib files FLAGS: - -h, --help Show this help and exit - -v, --version Show the version and exit - -c, --config-file= Path to config file for current session needed as argument. - Takes precedence over standard config file - --light-terminal Enable color mode for light terminal background - + -h, --help Show this help and exit + -v, --version Show the version and exit + -c, --config-file= Path to config file used for current session. + Takes precedence over standard config file. + --light-terminal= Enable color mode for light terminal background + --pdf-dir= Use PDF files named by citekey at the given path and its + subdirs as value for the `file` field of the entry matching + the citekey for the current session. + Does not overwrite or change the original file. + (might not work with citekeys containing special chars)" ``` As seen, you can pass a single file, multiple files, the path of a directory @@ -200,6 +204,10 @@ url_opener = "xdg-open" # Prefix which is prepended to the filepath from the `file` field # Use absolute paths (~ for HOME works). Otherwise, loading might not work. file_prefix = "/some/path/prefix" +# Path to folder (with subfolders) containing PDF files with the basename +# of the format "citekey.pdf". Other PDF basenames are not accepted. +# Use absolute paths (~ for HOME works). Otherwise, loading might not work. +pdf_path = "/path/to/pdf-folder" ``` If no file or dir is set as `bibfiles` value, you *have to* add a path via CLI @@ -207,22 +215,32 @@ interface. If the `bibfiles` value is set *and* a further path (or multiple) is provided through the CLI call, the entries of all those files will be opened in the started `bibiman` session. -The file prefix offers the possibility to keep file paths in your `.bib` file -short: E.g. a combination of those values in config and bibfile: +`file_prefix` -```toml -# bibiman.toml -file_prefix = "~/Documents/literature" -``` +: The `file_prefix` offers the possibility to keep file paths in your `.bib` + file short: E.g. a combination of those values in config and bibfile: -```bibtex -# bibfile.bib -file = {aristotle.pdf} -``` + ```toml + # bibiman.toml + file_prefix = "~/Documents/literature" + ``` + + ```latex + # bibfile.bib + file = {aristotle.pdf} + ``` + + Will result in opening the file `~/Documents/literature/aristotle.pdf` when + trying to open the PDF from inside `bibiman`. The `.bib` file itself will not + be edited! + +`pdf_path` -Will result in opening the file `~/Documents/literature/aristotle.pdf` when -trying to open the PDF from inside `bibiman`. The `.bib` file itself will not be -edited! +: The `pdf_path` is used as path wich is recursivley searched for files which + basename consists of the an entrys `citekey` plus a `.pdf` ending. Every file + which matches this pattern for an existing `citekey` is associated with the + particular entry for the current `bibiman` session and can be opened from + within. ### Color Configuration -- cgit v1.2.3 From 62580d8cc537808c34b0d9a0fe5554b4806a7aa6 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Fri, 30 May 2025 17:36:50 +0200 Subject: typo in --help function --- README.md | 2 +- src/cliargs.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 01268a7..d2827b4 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ FLAGS: -v, --version Show the version and exit -c, --config-file= Path to config file used for current session. Takes precedence over standard config file. - --light-terminal= Enable color mode for light terminal background + --light-terminal Enable color mode for light terminal background --pdf-dir= Use PDF files named by citekey at the given path and its subdirs as value for the `file` field of the entry matching the citekey for the current session. diff --git a/src/cliargs.rs b/src/cliargs.rs index c7a0eb1..04886d1 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -130,7 +130,7 @@ FLAGS: -v, --version Show the version and exit -c, --config-file= Path to config file used for current session. Takes precedence over standard config file. - --light-terminal= Enable color mode for light terminal background + --light-terminal Enable color mode for light terminal background --pdf-dir= Use PDF files named by citekey at the given path and its subdirs as value for the `file` field of the entry matching the citekey for the current session. -- cgit v1.2.3 From 1a34950a45a8fba97dca432fe36569eec1a05c8f Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 2 Jun 2025 10:01:15 +0200 Subject: update the README --- README.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index d2827b4..a9de6f3 100644 --- a/README.md +++ b/README.md @@ -210,10 +210,12 @@ file_prefix = "/some/path/prefix" pdf_path = "/path/to/pdf-folder" ``` -If no file or dir is set as `bibfiles` value, you *have to* add a path via CLI -interface. If the `bibfiles` value is set *and* a further path (or multiple) is -provided through the CLI call, the entries of all those files will be opened in -the started `bibiman` session. +`bibfiles` + +: If no file or dir is set as `bibfiles` value, you *have to* add a path via CLI + interface. If the `bibfiles` value is set *and* a further path (or multiple) + is provided through the CLI call, the entries of all those files will be + opened in the started `bibiman` session. `file_prefix` @@ -226,7 +228,7 @@ the started `bibiman` session. ``` ```latex - # bibfile.bib + % bibfile.bib file = {aristotle.pdf} ``` @@ -234,13 +236,18 @@ the started `bibiman` session. trying to open the PDF from inside `bibiman`. The `.bib` file itself will not be edited! + The prefix will only be added to filepaths which are explicitly set in the + `.bib` file itself using the `file` field. It will *not* "destroy" file paths + created through the `pdf_path` variable. Thus, it is safe to mix both + approaches if wanted! + `pdf_path` : The `pdf_path` is used as path wich is recursivley searched for files which - basename consists of the an entrys `citekey` plus a `.pdf` ending. Every file - which matches this pattern for an existing `citekey` is associated with the - particular entry for the current `bibiman` session and can be opened from - within. + basename consists of the an entrys `citekey` plus a `.pdf` ending + (case-insensitive). Every file which matches this pattern for an existing + `citekey` is associated with the particular entry for the current `bibiman` + session and can be opened from within. ### Color Configuration -- cgit v1.2.3 From 201aecebcd7c85127df9c43da01fdafc3465e53e Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 2 Jun 2025 17:40:50 +0200 Subject: impl check for valid filepath, update README --- README.md | 13 +++++++++---- src/app.rs | 4 ++-- src/bibiman.rs | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 8 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index a9de6f3..4c176af 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,15 @@ Or through `home-manager` config file: ### Void Linux -I maintain a [PR](https://github.com/void-linux/void-packages/pull/53803) in the -official Void package repos and hope it gets merged soon. Until that happens, -you can easily pull that PR into your local clone of Void packages and build it -with `xbps-src`. +You can install `bibiman` through `xbps`-package manager: + +```bash +# Through xbps directly +sudo xpbs-install bibiman + +# Or using xi from xtools package +xi bibiman +``` ## Usage diff --git a/src/app.rs b/src/app.rs index 15cdfe3..f7e7891 100644 --- a/src/app.rs +++ b/src/app.rs @@ -406,9 +406,9 @@ pub fn open_connected_file(cfg: &BibiConfig, file: &OsStr) -> Result<()> { // } else { // PathBuf::from(file) // }; - let file = PathBuf::from(file); + // let file = PathBuf::from(file); - let file = expand_home(&file).into_os_string(); + // let file = expand_home(&file).into_os_string(); // Pass filepath as argument, pipe stdout and stderr to /dev/null // to keep the TUI clean (where is it piped on Windows???) diff --git a/src/bibiman.rs b/src/bibiman.rs index 583d849..ea9dbf5 100644 --- a/src/bibiman.rs +++ b/src/bibiman.rs @@ -15,6 +15,7 @@ // along with this program. If not, see . ///// +use crate::app::expand_home; use crate::bibiman::entries::EntryTableColumn; use crate::bibiman::{bibisetup::*, search::BibiSearch}; use crate::cliargs::CLIArgs; @@ -674,16 +675,27 @@ impl Bibiman { let object = self.entry_table.entry_table_items[entry_idx].doi_url(); let url = app::prepare_weblink(object); app::open_connected_link(cfg, &url)?; + self.close_popup(); } else if self.popup_area.popup_list[popup_idx].0.contains("File") { // TODO: Selection for multiple files // let object = self.entry_table.entry_table_items[entry_idx].filepath()[0]; + let file = expand_home(&PathBuf::from(popup_entry.clone())); let object: OsString = popup_entry.into(); - app::open_connected_file(cfg, &object)?; + if file.is_file() { + app::open_connected_file(cfg, &object)?; + self.close_popup(); + } else { + self.open_popup( + PopupKind::MessageError, + Some("No valid file path: "), + Some(object.to_str().unwrap()), + None, + )?; + } } else { eprintln!("Unable to find ressource to open"); }; // run command to open file/Url - self.close_popup(); Ok(()) } -- cgit v1.2.3