Is there a way to open a user's vignette in a Shiny link?

I've got a package that has a shiny app included. I would like to include a link in the app to open the vignette. I'd prefer to have the link directly open the user's version of the vignette (ie...I'd rather not have to maintain a copy of the vignettes online somewhere). I'm not sure the package will ever go to CRAN, so I don't want to depend on a CRAN link either (and the shiny app will only ever be run locally). I've tried this is the ui code:

vig_path <- system.file("doc", package="myPackage")      
HTML(paste0("<a href=\"file:///", vig_path,"/Introduction.html\">Introduction</a>"))

When copy the link location and paste it in the browser (ie, from "Inspect" via Chrome dev tools), it opens (so, the path is correct). There is an error "Not allowed to load local resource:". So, am I just out of luck, or is there a trick to open local files that I'm missing?

Would adding the attr target="_blank" solve your issue? It would open the link in a new tab and it could contain it's own protocol.

Link: https://www.w3schools.com/tags/att_a_target.asp

target="_blank" did not solve the issue.

This did solve the problem:

it's a bit annoying to have to rebuild the package to check every change in the app, but it will work. I might just bite the bullet and push up the vignettes to a pkgdown site.

Iā€™m glad you found a solution! :grin:

For future reference, this community has a policy on cross-posting: FAQ: Is it OK if I cross-post?

The goal is to avoid helpers spending their (volunteer!) time and effort on questions that have already been answered elsewhere. The gist:

  1. Avoid simultaneous cross-posting. Pick the best outlet for your question and allow a reasonable amount of time (days, not hours) to get a response before seeking more help elsewhere.
  2. If you wind up sequentially cross-posting between this site and another site, clearly state that you have cross-posted and include a link to the other post
  3. If your question gets answered somewhere else, say so here as soon as possible (thanks very much for doing this part!)

Sorry! Prefer this forum, last-minute waffling on where to ask. Thanks for the info

1 Like