ropensci / rcrossref

R client for various CrossRef APIs
https://docs.ropensci.org/rcrossref
Other
170 stars 20 forks source link

Improve posibilities to select the correct file for bibliography #195

Closed GegznaV closed 4 years ago

GegznaV commented 5 years ago

It seems that the add-in searches for the bibliography file (.bib) in the current working directory (WD). Rmd files usually have different WD than the R console. This WD for Rmd files is also known as "Knit directory". If these two (the main WD and Knit directory) do not coincide, sometimes it is ambiguous to understand which directory the bibliography file will be written to (as there are 2 of those directories).

Moreover, if a non-existing directory is chosen, the add-in crashes with an error which is not very informative. The example of an error message, when I thought, that the file is in "assets/references.bib", but it was in "project/assets/references.bib":

> rcrossref:::crAddins()

Listening on http://127.0.0.1:3335
Warning in file.create(input$save_to) :
  cannot create file 'assets/references.bib', reason 'No such file or directory'
Warning in file(con, "r") :
  cannot open file 'assets/references.bib': No such file or directory
Warning: Error in file: cannot open the connection
  77: file
  76: readLines
  74: observeEventHandler
   3: shiny::runApp
   2: runGadget
   1: rcrossref:::crAddins

Could you implement the following features:

1) in the addin window, a field that indicates the name of the working directory the add-in currently uses; 2) the possibility to interactively choose a bibliography file. I.e., a button, which opens a dialogue window to choose an existing file or to create a new one; 3) in case of misspelled (non-existing) folder name: a. issue a (pop-up) warning with an informative message, which also indicates the path to WD, b. prevent the add-in from crashing in this situation.

Session Info ```r > devtools::session_info("rcrossref") - Session info -------------------------------------------------------------------------------------------------- setting value version R version 3.6.1 (2019-07-05) os Windows 10 x64 system x86_64, mingw32 ui RStudio language (EN) collate English_United States.1252 ctype English_United States.1252 tz Europe/Helsinki date 2019-10-23 - Packages ------------------------------------------------------------------------------------------------------ package * version date lib source assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1) BH 1.69.0-1 2019-01-07 [1] CRAN (R 3.6.0) bibtex 0.4.2 2017-06-30 [1] CRAN (R 3.6.0) cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1) colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) crosstalk 1.0.0 2016-12-21 [1] CRAN (R 3.6.0) crul 0.8.4 2019-08-02 [1] CRAN (R 3.6.1) curl 4.2 2019-09-24 [1] CRAN (R 3.6.1) digest 0.6.22 2019-10-21 [1] CRAN (R 3.6.1) dplyr 0.8.3 2019-07-04 [1] CRAN (R 3.6.0) DT 0.9 2019-09-17 [1] CRAN (R 3.6.1) ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1) fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.0) fastmap 1.0.1 2019-10-08 [1] CRAN (R 3.6.1) ggplot2 3.2.1 2019-08-10 [1] CRAN (R 3.6.1) glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1) gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0) htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1) htmlwidgets 1.5.1 2019-10-08 [1] CRAN (R 3.6.1) httpcode 0.2.0 2016-11-14 [1] CRAN (R 3.6.0) httpuv 1.5.2 2019-09-11 [1] CRAN (R 3.6.1) jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0) labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0) later 1.0.0 2019-10-04 [1] CRAN (R 3.6.1) lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.1) lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0) magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) MASS 7.3-51.4 2019-03-31 [1] CRAN (R 3.6.1) Matrix 1.2-17 2019-03-22 [2] CRAN (R 3.6.1) mgcv 1.8-29 2019-09-20 [1] CRAN (R 3.6.1) mime 0.7 2019-06-11 [1] CRAN (R 3.6.0) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 3.6.1) munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0) nlme 3.1-140 2019-05-12 [2] CRAN (R 3.6.1) pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1) plogr 0.2.0 2018-03-25 [1] CRAN (R 3.6.0) plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.0) promises 1.1.0 2019-10-04 [1] CRAN (R 3.6.1) purrr 0.3.3 2019-10-18 [1] CRAN (R 3.6.1) R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0) RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.6.0) Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1) rcrossref * 0.9.2.9610 2019-09-27 [1] Github (ropensci/rcrossref@1c8bfe6) reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.6.0) rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.0) scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0) shiny 1.4.0 2019-10-10 [1] CRAN (R 3.6.1) sourcetools 0.1.7 2018-04-25 [1] CRAN (R 3.6.0) stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0) stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0) tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.0) triebeard 0.3.0 2016-08-04 [1] CRAN (R 3.6.0) urltools 1.7.3 2019-04-14 [1] CRAN (R 3.6.0) utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.0) vctrs 0.2.0 2019-07-05 [1] CRAN (R 3.6.1) viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.0) withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.1) xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0) yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0) zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.0) ```
sckott commented 5 years ago

thanks again @GegznaV - again, include your session info with rcrossref loaded so we can see what version of rcrossref you have

GegznaV commented 5 years ago

rcrossref 0.9.2.9610 (2019-09-27)

sckott commented 5 years ago

@haozhu233 do you have time to take a look at this?

sckott commented 5 years ago

@GegznaV the person that maintains that part of this pkg is on leave for a bit

sckott commented 5 years ago

Seems like https://github.com/thomasp85/shinyFiles could be used to help the user select a file location - don't have time right now to try this out though

sckott commented 4 years ago

@GegznaV if you have any interest, you could try implementing and sending a PR