diff --git a/R/class.R b/R/class.R index 987b1b3e2266e243fcdd221cf8b91ffaf1a6d19f..80969316806c2354a7e72f838f7e0bee5634d685 100644 --- a/R/class.R +++ b/R/class.R @@ -7,6 +7,7 @@ library(httr) #'@importFrom R6 R6Class #'@importFrom httr POST #'@importFrom httr stop_for_status +#'@importFrom httr upload_file #'@importFrom httr content #'@export #'@keywords mediawiki @@ -231,30 +232,59 @@ Mediawikir <- R6Class("Mediawikir", ) ) +library(stringr) #'Batchator: Batch input to mediawiki based on a csv and a template #' #'@docType class #'@export +#'@importFrom stringr str_replace_all #'@keywords mediawiki #'@description Uses mediawikir to create a batch of pages Batchator <- R6Class("Batchator", public = list( author = NULL, wiki = NULL, - prefix ="", + page_prefix ="", + template = NULL, + content = NULL, + ###### # initialize ###### initialize = function (wiki,author,pass,prefix){ tryCatch({ self$wiki <- Mediawikir$new(wiki, author, pass) - self$prefix <- prefix + self$page_prefix <- prefix }, error = function(e){ print(e$message) self <- FALSE }) + }, + + ###### + # loadTemplate + ###### + loadTemplate = function(file_path){ + tryCatch({ + self$template <- readChar(file_path, file.info(file_path)$size) + }, + error = function(e){ + print(paste(e$message, "No template loaded")) + }) + }, + + ###### + # loadContent + ###### + loadContent = function(file_path){ + tryCatch({ + self$content <- read.csv(file=file_path, header = FALSE) + }, + error = function(e){ + print(paste(e$message, "No content loaded")) + }) } ) ) diff --git a/README.md b/README.md index 180f63d7678cb7ec95cb0cfb91fec0701ae89fae..282f34f7f29742bad6761676e9ca25ff17fdc648 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ mediawikir ========= -Un package R pour connecter la sortie d'un script R à une instance de [MediaWiki](https://www.mediawiki.org/wiki/Download) - -Pour plus de détails voir la documentation R associée \ No newline at end of file +An R package to connect an R script to a [MediaWiki](https://www.mediawiki.org/wiki/Download) instance. This also provides a class to perform batch page creation.