Skip to content
Snippets Groups Projects
Commit 9f20f201 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

Batchator load template & content

parent 36164ff3
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ library(httr) ...@@ -7,6 +7,7 @@ library(httr)
#'@importFrom R6 R6Class #'@importFrom R6 R6Class
#'@importFrom httr POST #'@importFrom httr POST
#'@importFrom httr stop_for_status #'@importFrom httr stop_for_status
#'@importFrom httr upload_file
#'@importFrom httr content #'@importFrom httr content
#'@export #'@export
#'@keywords mediawiki #'@keywords mediawiki
...@@ -231,30 +232,59 @@ Mediawikir <- R6Class("Mediawikir", ...@@ -231,30 +232,59 @@ Mediawikir <- R6Class("Mediawikir",
) )
) )
library(stringr)
#'Batchator: Batch input to mediawiki based on a csv and a template #'Batchator: Batch input to mediawiki based on a csv and a template
#' #'
#'@docType class #'@docType class
#'@export #'@export
#'@importFrom stringr str_replace_all
#'@keywords mediawiki #'@keywords mediawiki
#'@description Uses mediawikir to create a batch of pages #'@description Uses mediawikir to create a batch of pages
Batchator <- R6Class("Batchator", Batchator <- R6Class("Batchator",
public = list( public = list(
author = NULL, author = NULL,
wiki = NULL, wiki = NULL,
prefix ="", page_prefix ="",
template = NULL,
content = NULL,
###### ######
# initialize # initialize
###### ######
initialize = function (wiki,author,pass,prefix){ initialize = function (wiki,author,pass,prefix){
tryCatch({ tryCatch({
self$wiki <- Mediawikir$new(wiki, author, pass) self$wiki <- Mediawikir$new(wiki, author, pass)
self$prefix <- prefix self$page_prefix <- prefix
}, },
error = function(e){ error = function(e){
print(e$message) print(e$message)
self <- FALSE 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"))
})
} }
) )
) )
mediawikir mediawikir
========= =========
Un package R pour connecter la sortie d'un script R à une instance de [MediaWiki](https://www.mediawiki.org/wiki/Download) 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.
Pour plus de détails voir la documentation R associée
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment