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

Batchator base working, but doc with bad links

parent 000c14cd
No related branches found
No related tags found
No related merge requests found
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
......
......@@ -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,
......
......@@ -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}
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