The googlesites package is the R implementation of the Google Sites API. Using this package assumes you’ve used the Web UI to create your site. Once you’ve got a site (and maybe some templates), you can use this package to add more content, add attachments, find content, and delete content. This package allows you to store HTML pages and other static content locally and under version control and push it to your site programmatically whenever you feel like it.
See my blog post on why Google Sites aren’t such a bad thing: Google Sites for Documentation
View source code on GitHub at: https://github.com/StevenMMortimer/googlesites
First, you’ll need to install this package from GitHub.
devtools::install_github("StevenMMortimer/googlesites")
Second, you’ll need to go through a process of authenticating with Google and specifying the domain and site name so you don’t have to refer to it explicitly each time you call a function.
library(googlesites)
options(googlesites.site_domain = "site") # or your Apps domain
options(googlesites.site_name = "my-site")
library(googleAuthR)
options(googleAuthR.scopes.selected = "https://sites.google.com/feeds/")
gar_auth()
Third, do stuff to your site! After you’ve loaded and configured that package, you can take advantage of all the functionality of this package to manage your site. Like this:
test_html <- system.file("extdata", "example-site", "test.html", package="googlesites")
add_html_page(page_xhtml_source = test_html,
page_title = 'API Test',
page_custom_url = 'api-test',
overwrite=TRUE)
find_content(value_to_match='API Test',
field_to_match='title',
content_category='webpage')
pdf_cheatsheet <- 'https://www.rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf'
download.file(pdf_cheatsheet, 'rmarkdown-cheatsheet-2.0.pdf', mode="wb")
upload_file_to_site(local_file_path = "rmarkdown-cheatsheet-2,0.pdf",
parent_page_id = find_content(value_to_match='API Test',
field_to_match='title')$id)
delete_content(id = find_content(value_to_match='API Test',
field_to_match='title')$id)
This package currently supports the bare minimum for maintaining and uploading content to a Google Site. It’s anticipated that other functions to list sites, create sites, update site categories, and manage user permissions will be created and added to this package in the future to expand its capabilities. Thank you for using.
If you have further questions please submit them via email or issue on GitHub at https://github.com/StevenMMortimer/googlesites/issues. I’m happy to answer questions, but please do not ask questions with code in Disqus comments. Thank you!
This project was made with love and coffee. Studies show that I write R code 3x faster after drinking one cup coffee and that productivity scales linearly. Imagine what I could accomplish if you bought me 10 cups of coffee…
Thank you for your support!