ropensci-archive / wishlist

:no_entry: ARCHIVED :no_entry:
https://discuss.ropensci.org/c/wishlist/6
50 stars 4 forks source link

Posting an rmarkdown from R to WordPress #17

Closed talgalili closed 2 years ago

talgalili commented 9 years ago

I think it would be a huge help for bloggers (such as myself), to be able to publish to WordPress from R.

The ideal solution will take an R markdown, and will turn it into a post, including the upload of the figures to the server, getting the syntax highlighting to work, and maybe even know how to work with embedded javascripts (for when using things such as htmlwidgets).

I don't know how to do this myself, but I will happily beta-test such a product (and will help share it with bloggers of r-bloggers.com)

cboettig commented 9 years ago

This should be pretty straight-forward by defining the appropriate knitr hooks. The details might depend on if the user has a self-hosted (wordpress.org) site with plugins or a wordpress.com site; I suppose the latter is a good place to start though.

Meanwhile, I have some examples of this from when I was using a wordpress platform several years ago; may need some updating now:

http://www.carlboettiger.info/2012/02/27/using-knitr-and-rwordpress-to-publish-results-directly-from-r-6.html

http://www.carlboettiger.info/2012/02/28/knitr-with-flickr-and-wordpress.html

Certainly a more updated/packaged solution would be nice.

talgalili commented 9 years ago

Hi Carl, thank you for the links and directions! I hope you, or someone else, could pick this up / wrap this into a package.

jaredlander commented 7 years ago

Hi all, this would be huge. Was this ever incorporated anywhere?

karthik commented 7 years ago

Not yet, Jared. It's still a wish list item that we are waiting to see if someone will take on.

jaredlander commented 7 years ago

Got it, I guess it's a hard one.

jaredlander commented 7 years ago

I wrote a knitr print function to save htmlwidgets to an html file then create an iframe displaying the html file. The the iframe points to a URL specified in as a global chunk options.

Now if someone can the code to upload the html files to Wordpress (not every time it is knitted, but only when wanted), and to upload the main html file to Wordpress, we'd be there.

knitr::opts_chunk$set(widgetWebDir='https://www.host.com/widgets/FeedForwardMXNet')
knit_print.htmlwidget <- function(x, options, inline=FALSE, ...)
{
    width <- if(!is.null(options$out.width)) options$out.width else '100%'
    height <- if(!is.null(options$out.height)) options$out.height else 800

    saveName <- sprintf('%s.html', options$label)
    htmlwidgets::saveWidget(x, saveName)

    knitr::asis_output(sprintf(
        '<iframe src="%s/%s" width="%s" height="%s"></iframe>',
        options$widgetWebDir, saveName, width, height
    ))
}
DT::datatable(iris)

I'm sure we can be cleaner with the paths and where the html files are stored locally.

maelle commented 2 years ago

Thank you!

Note that future ideas should go to our wishlist forum category.

maelle commented 2 years ago

Relevant links

https://github.com/maelle/goodpress not maintained actively

https://github.com/yihui/knitr/issues/1866