Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mediawikiR
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathieu Loiseau
mediawikiR
Commits
000c14cd
Commit
000c14cd
authored
6 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
with page name pattern using csv columns
parent
8ddd016a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DESCRIPTION
+1
-1
1 addition, 1 deletion
DESCRIPTION
R/class.R
+15
-9
15 additions, 9 deletions
R/class.R
with
16 additions
and
10 deletions
DESCRIPTION
+
1
−
1
View file @
000c14cd
Package: mediawikir
Type: Package
Title: Connects to a mediawiki instance and writes in it what you want
Version: 0.1.
3
Version: 0.1.
4
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
...
...
This diff is collapsed.
Click to expand it.
R/class.R
+
15
−
9
View file @
000c14cd
...
...
@@ -255,8 +255,7 @@ Batchator <- R6Class("Batchator",
public
=
list
(
author
=
NULL
,
wiki
=
NULL
,
page_prefix
=
""
,
page_names
=
NULL
,
page_name_pattern
=
NULL
,
template
=
NULL
,
field_list
=
NULL
,
content
=
NULL
,
...
...
@@ -264,10 +263,9 @@ Batchator <- R6Class("Batchator",
######
# initialize
######
initialize
=
function
(
wiki
,
author
,
pass
,
prefix
){
initialize
=
function
(
wiki
,
author
,
pass
){
tryCatch
({
self
$
wiki
<-
Mediawikir
$
new
(
wiki
,
author
,
pass
)
self
$
page_prefix
<-
prefix
},
error
=
function
(
e
){
print
(
e
$
message
)
...
...
@@ -287,6 +285,13 @@ Batchator <- R6Class("Batchator",
})
},
######
# setPageNamePattern
######
setPageNamePattern
=
function
(
naming_pattern
){
self
$
page_name_pattern
=
naming_pattern
},
######
# loadContent
######
...
...
@@ -294,7 +299,6 @@ Batchator <- R6Class("Batchator",
tryCatch
({
csvM
<-
read.csv
(
file
=
file_path
,
header
=
FALSE
)
self
$
field_list
<-
as.vector
(
t
(
csvM
[
1
,]))
self
$
page_names
<-
csvM
[
-1
,
1
]
self
$
content
<-
csvM
[
-1
,]
},
error
=
function
(
e
){
...
...
@@ -309,17 +313,19 @@ Batchator <- R6Class("Batchator",
tryCatch
({
if
(
is.null
(
self
$
content
)
|
is.null
(
self
$
field_list
)
|
is.null
(
self
$
page_name
s
)
|
is.null
(
self
$
page_name
_pattern
)
|
is.null
(
self
$
template
))
{
warning
(
"Either no content or no template, use loadContent and/or loadTemplate."
)
warning
(
"Either no content or no template
s
, use loadContent
, setPageNamePattern
and/or loadTemplate."
)
}
else
{
for
(
i
in
1
:
nrow
(
self
$
content
)){
self
$
wiki
$
resetContent
(
str_replace_all
(
self
$
template
,
setNames
(
as.vector
(
t
(
self
$
content
[
i
,])),
self
$
field_list
)))
self
$
wiki
$
setPage
(
paste
(
self
$
page_prefix
,
self
$
page_names
[
i
],
sep
=
""
))
#self$wiki$postContent()
self
$
wiki
$
setPage
(
str_replace_all
(
self
$
page_name_pattern
,
setNames
(
as.vector
(
t
(
self
$
content
[
i
,])),
self
$
field_list
)))
self
$
wiki
$
postContent
()
}
}
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment