Tags:
editing2Add my vote for this tag create new tag
, view all tags
Various ways of editing Wiki pages in your editor of choice have been suggested in the pages:


What Hath Been Wrought?

There are a few bits to this:

  1. A Daemon program wikiEditDaemon.pl and it's perl object wikiEditDaemonObject.pm
  2. Two template files, implementing the non-skin minimal
  3. A script for the vim editor which communicates with the daemon.
  4. A syntax file for the vim editor which does a modest job of marking WikiSyntax (which you can get from the VimEditor page).

The daemon is capable of getting pages from the Wiki using the minimal templates and putting them in a directory for editing. When you are done editing it saves the result back to the Wiki. The VimEditor scripts integrate this into Vim.

The Fine Print (Disclaimer)

If you are going to use this the standard disclaimers apply. If this software causes you to lose or corrupt data, brings down your corporate network, gets you fired or starts a war, then that makes me sad but doesn't make me liable.

If you have improvements or suggestions, please let me know.

This is software I use every day, and it works for me. It likely has some bugs. As they say, every program has bugs, and every program can be shortened by one line... therefore every program can be reduced to a single line that doesn't work. Hopefully I'm not that badly off here.

Platforms

This software is aimed at power users and is known to work on Linux. I expect that other versions of Unix should be OK. Windows users may well be out of luck since I use Unix FIFO pipes.

I'm using this on a 01 Dec 2001 release of TWiki. I've got a current installation of Perl (5.8) but I expect anything after 5.005.3 should work. You'll need the libwww package for Perl for the LWP::UserAgent, URI and HTTP packages, and the POSIX package.

You could use the Daemon component with editors other than the VimEditor, but you would have to write a script in that editor to do so, or communicate directly with the daemon through its FIFO pipe. I also use the /proc file system to check on processes.

How to Install This

  1. Put the daemon perl scripts in a handy place. $HOME/bin is my favourite place, and is the default configured in the script itself. If you put it somewhere else, you'll need to change the path as indicated in the script .wikiVimRC.
  2. If you intend to use the daemon with the VimEditor then put the .wikiVimRC script somewhere where you can :source it, usually in your $HOME directory. Put the syntax file from the VimEditor page either in the vim syntax installation, or under $HOME/.vim/syntax so that Vim will find it.
  3. Put the templates on the TWiki installation under the twiki/templates directory. This program needs these templates to function properly.

Using the Package

If you are using Vim, all you need to do is :source .wikiVimRC to load the management functions into Vim. The following short-cut commands are provided, and work from command-mode in Vim:

  • :WDStart
    Start the daemon. If it is already running (as indicated by the presence of its input pipe and the process is there) then it won't be started again.
  • :WURL
    Supplies the daemon with the TWiki URL. When prompted, supply the URL up to and including the cgi-bin directory.
  • :WAuth
    Authenticate yourself to the TWiki. When prompted, give it your WikiName and your password.
  • :WE
    Supply the Web.PageName to be edited. When the download is done, the editor will pull the file in for editing.
  • :WS
    Saves the Web.PageName you supply on the command prompt line. This will close the window if you save from the file's own edit buffer
  • :WW
    Saves the current edit buffer back to the wiki, closing it it when it has finished.
  • :WLog
    Displays the last few lines of the edit daemon log file.

If you need to create a page, create it first through your browser. Also, use the browser mechanisms to change or add forms to the page.

Form Values

There will be a line

<!--- Do not remove this line: Form Fields can be edited below --->
in the file you edit. If form values are attached to the page, then they are supplied after this line in a simple
 name=value
format which you can then modify. Changes will be written back to the wiki.

Guts of the Thing

The daemon creates a directory, by default $HOME/.wikiEditDaemon in which it works.

  • $HOME/.wikiEditDaemon/log is the log file, and lists operations that have been performed and errors that have occurred. Old log files are stamped with the date and time when a new daemon starts, and left in the directory for reference.
  • $HOME/.wikiEditDaemon/edit is the editing directory, where the files that you have recalled are placed for editing.
  • $HOME/.wikiEditDaemon/inputPipe is the pipe to which you feed commands.

Note that all of this is only readable and writable by you. Files in the edit sub-directory are removed after editing is complete.

You can send commands directly to the daemon with an echo command, for example:

  echo quit > ~/.wikiEditDaemon/inputPipe
It understands the commands:
  • configure wikiURL followed by the URL of the Wiki, up to and including the cgi-bin directory.
  • authenticate followed by your Wiki name and password.
  • edit followed by the Web.PageName to be edited.
  • save also followed by the Web.PageName to be edited, or the keyword ALL to save all open files.
  • quit to shut down, saving all files opened with edit.
Note that you must configure the URL, then authenticate, then you can start editing.

Useful Notes, Known Problems

  • I like to put a few menu items up that call the editing functions for various often edited files (in my case, log books).
  • When I start my .vimrc that is set for certain tasks, I call the functions to start the daemon, supply a default URL, then call the authentication function.
  • It would be nice to be able to access the search routines of TWiki this way. Someday I'll have to write something, but not today.
  • There is supposed to be a read-only mode with this, done with the read command to the daemon. Unfortunately, the raw option of the view command is contaminated with HTML code in the bin/view script and the minimal template doesn't get what I expected.
  • If I was feeling really smart and enthusiastic I would use the VimEditor language interface to use the daemon more directly. I don't feel that smart today, but might later on.

-- SimonClift 12 Nov 2002



Comments & Feedback

I've posted another update, this one whacks a nasty little bug that went off at midnight.

-- SimonClift - 17 Jan 2003

BTW I mentioned your Gvim integration daemon yesterday to someone at London.pm who is developing a 'wikibot' - an IRC bot that lets IRC users update Wikis by sending messages to the bot via an IRC channel. He has a working version for UseModWiki, using LWP::Agent like your code, so there may be some scope for code re-use - see the Wikibot page for more info.

-- RichardDonkin - 22 Nov 2002

TEXTAREAS are handled with vi/vim (or your favourite $EDITOR) with the superb text mode browser 'w3m' (synop.: better than 'lynx' and perfect for mostly text TWikis with support for tables, cookies, ssl, etc.; contemporaneous to but functionally superior to 'links' other than in terms of performance IMHO).

I don't believe that 'w3m' is available under cygwin yet ('links' is and may do the job as well) so this may be a Linux/Unix only solution, but of course if one has access to a Linux server via ssh/telnet then w3m/links may be used from most any platform.

Also, I've heard mention, but not verified, that Mozilla supports external editors for textareas as well. This may be in a devel or patch but not a released version however.

-- TWikiGuest - 03 Dec 2002

Of course it does wink
I'm using it right now together with VimEditor. You need a so called Extension named mozex, which you can find at http://extensionroom.mozdev.org/ . I only tested FireFox (which works quite well), but Mozilla should work too.
Hmm, I should start a new page for this, but which Web is the right one for ExternalEditorViaMozEx ? Support? TWiki?

-- RalfDoering - 11 Jun 2004

Thanks for the link Ralf. I would probably create ExternalEditor and make a Mozilla and w3m sections within that page. In which web though? That's a tough one. I would do it here in Codev because it gets the most eyeballs. There is not much action in TWiki, that being mostly "the manual" (and nobody reads them anymore... :).

-- MattWilkie - 13 Jun 2004

This really seems like the kind of thing that should be put in vim scripts. I'm very tempted to do it to help spread the TWiki love, but I don't want to seem like I'm taking the credit for it.

-- IanTegebo - 15 Mar 2006


See also: EditorDaemonAddOnDev
Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formattmpl edit.minimal.tmpl r2 r1 manage 0.1 K 2002-11-21 - 15:36 SimonClift A "minimal" edit template.
Unknown file formattmpl view.minimal.tmpl r1 manage 0.1 K 2002-11-12 - 19:13 SimonClift A "minimal" view template... needs work.
Perl source code filepl wikiEditDaemon.pl r2 r1 manage 5.1 K 2002-11-21 - 15:37 SimonClift The Wiki Edit Daemon Perl script, main program
Perl source code filepm wikiEditDaemonObject.pm r3 r2 r1 manage 19.5 K 2003-01-17 - 16:09 SimonClift The object that does the work for the daemon.
Unknown file formatEXT wikiVimRC r2 r1 manage 5.8 K 2002-11-21 - 15:38 SimonClift Daemon commands for the VimEditor
Edit | Attach | Watch | Print version | History: r14 < r13 < r12 < r11 < r10 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r14 - 2006-03-15 - IanTegebo
 
  • 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-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.