microsimulation / ijm

A central place for general issues, documents, scripts and resources for the IJM
https://microsimulation.org/ijm/
MIT License
4 stars 0 forks source link

Add "export reference" functionality (BibTeX and RIS) #21

Closed astrajescu closed 4 years ago

astrajescu commented 4 years ago

For the moment each article on IJM site can only be downloaded in PDF format (see fig.1)

It is intended to broaden the download functionality to allow export reference-files (citations) in formats specified by IJM, i.e. BibTeX and RIS files. This export functionality is already implemented on eLife Magazine (see fig.2) and thus we have to find a technical solution to replicate it.

Out of scope: For this task we don't handle open citations (Mendeley, ReadCube, papers and CiteULike). Out of scope: For this task we don't handle the "n/a issue"

Fig 1 Fig 2

BlueReZZ commented 4 years ago

There's a route for generating the LaTeX file for BibTeX file .bib and one for the .ris file too in the routes config: https://github.com/microsimulation/ijm/blob/b5d106f4369208ff849e4104afb02b7e0c690aa7/journal/app/config/routing.yml#L39

It calls the ArticleController and generates the file, on-the-fly using a twig template: https://github.com/microsimulation/ijm/blob/master/journal/app/Resources/views/article.bib.twig

This template contains some hard-coded references to eLife so they just need checking and replacing, e.g.: https://github.com/microsimulation/ijm/blob/b5d106f4369208ff849e4104afb02b7e0c690aa7/journal/app/Resources/views/article.bib.twig#L28

There is a similar template for generating RIS too: https://github.com/microsimulation/ijm/blob/master/journal/app/Resources/views/article.ris.twig

With similar replacements needed: https://github.com/microsimulation/ijm/blob/b5d106f4369208ff849e4104afb02b7e0c690aa7/journal/app/Resources/views/article.ris.twig#L35

@astrajescu or @hdrury1 might be able to find out what these values need to be replaced with for IJM

Once the templates have been updated it should be a case of re-instating the download menu which is generated automatically from a list.... I'm not sure how though.

BlueReZZ commented 4 years ago

The list is generated from the data in the API response but the code was removed from the eLife version to the IJM version. To regenerate the list we need to reinstate the code from ArticleDownloadLinksList

Here's the file in eLife's version of journal: https://github.com/elifesciences/journal/blob/8d61f42b9daf10ad5f68389d2612ba48c0df9948/src/ViewModel/Converter/ArticleDownloadLinksListConverter.php#L72

            $groups[mixed_visibility_text('', 'Downloads', '(link to download the article as '.Humanizer::prettyList(...$types).')')] = $downloads;
        }

        if ($object->getPublishedDate()) {
            $groups[mixed_visibility_text('', 'Download citations', '(links to download the citations from this article in formats compatible with various reference manager tools)')] = [
                new ViewModel\ArticleDownloadLink(new ViewModel\Link('BibTeX', $this->urlGenerator->generate('article-bibtex', [$object]))),
                new ViewModel\ArticleDownloadLink(new ViewModel\Link('RIS', $this->urlGenerator->generate('article-ris', [$object]))),
            ];
        }

        $groups[mixed_visibility_text('', 'Open citations', '(links to open the citations from this article in various online reference manager services)')] = [
            new ViewModel\ArticleDownloadLink(new ViewModel\Link('Mendeley', 'https://www.mendeley.com/import?doi='.$object->getDoi())),
            new ViewModel\ArticleDownloadLink(new ViewModel\Link('ReadCube', 'https://www.readcube.com/articles/'.$object->getDoi())),
            new ViewModel\ArticleDownloadLink(new ViewModel\Link('Papers', sprintf('papers2://url/%s?title=%s', urlencode($articleUri), urlencode(strip_tags($object->getTitle()))))),
            new ViewModel\ArticleDownloadLink(new ViewModel\Link('CiteULike', sprintf('http://www.citeulike.org/posturl?url=%s&title=%s&doi=%s', urlencode($articleUri), urlencode(strip_tags($object->getTitle())), $object->getDoi()))),
        ];

Once we've edited the BIB and RIS generators, and checked that the $articleUri is returning correctly the download menu should match expectations.

BlueReZZ commented 4 years ago

Looks like I was the one that removed it in May last year

https://github.com/microsimulation/ijm/commit/0b9d23cfca75e12654894e143e928439b8569319#diff-31a243fa4790d9a470a269ff8e5c66de

astrajescu commented 4 years ago

Please make sure to change the ISSN number that is generated within the BibTeX and RIS files to the new one related to IJM - "1747-5864" (just like we change journal and publisher names). Beside, in the BibTeX file line11 citation should mentions the correct volume issue number, e.g. 11(3), not only the volume.