papercite icon indicating copy to clipboard operation
papercite copied to clipboard

Download Bibtex from Bibliography

Open someonehere15 opened this issue 8 years ago • 10 comments

The plugin is great, the most feature packed! I have only one small request: Any way to provide a download link for each bibtex file on the bibliography, and also one download link for a single bibtex will all references? there already is the show bibtex option, but no download. That would be great for the case I need it for. Thanks again, great plugin!

someonehere15 avatar Apr 15 '16 02:04 someonehere15

Yes this would be possible and useful - I think the best would be by adding a special code to be added to template files. I add this to the features list.

bpiwowar avatar Apr 15 '16 07:04 bpiwowar

Hey, thanks for the quick response! Any chance you could add this within two months? I have an important use case for a prototype that I need to present in less than two months, and it depends completely on this. Or at least could you tell me what I need to add, although it would be better if its officially in your plugin, to keep updates.

PS. just a couple more things:

  1. Could you also add a tooltip to each in-text citation, so when the mouse is hovering over, it shows the reference, without having to click to go to the end? It would be a great addition.
  2. Could you make it possible to add the [bibshow] code at the end of the text as a default? It would help with the flow of the text. I write everything, and cite, and at the end add bibshow to indicate here put my references.
  3. I can use bibshow and bibcite with the bibtex key, but I can't seem to make it work with a numeric key. e.g. [bibshow file=fileurl] and [bibcite key=1] and I get "Unknown bibtex entry with key [1]". I tried many versions, I added key_format=numeric to bibshow, I don't know what I'm missing.

someonehere15 avatar Apr 15 '16 08:04 someonehere15

I don't know how much time I will spend on this, so don't rely on it. However, if you can code, I can guide you on what to do, and by submitting a pull request, the code would be integrated in further versions.

For the other things, please submit an issue for each otherwise I cannot keep track of everything: (1) seems quite easy to do with some javascript; (2) I don't understand - [/bibshow] can be used to mark the point where references should be output, and this is optional (automatically inserted at the end of the text if missing); (3) I don't think 1 is a valid bibliography key, but I am surprised it does not work - please open a bug report giving the content of your bibtex file (the entry with the numeric key) and the exact code you are using.

bpiwowar avatar Apr 15 '16 09:04 bpiwowar

Thanks for the answer. I can try myself, just tell me what to do.

for (2), I meant that the way it is now, I have to put a [bibshow file=blabla] in the beginning of the text, so I can add citations later. It would just be easier to structure the text if I dont add [bibshow] in the beginning, but just the end, and it automatically parses the whole document. At least as a default, unless I specifically add sections the way you do now. I hope it was clear this time.

someonehere15 avatar Apr 15 '16 11:04 someonehere15

It would need rewriting the parsing system so as to parse the file two times, which is not very convenient, especially if switching to the wordpress shortcode API (which I intended to do). The main problem is that the actual way of doing so is the reverse and allows to retrieve the databases before matching the entries.

bpiwowar avatar Apr 15 '16 11:04 bpiwowar

Ok thanks. Not a problem anyway, just a suggestion. Please let me know about the download links, I have little time left and it would be great. Also the tooltip if you have time. Thanks a lot.

someonehere15 avatar Apr 15 '16 11:04 someonehere15

Just the roadmap in case you want to code it:

  1. Create a new file download.php that will be used to return the references given the bibtex URLs. The getData could be adapted so that it can be called to retrieve the actual files
  2. Use setGlobal in papercite.php (for bibshow and bibtex shortcodes) to add a variable (e.g. DOWNLOAD_URL) holding the URL to the download.php + arguments.

Then, in your template, you can use @DOWNLOAD_URL@ to display the URL to the bibtex entries.

bpiwowar avatar Apr 15 '16 11:04 bpiwowar

I can't seem to fully understand the code, there is a lot of stuff. From what I see, getData gets all the papercite URLs the user has placed in the post, and parses them, and returns an array of results (not sure what format the results are). And I don't understand how this goes to the final @bibtex@ variable. Anyway, one alternative I thought was to get the bibtex data that you show on the page from the Show Bibtex button, and directly create a file by just adding another link: <a href="data:text/plain;charset=UTF-8,@bibtex@" download="@[email protected]">[Download]</a> I know it is not compatible with a lot of browsers, but to be honest I do know how to create a file with php, but I'm not sure how to pass the @bibtex@ value to another php file to create a file. If you can tell me how to pass @bibtex@ would be great.

someonehere15 avatar Apr 15 '16 16:04 someonehere15

I think, beside my previous solution, I need to create a php file as you said, and a link to that from the tpl. However I don't think I need to modify getData, but just reuse whatever you use to show the bibtex on the page, but instead I create a file. As I said though, I don't know how to work with templates, and I don't know how the @bibtex@, @id@, etc. are retrieved.

someonehere15 avatar Apr 18 '16 15:04 someonehere15

The process in itself is quite complex:

  • papercite generates a first string where it uses placeholders for citations (BIBCITE%%XXXX)
  • for displaying bibliographies, it uses bib2tpl that recursively match parts of the templates to display the entries - all this process can be found in bib2tpl/bibtex_converter.php

bpiwowar avatar Apr 25 '16 15:04 bpiwowar