ESHackathon / CiteSource

http://www.eshackathon.org/CiteSource/
GNU General Public License v3.0
16 stars 1 forks source link

RIS file not exporting from Shiny app #176

Closed rootsandberries closed 2 months ago

rootsandberries commented 4 months ago

I get the following message when trying to export RIS (csv and bibtex are working fine):

Warning in export_ris(rv$latest_unique, file) : Function saves a RIS file, so filename should (usually) end in .ris. For now, name is used as provided.

Final Mapping: DB : cite_source_include C7 : cite_label_include C8 : cite_string_include C1 : duplicate_id C2 : record_ids Do you want to proceed with this mapping? (yes/no): y Export cancelled. Please modify your user_mapping argument and try again.

When I choose yes or no, it exports a file with this name: downloadRis.html and also gives me the following error (weirdly, nothing actually saves when I save this file or when I change the extension to RIS).

Export cancelled. Please modify your user_mapping argument and try again.

TNRiley commented 4 months ago

I noticed the same thing and have it listed on issue #152 which has a number of consolidated shiny issues.

TNRiley commented 4 months ago

This error is due to a change I made recently to help users map IDs and tags to specific fields. I wanted to give the user an option to review the mapping before export. I'm not sure if we could replicate this function in the shiny export, but that would be nice. I'll keep looking at this - I'm also going to remove it from #152 as this mapping function would be useful.

TNRiley commented 4 months ago

possible to add these option in the shiny with this? - I'm not experienced with the shiny UI file. Let's discuss.

export_ris_shiny <- function(input, output, session, citations, filename = "output.ris") {

  # Default mapping of RIS fields to citations columns
  default_mapping <- reactive({
    list(
      "DB" = input$cite_source_include,
      "C7" = input$cite_label_include,
      "C8" = input$cite_string_include,
      "C1" = input$duplicate_id,
      "C2" = input$record_ids
    )
  })

  observeEvent(input$confirm_mapping, {
    # Rename the citations columns according to the final mapping
    for (field in names(default_mapping())) {
      if (default_mapping()[[field]] %in% names(citations)) {
        citations <- citations %>% dplyr::rename(!!field := .data[[default_mapping()[[field]]]])
      }
    }

    # Currently, write_refs does not accept tibbles, thus converted
    write_refs(as.data.frame(citations), file = filename)
  })
}

need to add the appropriate input widgets to your UI for the user to select the mapping, and an action button with the ID confirm_mapping for the user to confirm the mapping.

DrMattG commented 3 months ago

I changed the function back so it is able to download RIS - with the default mapping for the moment (so the shiny works) whilst I try and include mapping choices

TNRiley commented 3 months ago

I changed the function back so it is able to download RIS - with the default mapping for the moment (so the shiny works) whilst I try and include mapping choices

I'm still running into export issues with the .ris in the shiny, still tries do download as downloadRis.htm

DrMattG commented 3 months ago

I changed the function back so it is able to download RIS - with the default mapping for the moment (so the shiny works) whilst I try and include mapping choices

I'm still running into export issues with the .ris in the shiny, still tries do download as downloadRis.htm

Because I forgot to merge the pull request!