## AUTHOR: BRIAN M. BOT
#####
## THIS SIGNATURE GETS INFO ABOUT REPOSITORY IF REPOSITORY IS PASSED AS A CHARACTER STRING
setMethod(
f = "getPermlink",
signature = signature("character", "ANY"),
definition = function(repository, repositoryPath, ...){
argList <- list(...)
argList[["repository"]] <- repository
if( any(names(argList) == "type") ){
type <- tolower(argList[["type"]])
argList[["type"]] <- NULL
} else{
type <- "html"
}
myRepo <- do.call(getRepo, argList)
if( missing(repositoryPath) ){
getPermlink(myRepo, as.character(NA), type=type)
} else{
getPermlink(myRepo, repositoryPath, type=type)
}
}
)
## HANDLE MISSING CASE FOR REPOSITORY PATH
setMethod(
f = "getPermlink",
signature = signature("githubRepo", "missing"),
definition = function(repository, repositoryPath, ...){
getPermlink(repository, as.character(NA), ...)
}
)
## THE MOST SPECIFIC OF THE FUNCTIONS (WHICH ALL WILL END UP CALLING)
setMethod(
f = "getPermlink",
signature = signature("githubRepo", "character"),
definition = function(repository, repositoryPath, ...){
argList <- list(...)
if( any(names(argList) == "type") ){
type <- tolower(argList[["type"]])
if( !(type %in% c("raw", "html")) ){
stop("type must be either 'raw' or 'html'")
}
} else{
type <- "html"
}
if( !is.na(repositoryPath) & !(repositoryPath %in% repository@tree$path) ){
stop(sprintf("repositoryPath %s does not match any paths within the repository tree", repositoryPath))
}
if( type == "raw" ){
if( is.na(repositoryPath) ){
stop("repositoryPath must be specified for type='raw'")
}
permlink <- .constructRawPermlink(repository, repositoryPath)
}
if( type == "html" ){
permlink <- .constructHtmlPermlink(repository, repositoryPath)
}
return(permlink)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.