Tags:
automation1Add my vote for this tag create new tag
view all tags
Hi all,

is there any utility available using which Text pages can directly be converted into Twiki page or viewed as twiki page on the Twiki link.

basically i am running cron jobs which create text files. I would like these files to be viewable on my TWIKI site..

-- BinuAbraham - 14 Sep 2004

one way: use curl to upload the text files as attachments to a pre existing topic.

another: have the cron job put the output text file in a twiki data dir, e.g. $twikiroot/data/CronWeb/JobTwo.txt .The text files would need to be proper WikiWords and there will be no version control (your script will be responsible for not overwriting existing files).

another: there is a python plugin for offline editing of twiki topics you might be able to leverage, EditTWikiExternalEditorAddOn.

-- MattWilkie - 15 Sep 2004

If it's only a set number of files you could put them somewhere web accessable and use %INCLUDE{http://url.to.file}% to display them in topics.

-- SamHasler - 15 Sep 2004

If it's only a set number of files you could put them somewhere web accessable and use %INCLUDE{http://url.to.file}% to display them in topics.

-- SamHasler - 15 Sep 2004

Regarding what MattWilkie wrote, you can generate the version control history by running the ci command (part of RCS) after you copy the .txt file into the web's data directory.

For example, I do something like this:

su apache -s /bin/bash -c "ci -mnone -t-none -wcva -l BogusTopic.txt"

Where apache is the user who normally owns the files in the data directory, /bin/bash is the shell to use since, on my system, the apache user's default shell is /sbin/nologin, the "cva" part of -wcva is the initial author, and BogusTopic.txt is the topic I'm adding.

I'm not sure if this is 100% technically correct, but the *.txt,v files it generates look identical to what TWiki would have generated if I asked it to create the file.

-- ChrisAnderson - 14 Jul 2005

If you can't su to apache (and many people can't) you can cheat a bit. Put this script in your twiki bin directory:

#!/bin/sh
echo "Content-type: text/plain"
echo ""
ci -mnone -t-none -wcva -l /full/path/to/twiki/data/Web/BogusTopic.txt
make sure the permissions are correct and invoke it from the browser (get a testenv URL and replace the word 'testenv' with the name of your script).

-- CrawfordCurrie - 14 Jul 2005

This looks like the perfect application for an addon. I often need to generate TWiki pages and dump them in the data dir, but I'd be more comfortable if I could upload a topic via a cgi script, attachments and all, and unpack and check them all in. Maybe call it an AutomatedRemoteEditingAddOn (similar to the python EditTWikiExternalEditorAddOn, but implemented in perl) which checks out, downloads a topic (and optionally its attachments), optionally appends or edits the topic, repackages the topic and uploads it in the end for checkin.

-- PeterNixon - 15 Jul 2005

see also CPAN:WWW::Mechanize::TWiki

-- WillNorris - 15 Jul 2005

On newer Unix/Linux platforms you can do the su command above using the sudo command thus:

sudo -u apache ci -mnone -t-none -wTWikiGuest -l NewTopicFileName.txt
Note that the password that you are asked for is your own password.

-- DuncanKinnear - 26 Jan 2007

I strongly recommend to use the official API to manipulate topic content. Content can easily get out of sync if the .txt,v file is manipulated directly. For example, plugins and core will miss a trigger to do something (mail notification, content caching, etc.)

See TWikiFuncDotPm and TWikiPlugins.

-- PeterThoeny - 26 Jan 2007

I hear what you are saying Peter, but is there a document somewhere here on twiki.org that details how to externally create 1200+ topics in a batch mode?

I have created a script which parses the output of the wvHtml word viewer utility, and creates TWiki ML text for each document. I'd like to convert 1200+ Word Documents using an external batch script.

What sequence of function calls will allow me to create the topics?

Thanks in advance.

-- DuncanKinnear - 02 Feb 2007

Specifically, use the function TWiki::Func::saveTopic(), TWikiFuncDotPm to save topics. The tools/mailnotify with lib/TWiki/Contrib/Mailer.pm is an example of how TWiki should be initialized if called by a script.

-- PeterThoeny - 02 Feb 2007

Duncan, please consider publishing your script as an AddOn on twiki.org! I think many people would be very interested in Word doc conversion, especially in batch mode! TIA!

-- JosMaccabiani - 03 Feb 2007

Duncan, you might want to look at ExcelImportExportPlugin, where I create TWiki topics from rows in an excel spreadsheet as one of the options. If you send me or post your script I can point you what to do to create the topics...

-- ThomasWeigert - 03 Feb 2007

Peter

Thanks for the pointers, will have a look at these in the next fews days. Did I read somewhere her on TWiki.org that these scripts need to be run from the bin directory under TWiki?

Joss

I would love to contribute to twiki.org but I have the following issues with publishing the script:

  1. I have no idea how to go about it. Can you point me to instructions for submittin add-ons
  2. The script is quite specialised for our environment (referring to our own defined styles, etc.), so I don't know how useful it would be.

Having said that, if I knew how to do it I probably would.

Thomas

Will have a look at your plugin. I had actually already downloaded it but not got around to investigating it. I'd love to write a similar plugin that allowed you to include a Word Document into another topic.

-- DuncanKinnear - 09 Feb 2007

More people are asking about this kind of stuff. It would be nice to have a how-to on ScriptedTWikiContentCreation. Anybody inclined in writing this SupplementalDocumentation topic? It can be based on the info on this topic here and on the tools/mailnotify with lib/TWiki/Contrib/Mailer.pm example.

-- PeterThoeny - 16 Feb 2007

Edit | Attach | Watch | Print version | History: r15 < r14 < r13 < r12 < r11 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r15 - 2007-02-16 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.