From d9669b14986f564f43131e0f16f71a8bc952ff2c Mon Sep 17 00:00:00 2001 From: elena Date: Thu, 23 Nov 2023 15:19:11 +0100 Subject: [PATCH] expand repo links --- R/bs4_book.R | 27 +++++++++++++++++++++++---- man/publish_book.Rd | 16 ++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/R/bs4_book.R b/R/bs4_book.R index 9f9b13403..97c96c072 100644 --- a/R/bs4_book.R +++ b/R/bs4_book.R @@ -419,16 +419,35 @@ tweak_navbar <- function(html, toc, active = "", rmd_index = NULL, repo = NULL) repo$subdir <- paste0(repo$subdir, "/") } - repo_edit <- paste0(repo$base, "/edit/", repo$branch, "/", repo$subdir, rmd_index[[active]]) - repo_view <- paste0(repo$base, "/blob/", repo$branch, "/", repo$subdir, rmd_index[[active]]) + if(grepl("dev.azure", repo$base)) { + repo_edit <- paste0(repo$base, "?path=/", rmd_index[[active]]) + repo_view <- repo_edit + } else if(grepl("bitbucket", repo$base)){ + repo_edit <- paste0(repo$base, "/browse/", rmd_index[[active]]) + repo_view <- repo_edit + } else { + repo_edit <- paste0(repo$base, "/edit/", repo$branch, "/", repo$subdir, rmd_index[[active]]) + repo_view <- paste0(repo$base, "/blob/", repo$branch, "/", repo$subdir, rmd_index[[active]]) + } + } else { repo_edit <- NULL repo_view <- NULL } if (!is.null(repo$base)) { - icon <- repo$icon %n% - ifelse(grepl("github\\.com", repo$base), "fab fa-github", "fab fa-gitlab") + icon <- repo$icon %n% { + if(grepl("github\\.com", repo$base)) { + "fab fa-github" + } else if (grepl("dev.azure", repo$base)) { + "fab fa-microsoft" + } else if (grepl("dev.azure", repo$base)) { + "fab fa-bitbucket" + } else { + "fab fa-gitlab" + } + } + template_link_icon(html, ".//a[@id='book-repo']", icon) template_link_icon(html, ".//a[@id='book-source']", icon) template_link_icon(html, ".//a[@id='book-edit']", icon) diff --git a/man/publish_book.Rd b/man/publish_book.Rd index 091c75a04..856ae16a1 100644 --- a/man/publish_book.Rd +++ b/man/publish_book.Rd @@ -23,12 +23,16 @@ published to account or any single account already associated with \item{server}{Server to publish to (by default beta.rstudioconnect.com but any RStudio Connect server can be published to).} -\item{render}{Rendering behavior for site: "none" to upload a -static version of the current contents of the site directory; -"local" to render the site locally then upload it; "server" to -render the site on the server. Note that for "none" and "local" -R scripts (.R) and markdown documents (.Rmd and .md) will not be -uploaded to the server.} +\item{render}{Rendering behavior for site: +\itemize{ +\item \code{"none"} uploads a static version of the current contents of +the site directory. +\item \code{"local"} renders the site locally then uploads it. +\item \code{"server"} uploads the source of the site to render on the server. +} + +Note that for \code{"none"} and \code{"local"} source files (e.g. \code{.R}, \code{.Rmd} and +\code{.md}) will not be uploaded to the server.} } \description{ Publish a book to the web. Note that you should be sure to render all