From f3dad30df5b8807dd562a40bd83ee2ae8aa811a2 Mon Sep 17 00:00:00 2001 From: Mathieu Loiseau <mathieu.loiseau@univ-grenoble-alpes.fr> Date: Wed, 20 Mar 2019 15:41:39 +0100 Subject: [PATCH] mediawikir:postContent now allows summary --- DESCRIPTION | 2 +- R/class.R | 11 ++++++----- man/Mediawikir.Rd | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 745e3e6..7bc2d08 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.9 +Version: 0.1.10 Author: Mathieu Loiseau Maintainer: Mathieu Loiseau <loiseaum@univ-grenoble-alpes.fr> 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. diff --git a/R/class.R b/R/class.R index 683cee5..c07a25d 100644 --- a/R/class.R +++ b/R/class.R @@ -62,7 +62,8 @@ library(stringr) #' \item{\code{raw} → No editing of the content}{} #' }} #' }} -#' \item{\code{postContent()}}{To replace the content of \code{page} with \code{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} @@ -182,7 +183,7 @@ Mediawikir <- R6Class("Mediawikir", ###### # postContent ###### - postContent = function(){ + postContent = function(comment="R generated content"){ success <- TRUE tryCatch( { #Verify that a page has been selected @@ -216,7 +217,7 @@ Mediawikir <- R6Class("Mediawikir", fields <- list(action = "edit", title = self$page, #basetimestamp = "TODO", - summary = "R generated content", + summary = comment, format = "json", text = self$content, token = response$query$tokens$csrftoken) @@ -225,7 +226,7 @@ Mediawikir <- R6Class("Mediawikir", fields <- list(action = "edit", pageid = self$page, #basetimestamp = "TODO", - summary = "R generated content", + summary = comment, format = "json", text = self$content, token = response$query$tokens$csrftoken) @@ -293,7 +294,7 @@ Mediawikir <- R6Class("Mediawikir", if(newText != formerText){ self$resetContent() self$addContent(newText, "raw") - success <- self$postContent() + success <- self$postContent(paste(field," → ", newValue, sep="")) } else{ success <- paste("No modification of ",self$page," due to setting “",field,"†to “",newValue,"â€.",sep="") diff --git a/man/Mediawikir.Rd b/man/Mediawikir.Rd index e25d1ea..42c6614 100644 --- a/man/Mediawikir.Rd +++ b/man/Mediawikir.Rd @@ -60,7 +60,8 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use \item{\code{raw} → No editing of the content}{} }} }} - \item{\code{postContent()}}{To replace the content of \code{page} with \code{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} -- GitLab