Ævar Arnfjörð Bjarmason wrote:
On Mon, 21 Mar 2005 21:23:28 +0000, Jim Higson
<jh(a)333.org> wrote:
Jim Higson wrote:
Tomer Chachamu wrote:
On Mon, 21 Mar 2005 15:07:50 +0000, Jim Higson
<jh(a)333.org> wrote:
> I'm trying to programatically submit edits to my wiki via a http
> post, using XMLHTTP. However, I am unable to 'persuade' the server to
> accept them. The server always responds as if I'm asking for a
> preview.
>
> Either:
> * I'm not making the upload requests correctly
> * There is a server side security model that forbids this
> * I'm going mad :)
>
> You can see the form-data I'm sending by going here:
>
>
http://81.5.150.113/wysi/Very_small_test?debug=yes&action=edit
> then change the wikitext and click save, the request and response
> body will be shown on the right (which I use as a debugging area)
>
> Any help would be really appreciated, this is a real show-stopper for
> my project.
Are you loading the edit page first and taking the wpEditToken? You
need it. (It's used for various things, including detection of edit
conflicts.)
I wasn't aware of such a thing - this is obviously the problem.
Is is possible to request a token from the server without it generating
a page? (since the page will never be displayed) Or any another way
that a thick(er) client can submit edits.
I could just request an edit page in the background to get the token,
but doing so would defeat the object of a low-bandwidth, low-cpu wiki.
As an aside, what do people here think of this project? Personally I
see a lot of potential in this kind of 'half-thick' interface - the
very quick feedback when editing should make contributing a lot easier
for those starting to learn the wiki syntax.
Having thought it some more, I'm pretty sure the only way this can be
solved is to add recognition for &action=getedittoken to mediawiki. This
would return a tiny http response with just the token as text/plain. When
the server gets the token back, it would send back an "ok" or
"collision"- this is editing equivalent of action=raw.
This would be useful for anyone who is trying to write a thick interface
to mediawiki, or any other kind of alternate edit tool.
Does this sound like an acceptable addition?
Maybe I'm missing something (wouldn't be the first time) but couldn't
you just parse the page for the edittoken? It's pretty easy, for
example this Perl code which takes the scalar $editpage containing
page retrevied with action=edit would return the token as a variable:
(my $wpEditToken) = $editpage =~
m#(?<=<input).*([\w\d]{32}).*(?=wpEditToken)#g;
The problem here is I'm trying to build a low bandwidth interface. If the
edit token is 32 bytes it seems a terrible waste to have to download 40k or
more of HTML to get at it!
If you goto
http://81.5.150.113/wysi - it looks pretty much like the normal
wikimedia, but NONE of the html you see was generated on the server. It's
difficult to get this across sometimes because to the user it looks just
the same.
The other issue is creating pages that are never shown is a huge waste of
server-side CPU time. My interface uses only static content on the
presentation tier. Potentially an Apache machine could serve an order of
magnitude more pages using this project.
Jim