This question about Topic Markup Language and applications: Answered

Programmatically altering topic/web content

Hi all

I am interested in programmatically altering the content of pages in Foswiki. I have not installed Foswiki before, but satisfying this requirement is critical if Foswiki is going to be adopted at my organisation.

Specifically, some wiki content will be generated as part of a build process and I want to be able to use an API call to update associated Foswiki pages. It would be great if the main sections of these particular pages could be made read-only and if users could still comment about the generated content in a separate section at the end.

I have never used Perl so would prefer a solution which uses something language neutral such as web services so I can crank out HTTP requests using Java (the generation will be the result of an Ant build).

An answer to a TWiki support request mentioned the option of storing pages as plain text. Is this possible and a good idea in this particular case? Other sections of the wiki installation will contain user-written content which we would like to have a revision history of.

Thanks very much for your help

-- FrankCopperfield - 03 Mar 2009

An answer to a TWiki support request mentioned the option of storing pages as plain text.

I'm not sure what you mean, since the pages are already stored as plain text. You can use the Wiki's scripts to create the content (with an HTTP request), or your program just needs to put a file in the right directory and add a simple header (see the first two lines of the raw=debug version of this topic for an example). If it's written directly to the file system, there is no revision history of course until you edit the page.

There are various ways to have the main page read-only but allow for user comments.There are some plug-ins that could help, but I'm not sure of their migration status (hopefully someone else will chip in on that). But following the KISS principle: your program could embed the AccessControl setting ALLOWTOPICCHANGE = an admin group only, for example (and hide that line from view in an HTML comment). Then the user comments would be on a separate child page (similar to TalkPageConcept / TalkPageConceptTalk, or the plugin "Dev" topics at twiki.org), with read/write access (and of course, revision history).

-- SeanMorgan - 04 Mar 2009

Sean's idea is the most sensible to combine restricted content with an INCLUDE of another topic that has open permissions.

As for automation - you can always call save on a topic to either generate or update it. See for instance Extensions support (raw view) that contains a search to display "create" links if a support topic does not exist.

Additionaly you may use AttachContentPlugin to store information in attachments.

-- ArthurClemens - 04 Mar 2009

As an example of posting data directly to a page using the save script:

http://yourfoswiki/bin/save?topic=Web.TopicName;text=the+content+you're+posting+to+the+wiki

(or even better, send them as POST params rather than GET)

-- SvenDowideit - 04 Mar 2009

I just read through the answers above an would have said the same, so marking this as answered.

-- CrawfordCurrie - 10 Mar 2009

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version
Status Answered
Topic revision: r5 - 10 Mar 2009, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy