Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for remotely controlling/accessing JabRef (Command-Line or x-callbacks) #5719

Closed
nathanlesage opened this issue Dec 8, 2019 · 9 comments

Comments

@nathanlesage
Copy link

Hey, as discussed on Twitter, over at Zettlr we're currently thinking about ways to interact between the app and several reference managers. Everytime you write something, it might happen that you want to change something in a specific citation or just want to open the linked PDF-File. In this case, it would be great to have a small interface to tell reference managers "Hey, please jump to that entry!" or "Could you please open the PDF file linked with that citekey?"

Zotero uses x-callback-links for that, that is, custom-protocol URLs such as zotero://open-pdf/library/items/[itemKey]?page=[page] or zotero://select/items/@[citekey]. The benefit would clearly be a better cross-integration between several components of your workflow on your computer.

If something like this would be possible, this would be great! :) I'm not sure of all potential good options for such an API, but I think the most important ones would be "Open linked PDF for entry with citekey @xyz" and "Select entry @CiteKey".


Further reference: Zettlr/Zettlr#418

@tobiasdiez
Copy link
Member

That should be relatively straightforward to implement: https://stackoverflow.com/questions/26363573/registering-and-using-a-custom-java-net-url-protocol

Do you also have the database name, or just the citation key?

Side remark/question: As you may know some reference manager include knowledge management and note taking to some extend. This is still one of JabRef's weaknesses. Do you think it would be possible to include some of the features of Zettlr in JabRef? A beginning would be for example to view Zettlr notes citing a given entry.

@nathanlesage
Copy link
Author

Sounds good! I am not sure what options one might end up needing — therefore I'd design the API to be extendable. I haven't yet made so much experience using JabRef (albeit I will be implementing it in a project I'm working on currently, because having one bibTex file is much better for working in a team than Zotero's internal database!) So concerning database name — I don't know how often one might have more than one open …? I mean Zettlr will read in the BibTex file, so it'll have access to everything stored in there.

Concerning the callback URLs, I'd opt for a REST or CRUD-approach, because it seems to me to be the most flexible approach to that! (In case of security concerns one could limit access to the commands via Preferences or a notification window).

And to the side remark/question: Sounds like a very interesting idea. I personally don't really use the note taking abilities of Zotero, because I tend to view software based on the one-program-one-function paradigm (albeit I'd rather say: one program one domain), this is why I don't want to implement reference manager functionality into Zettlr and opt for simply communicating with a program that offers such functionality. However, there's an issue open on my tracker where someone wanted such an x-callback-approach for Zettlr, and while we're on it, I could also implement that in Zettlr so that reference managers can access the internal API themselves!

@nathanlesage
Copy link
Author

Heya, I just wanted to drop by because while discussing the cross-integration, we came upon a question that we might want to discuss before integrating that feature: Most citations are in the form [prefix @CiteKey, page-number]. Zettlr is able to extract the page number, so when we talk about "please open that item", together with @somelinguist we had the idea that maybe we could implement an API that also optionally takes a page-parameter to -- if the linked file is indeed a PDF -- open the PDF on the specified page. Zotero, for instance, also implements that functionality via their callback API. I don't know -- is it possible for JabRef to open PDFs with a page number given? If so, the question would be of how to handle it -- the easiest way from the perspective of Zettlr would be to simply throw both CiteKey, library, and an optional page number at JabRef, and then let JabRef decide whether to use the page number (if the linked file is indeed a PDF) or to simply ignore it (if it's a simple URL).

What do you think?

@tobiasdiez
Copy link
Member

At the moment, JabRef does not support opening a PDF at a specific page. In principle, it would be relatively straightforward to add it. Related code:

} else if (StandardField.PS.equals(field)) {
try {
NATIVE_DESKTOP.openFile(link, StandardField.PS.getName());
} catch (IOException e) {
LOGGER.error("An error occurred on the command: " + link, e);
}
} else if (StandardField.PDF.equals(field)) {
try {
NATIVE_DESKTOP.openFile(link, StandardField.PDF.getName());
} catch (IOException e) {
LOGGER.error("An error occurred on the command: " + link, e);
}

However, there is no generally accepted API for pdf reader, so one needs to have a look at the most common ones and find the necessary cmd args. This is possible but also a bit of work. So for now I would say you can through the page number at JabRef, but we will ignore it for the moment. If there is enough user feedback to get page numbers working, we can implement it later.

I'm pretty busy the next two weeks, not sure if I find the time to implement the API soon. :(

@nathanlesage
Copy link
Author

This sounds great! I know that there's no unified API (I mean why standardise, right? 🙄) I'll just stay tuned on how you'll be implementing that and in the meantime think of a good scalable way of realising this interaction within Zettlr. Additionally, I'll increase priority on the implementation of such a callback-interface in Zettlr, so if you'd like you can think of ways in which an interaction with Zettlr for notes based on the CiteKeys, etc. would be cool for you, so that I can directly implement the API endpoints you'd need right from the beginning! :)

P.S.: I tried to find the responsible class for the integrations you already have for other programs such as TeXLive and vi, but I couldn't find it. It would be really nice if you could point me in the right direction so that I can "copy" the way you handle those apps in order to make it easy to implement the inter-application-communication!

Oh, and we all are busy, so there's absolutely no pressure! I really value that you want to implement this API, but please, there's no deadline — after all, it's open source! Have nice holidays and a good start into 2020 and don't worry too much until then!

@somelinguist
Copy link

@tobiasdiez That sounds great!

For reference, Zotero has some logic for figuring out how to pass the command line arguments to several different PDF readers on different OS at https://github.com/zotero/zotero/blob/3c1cdd57d2ad52cc9434b906a469579cb7b850a8/chrome/content/zotero/xpcom/openPDF.js#L26

For Windows, they're supporting Adobe and PDF-XChange, both of which look like you would do:

path/to/program.exe /A page=# path/to/pdf

For Linux, they support Evince and Okular, both of which look like:

path/to/program -p # /path/to/pdf

On macOS they support the native Preview app, Skim, and PDF Expert. They're using custom AppleScripts for each one (see link above).

@tobiasdiez tobiasdiez self-assigned this Dec 11, 2019
@tobiasdiez
Copy link
Member

@nathanlesage These push operations are implemented here: https://github.com/JabRef/jabref/tree/8777c16a99bd83e4a30ddafc859c0c2208b68733/src/main/java/org/jabref/gui/push
For most applications it's just a glorified command line execution, i.e.

@Override
protected String[] getCommandLine(String keyString) {
return new String[] {commandPath,
"\"[InsText('" + getCiteCommand() + "{" + keyString.replace("'", "''") + "}');]\""};
}
.

@nathanlesage
Copy link
Author

Thanks for the hint!

… I suppose it would not be too difficult to use callback URLs instead of CLI calls given the above-mentioned stackoverflow thread, right? If so, it would be great, because I somehow feel that implementing a clean RESTful API via callback URLs is better than implementing command line switches, because these I'd need to hack together ugly, b/c the command line switches are accessed at the purely functional part of the app currently, which would break the object-oriented approach to some extend :D

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2020

This issue has been inactive for half a year. Since JabRef is constantly evolving this issue may not be relevant any longer and it will be closed in two weeks if no further activity occurs.

As part of an effort to ensure that the JabRef team is focusing on important and valid issues, we would like to ask if you could update the issue if it still persists. This could be in the following form:

  • If there has been a longer discussion, add a short summary of the most important points as a new comment (if not yet existing).
  • Provide further steps or information on how to reproduce this issue.
  • Upvote the initial post if you like to see it implemented soon. Votes are not the only metric that we use to determine the requests that are implemented, however, they do factor into our decision-making process.
  • If all information is provided and still up-to-date, then just add a short comment that the issue is still relevant.

Thank you for your contribution!

koppor pushed a commit that referenced this issue Jan 1, 2022
f78c707 Update Turabian (full note) for 17.1.3.2 Reprint Editions (#5809)
2169ddc Create art-libraries-society-of-north-america-arlisna-reviews.csl (#5791)
94119a6 Create university-of-south-wales-harvard.csl (#5787)
470925c Update fachhochschule-sudwestfalen.csl (#5811)
1a9eff7 Create annals-of-public-and-cooperative-economics.csl (#5747)
d7477f2 Merge pull request #5368 from POBrien333/patch-862
113e683 Merge pull request #5812 from citation-style-language/apa-no-initials
62dacff Create universitat-oberta-de-catalunya-apa.csl
046482c Fix Organization Studies title
1213b95 Make oranization-studies dependent
c9641f4 Create apa-no-initials.csl
0b4e047 Modify american-journal-of-archaeology.csl (#5719)
ddeda4f Create journal-of-economic-impact.csl (#5707)
40c2696 Update gallia.csl (#5782)
5d5927a Create serbian-archives-of-medicine.csl (#5721)
2777954 Merge pull request #5807 from dhacker29/master
77e3fca Update Society of Biblical Literature Full Note for 6.1.6
4479a5a haaga-helia-university-of-applied-sciences-harvard.csl: no date cites need to be unique (#5726)
d00e046 Create university-of-roehampton-harvard.csl (#5732)
e76da40 Medicinski Razgledi -- fix locale
75b1554 Add original-date extra to proper place as per SBL Handbook 6.2.17-18 (#5725)
d43676e Update harvard-bournemouth-university.csl (#5667)
0312a39 Create ABNT NBR 6023:2018. UNESP – Faculdade de Engenharia de Guarati… (#5705)
6585ff9 Create sinergie-italian-journal-of-management.csl (#5776)
a7dc678 Create journal-of-global-health.csl (#5775)
02080ce Merge pull request #5800 from citation-style-language/validation-fixes
8b51d85 change s. d. to s.d. in french style for INBO reports (issue #2) (#5634)
1b4ec09 Create bloomsbury-academic.csl (#5741)
1f28d87 Create zeithistorische-forschungen.csl (#5766)
bb11942 Remove superfluous 'container' data from wiley-vch-books
06038a7 Remove et-al affixes
be96bd8 Remove et-al affixes from bibliotecae-it.csl
03a94e4 Remove more et-al affixes
07d7423 Revert non-et-al changes to universitat-basel-iberomanistik
f8e5fd8 Create medicinski-razgledi.csl (#5789)
b4df8ee Create dut-harvard.csl (#5762)
40855c4 Fix affixes on et-al
b4fe9b0 Merge pull request #5798 from citation-style-language/uris
3dc4aaf URL-encode documentation URLs
408a3a8 fixes citation-style-language/Sheldon#38
42aca5b Update biophysics-and-physicobiology.csl (#5751)
706bea0 Create universidade-do-porto-faculdade-de-engenharia-chicago-pt.csl (#5742)
269ff91 Update universidade-do-porto-faculdade-de-engenharia-chicago.csl (#5797)
0ba51e7 Update el-profesional-de-la-informacion.csl (#5785)
dac3baf Create arthropod-systematics-and-phylogeny.csl (#5772)
9dff241 Merge pull request #5796 from dhacker29/patch-1
35949f4 Update turabian-fullnote-bibliography-no-ibid.csl
ccfb661 Merge pull request #5793 from benjaminmoon/patch-2
520e127 Update frontiers-medical-journals.csl (#5740)
ab629ab Update natura-croatica.csl (#5795)
60b2b17 Rename turabian-fullnote-bibliography-no-ibid to turabian-fullnote-bibliography-no-ibid.csl
ad4edff Create turabian-fullnote-bibliography-no-ibid
d9b956c Update monographs-of-the-palaeontographical-society.csl
3648ae6 Merge pull request #5792 from StianOby/fix-no-page-number-articles
e15b2f7 Update norsk-henvisningsstandard-for-rettsvitenskapelige-tekster.csl
d8778cf Removed "page" (s. ) term for articles that do not have page numbers.
409017c add medium field for eBooks to MLA 8th

git-subtree-dir: buildres/csl/csl-styles
git-subtree-split: f78c707
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants