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

add paragraph and titles to content (not online yet)

parent 358ad494
No related branches found
No related tags found
No related merge requests found
......@@ -18,15 +18,30 @@ library(R6)
#'@field content the future content of \code{page_name}, which will be incrementally constructed using object methods
#'@examples
#' mwHandler <- Mediawikir$new("http://my.wiki.org", "reg_user", "mypassword", "wikiPage")
#' mwHandler$addContent("This is an introduction to Mediawikir")
#' mwHandler$addContent("First step","h2")
#' mwHandler$addContent("First step of the first step","h3")
#'@section Methods:
#'\describe{
#' \item{\code{initialize(instance_url, user, page, pass)}}{Creates a new Mediawikir object out of:\describe{
#' \item{\code{initialize(instance_url, user, page, pass)}}{Creates a new 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{page}}{The wiki page which contains the changes}
#' \item{\code{pass}}{The user's password}
#' }}
#' \item{\code{connect(pass)}}{Should not be called directly (see initialize for detail)}
#' \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}{}
#' }}
#' }}
#'}
Mediawikir <- R6Class("Mediawikir",
public = list(
......@@ -90,6 +105,20 @@ Mediawikir <- R6Class("Mediawikir",
print(e$message)
self <- FALSE
})
},
######
# addContent
######
addContent = function(theContent, type="p"){
switch(type,
h2 = theContent <- paste("==", theContent, "=="),
h3 = theContent <- paste("===", theContent, "==="),
h4 = theContent <- paste("====", theContent, "===="),
h5 = theContent <- paste("=====", theContent, "====="),
p = theContent <- paste(theContent, "\n", sep=""),
)
self$content <- paste(self$content, theContent, sep="\n")
}
)
)
......@@ -29,17 +29,32 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use
\section{Methods}{
\describe{
\item{\code{initialize(instance_url, user, page, pass)}}{Creates a new Mediawikir object out of:\describe{
\item{\code{initialize(instance_url, user, page, pass)}}{Creates a new 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{page}}{The wiki page which contains the changes}
\item{\code{pass}}{The user's password}
}}
\item{\code{connect(pass)}}{Should not be called directly (see initialize for detail)}
\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}{}
}}
}}
}
}
\examples{
mwHandler <- Mediawikir$new("http://my.wiki.org", "reg_user", "mypassword", "wikiPage")
mwHandler$addContent("This is an introduction to Mediawikir")
mwHandler$addContent("First step","h2")
mwHandler$addContent("First step of the first step","h3")
}
\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