diff --git a/DESCRIPTION b/DESCRIPTION index 1d8a7a4740de58283fa7691b5b49ca0bb97f3228..b3bee77f9387b67b44ebe17a8dc82d9e74c295c3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mediawikir Type: Package Title: Connects to a mediawiki instance and writes in it what you want -Version: 0.1.4 +Version: 0.1.5 Author: Mathieu Loiseau Maintainer: Mathieu Loiseau <loiseaum@univ-grenoble-alpes.fr> Description: It can be used to post the output of an R script directly into a mediawiki instance diff --git a/R/class.R b/R/class.R index 1e1c0e9a9dfe70620ee0f75ca1564dfe8663b2f3..24af10ea497fd0acb901b3dfb217a7c5d4d5ff02 100644 --- a/R/class.R +++ b/R/class.R @@ -248,9 +248,55 @@ library(stringr) #' #'@docType class #'@export -#'@importFrom stringr str_replace_all #'@keywords mediawiki -#'@description Uses mediawikir to create a batch of pages +#'@description Uses \link{Mediawikir} to create/edit a batch of mediawiki pages +#'@format An \code{\link{R6Class}} generator object +#'@return Object of \code{\link{R6Class}} with methods to interact with mediawiki instance +#'@field author the mediawiki user who will be the author of the pages/modifications +#'@field wiki a mediawikir object +#'@field page_name_pattern a pattern to name the pages generated +#'@field template the content of a text file with the template for the wikitext of the pages to create in a batch +#'@field field_list the list of symbols that will be replaced (the first line of the csv file that will be sent to the Batchator) +#'@field content a matrix of the words that will replace the symbols in the templates (both content and page names — the next lines of the csv file) +#'@examples +#' bachata <- Batchator$new("http://wiki.lezinter.net", "user","pass") +#' bachata$loadTemplate("/path/to/template.wiki") +#' bachata$loadContent("/path/to/content.csv") +#' bachata$setPageNamePattern("Project:Media/Sounds/~word~ (~voice_artist~)") +#' bachata$applyTemplate() +#' #content of "template.wiki" : {{menuLUCIOLE}} +#' # {{Sound info +#' # |title=~word~ (~voice_artist~) +#' # |type=word +#' # |text=~word~ +#' # |language=en +#' # |character=~char~ +#' # |validation=recorded +#' # |theme=~theme~}} +#' #content of "content.csv" +#' #"~word~","~theme~","~char~","~voice_artist~" ↠the field list (see they are used in the templates above) +#' #"Zero","numbers","Awful Owen","Carlos" +#' #"One","numbers","Awful Owen","Carlos" +#' #"One","numbers","Black Betty","Carla" +#' #3 pages are created in this example… +#'@section Methods: +#'\describe{ +#' \item{\code{initialize(wiki,author,pass)}}{Creates a new Batchator object (and its Mediawikir object as an attribute) +#' \describe{ +#' \item{\code{wiki}}{The base url to the mediawiki instance} +#' \item{\code{authr}}{The screen name of the user who will be credited for the changes in the wiki} +#' \item{\code{pass}}{The user's password} +#' }} +#' \item{\code{loadTemplate(file_path)}}{Takes the path of a text file containing a template that will serve as base +#' for all the pages generated. The template should contain occurrences of the fields defined in the \link{content} file.} +#' \item{\code{setPageNamePattern(naming_pattern)}}{Takes a string of the parttern for the page names that will be generated. +#' The template should contain occurrences of the fields defined in the \link{content} file.} +#' \item{\code{loadContent(file_path)}}{Takes the path to a csv file that contains both the list of fields used in the templates (1st line) +#' AND the data for each of those fields (following lines).} +#' \item{\code{applyTemplate()}}{Applies the templates defined using \link{loadTemplate}, \link{setPageNamePattern} to the data loaded with \link{loadContent}.} +#'} +#'@importFrom stringr str_replace_all + Batchator <- R6Class("Batchator", public = list( author = NULL, diff --git a/man/Batchator.Rd b/man/Batchator.Rd index 93afe1b8463a76b2d0c9c858f3f80ea3df3b5b42..32bd3566c08ebbc6cccf00a61e4aeb8132f61d15 100644 --- a/man/Batchator.Rd +++ b/man/Batchator.Rd @@ -4,11 +4,71 @@ \name{Batchator} \alias{Batchator} \title{Batchator: Batch input to mediawiki based on a csv and a template} -\format{An object of class \code{R6ClassGenerator} of length 24.} +\format{An \code{\link{R6Class}} generator object} \usage{ Batchator } +\value{ +Object of \code{\link{R6Class}} with methods to interact with mediawiki instance +} \description{ -Uses mediawikir to create a batch of pages +Uses \link{Mediawikir} to create/edit a batch of mediawiki pages +} +\section{Fields}{ + +\describe{ +\item{\code{author}}{the mediawiki user who will be the author of the pages/modifications} + +\item{\code{wiki}}{a mediawikir object} + +\item{\code{page_name_pattern}}{a pattern to name the pages generated} + +\item{\code{template}}{the content of a text file with the template for the wikitext of the pages to create in a batch} + +\item{\code{field_list}}{the list of symbols that will be replaced (the first line of the csv file that will be sent to the Batchator)} + +\item{\code{content}}{a matrix of the words that will replace the symbols in the templates (both content and page names — the next lines of the csv file)} +}} + +\section{Methods}{ + +\describe{ + \item{\code{initialize(wiki,author,pass)}}{Creates a new Batchator object (and its Mediawikir object as an attribute) + \describe{ + \item{\code{wiki}}{The base url to the mediawiki instance} + \item{\code{authr}}{The screen name of the user who will be credited for the changes in the wiki} + \item{\code{pass}}{The user's password} + }} + \item{\code{loadTemplate(file_path)}}{Takes the path of a text file containing a template that will serve as base + for all the pages generated. The template should contain occurrences of the fields defined in the \link{content} file.} + \item{\code{setPageNamePattern(naming_pattern)}}{Takes a string of the parttern for the page names that will be generated. + The template should contain occurrences of the fields defined in the \link{content} file.} + \item{\code{loadContent(file_path)}}{Takes the path to a csv file that contains both the list of fields used in the templates (1st line) + AND the data for each of those fields (following lines).} + \item{\code{applyTemplate()}}{Applies the templates defined using \link{loadTemplate}, \link{setPageNamePattern} to the data loaded with \link{loadContent}.} +} +} + +\examples{ + bachata <- Batchator$new("http://wiki.lezinter.net", "user","pass") + bachata$loadTemplate("/path/to/template.wiki") + bachata$loadContent("/path/to/content.csv") + bachata$setPageNamePattern("Project:Media/Sounds/~word~ (~voice_artist~)") + bachata$applyTemplate() + #content of "template.wiki" : {{menuLUCIOLE}} + # {{Sound info + # |title=~word~ (~voice_artist~) + # |type=word + # |text=~word~ + # |language=en + # |character=~char~ + # |validation=recorded + # |theme=~theme~}} + #content of "content.csv" + #"~word~","~theme~","~char~","~voice_artist~" ↠the field list (see they are used in the templates above) + #"Zero","numbers","Awful Owen","Carlos" + #"One","numbers","Awful Owen","Carlos" + #"One","numbers","Black Betty","Carla" + #3 pages are created in this example… } \keyword{mediawiki}