How to import data
—
!!1!
!
>How to import data into a Soks wiki
—
!!2!
!
—
!!3!
!
The basic question: How can I import data into Soks?
(both pages and attachments)
!
!4!
!
—
!!5!
!
I have a table worth of information that I would like to load into my Soks wiki.
Each row of the table will become a page and each row has a PDF file associated with it.
!
!6!
!
—
!!7!
!
What would be the process of dumping my tabular data in the wiki?
Do I merely need to dump out
!
!8!
!
!
!9!
!
versions of the pages in the contents directory
(properly escaped)
?
Do I need the YAML revision companions?
Do I merely dump the PDF files in the
!
!10!
!
!
!11!
!
directory
(with proper
!
!12!
!
!
!13!
!
files also placed in
!
!14!
!
!
!15!
!
)?
!
!16!
!
So far,
I have something like,
!
!17!
!
!
!18!
!
—
!!19!
!
Am I heading in the correct direction?
Bil !
!20!
!
Yes.
comments:
—
!!21!
!
>
—
!!22!
!
You don’t need to escape the file-names,
Soks should detect they are not escaped and correct them.
!
!23!
!
!
!24!
!
You don’t need to create revisions files,
Soks will create them automatically.
!
!25!
!
!
!26!
!
If a revision file exists,
but is out of date,
Soks will bring the revision file up to date.
!
!27!
!
!
!28!
!
(I think you have realised this,
but just in case)
To import the PDFs,
you need to both put them in the attachment directory and create a page in the content directory whose name starts
‘attached
’ and whose content is
!
!29!
!
!
!30!
!
!
!31!
!
!
!32!
!
You can do this while the wiki is running
(soks periodically scans the content folder and updates itself with any changes
1) but if you are adding a lot of files it is best to stop the wiki while the changes are made.
—
tamc2 !
!33!
!
—
!!34!
!
—
!!35!
!
An alternative
(only appropriate if you plan to update the wiki from the database frequently)
would be to write a helper class that you call from start.rb and that uses the
@wiki.revise(pagename,
content,
author) methods.
!
!36!
!
—
!!37!
!
A third alternative would be to use DRb
(e.g.
write
!
!38!
!
!
!39!
!
!
!40!
!
!
!41!
!
somewhere in your start.rb file)
and then write a script
(or use irb)
to remotely call the
@wiki.revise(
pagename,
content,
author) methods.
!
!42!
!
—
!!43!
!
>
—
!!44!
!
1
—
!!45!
!
Changes detected by looking at the file’s timestamp,
not its content.
!
!46!
!
—
!!47!
!
Tag: Include this page in the distribution !
!48!
!