I was thinking about generalising and componentising the mechanism behind the
MailInAddOn when I realised: I want to be able to script TWiki to perform certain actions and I want to be able to do this from:
- within an email
- from some sort of console
- within a %WCL{}% directive
This way I could get on command line to send batches of control commands from a script
(eg:
AddWeb,
AppendTextToTopic)
Thoughts?
--
MartinCleaver - 05 Jun 2002
As a fan of ASCII I was thinking in the same direction. As a result I came up with two command line scripts which enable the manipulation of topics. Handling of others features(Webs, Attachments) is missing.
I did not create a new language, you have to use these scripts from the language of your choice, e.g. shell-scripts, makefiles, tcl, perl ....
- the first script extract the data( the thing you get in the edit box ) of a topic and stores it in a file.
- the second script uses a file and stores it as a TWiki topic. Of course you should do something with the data before sending it back, like inserting at a certain place some interesting stuff
I now packed the scripts together. You can find them
here
.
--
FrankHartmann - 13 Jun 2002
Interesting approach - in essence you are scripting through the webserver by pretending to be a browser.
I was thinking of something somewhat different in implementation. I believe that it would be possible and preferable to expose functionality through a scripting engine at the back of TWiki.
This would wrap up the proposed
WebServices functionality to allow it to be scripted. The advantage of going through the
WebServices functionality is that this would, like your solution, provide the ability to run the scripts on a machine other than the server.
It would take some work, however, and would require separating
CGI aspects from the TWiki processing functionality.
--
MartinCleaver - 14 Jun 2002
Very interesting. One use could be to edit with emacs the text!!!
A suggestion: provide also an edit skin to install giving a raw view of the text, named
for instance
rawinterface, that should be included in TWiki distrib, such as:
%TEXT%
SEP
%F0RMFIELDS%
With SEP being something not found in %TEXT%, such as control chars (^A, ^B ... ^?).
Your script would then append
?skin=rawinterface to the URL.
This way:
- you do not depend of the installed skin
- parsing would be safer on your side
--
ColasNahaboo - 15 Jun 2002
I think that I have been considering something similar.
All of the TWiki commands are basically just cgi scripts that output html
to standard output.
The only reason that they are not standalone commands that can be called
from the UNIX (or Cygwin, or DOS) command line is that they depend
on the
CGI environment variables.
And because they parse the URL, as opposed to reading command line arguments.
Other wikis use command line arguments - question marks "?" in the URLs.
E.g. the original, Ward's Wiki.
If the TWiki scripts can be made to do some parsing of the command line
-- e.g. if no command line arguments, behave as now,
otherwise parse the command line
-- and if they can be similarly made to get some parameters
off the command line rather than out of the environment,
these tools would be useful as ordinary UNIX text manipulation tools.
--
AndyGlew - 24 Jun 2003
This might seem silly, but why not just write a wrapper? eg:
You type:
# twikibin view /Codev/WikiControlLanguage?raw=debug | myfilter | twikibin save /Codev/WikiControlLanguage?raw=debug
You'd need a really, really debug skin (no header/tail/textbox). I'd expect the options to go along the lines of
# twikibin --h-<header> value (script) (Topic URL)
And all
twikibin does is modify
%ENV before running the appropriate script.
Incidentally the reason (many) other wikis can do this:
>
Other wikis use command line arguments - question marks "?" in the URLs.
Is because they don't use any terms with "=" in the url after the question mark.
If an "=" is used - as in skin=, t=, raw= then Apache at least doesn't set ARGV.
Examples (tested):
-
http://127.0.0.1/cgi-bin/test.pl?junk%20junk results in @ARGV
(*) being set by apache to ("junk junk")
-
http://127.0.0.1/cgi-bin/test.pl?junk=junk results in @ARGV
(*)being set by apache to ()
- (*) OK, actually argc,argv, but that's pedantry
That said, the places where (many) other Wiki's use
? for, twiki uses
/ .
As a result some sort of wrapper is IMO probably a better route. It also means you only have one set of code to worry about and a single wrapper program. After all whilst you
might argue you don't want things skinned (what you don't want the user pages skinned as vCards?) I doubt that wanting a raw version of the text isn't desirable.
--
MichaelSparks - 24 Jun 2003
Related to this, though should be utilising the same engine, I would really like a way of defining/adding to topics whilst writing a master topic. One way to do this would be to introduce a syntax such as:
%WCL{
Here is a NewConcept {A New Concept is a .Concept {a thing to think about}} that you might not have ProperlyConsidered {Not just had in your mind for a little while}}
}%
This master topic would create or add to topics called NewConcept and Concept, just appending to them. The content saved in the master topic would be whatever is left. Assuming all topics were empty at the start, saving this would end up with the following topics contents:
- master concept
- Here is a NewConcept that you might not have ProperlyConsidered
- NewConcept
- A New Concept is a .Concept
- Concept
- a thing to think about
- ProperlyConsidered
- Not just had in your mind for a little while
NB. .Concept is a syntax introduced by
SingletonWikiWordPlugin
--
MartinCleaver - 30 Jul 2003