Description: Mediawikir class can be used to post the output of an R script directly into a mediawiki instance. Batchator class allows batch page creation.
@@ -11,8 +11,60 @@ Object of \code{\link{R6Class}} with methods to interact with mediawiki instance
\description{
A Mediawikir controller serves to connect to a mediawiki API as a registered user in order to edit automatically certain documents based on R scripts
}
\section{}{
NA
\section{Methods}{
\describe{
\item{\code{initialize(instance_url, user, pass)}}{Creates a new \pkg{Mediawikir} object out of:
\describe{
\item{\code{instance_url}}{The base url to the mediawiki instance}
\item{\code{user}}{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{dir}}{In case of \href{https://www.mediawiki.org/wiki/Manual:Short_URL}{short Url configuration},
the base url for mediawiki is not the actual directory containing the api and index.php files. In these cases,
the user should specify the installation directory of mediawiki from the base_url.}}}
\item{\code{setPage(pageNameOrId)}}{To set the page for the next post
\describe{
\item{\code{pageNameOrId}}{The name (or id) of the wiki page which contains the changes}
}}
\item{\code{connect(pass)}}{Should not be called directly (see \code{initialize} for detail)}
\item{\code{resetContent(baseContent="")}}{To reset the content of the page for the next post
\describe{
\item{\code{baseContent}}{The wikitext base for the next post}
}}
\item{\code{addContent(theContent, type="p")}}{To add content that will later on be posted to mediawiki. This is where structuring elements are provided
\describe{
\item{\code{theContent}}{Either text (using mediawiki syntax) or path to a file}
\item{\code{type}}{\describe{
\item{\code{p} → A plain paragraph.}{}
\item{\code{h2} → Level 2 title}{}
\item{\code{h3} → Level 3 title}{}
\item{\code{h4} → Level 4 title}{}
\item{\code{h5} → Level 5 title}{}
\item{\code{raw} → No editing of the content}{}
}}
}}
\item{\code{postContent(comment)}}{To replace the content of the \code{page} (attribute) with \code{content} (attribute).
Parameter \code{comment} specifies the description of the modification, default is \code{“R generated content”}}
\item{\code{uploadFile(file_path, file_name)}}{To upload a file to the server (will overwrite existing files)
\describe{
\item{\code{file_path}}{Path to the file to upload to the server}
\item{\code{file_name}}{Name under which to store it}
\item{Returns the title of the wiki page containing the file or \code{FALSE} on error}{}
}}
\item{\code{getContent()}}{Returns the \emph{wikitext} of the selected page (cf. \code{setPage})}
\item{\code{replaceSingleLineTemplateField(template, field, newValue)}}{To replace a field of a template in the selected \code{page}.
This method does not work with numbered parameters. If the sought field does not exist, adds it at the beginning of the template.
Right now it works only for pages that only contain one occurence of the parameter (it does not take outer context into account)
Additionnally, this function is not made for templates the value of which spans accross multiple lines.
\describe{
\item{\code{template}}{The template to look for}
\item{\code{field}}{The name of the field concerned}
\item{\code{newValue}}{The new value of the field}