Difference between revisions of "Talk:Wiki.pl"
(finding wiki version with wiki.pl) |
|||
| Line 3: | Line 3: | ||
*Sync direction | *Sync direction | ||
*Wikilogin only if not logged in | *Wikilogin only if not logged in | ||
| + | ---- | ||
| + | ;Wiki version | ||
| + | Couldnt see any functions which determine the wiki version that wikid is accessing, this could be useful. --[[User:Sven|Sven]] 15:09, 7 Jun 2006 (NZST) | ||
;Modifications to work with MediaWiki 1.6.5 | ;Modifications to work with MediaWiki 1.6.5 | ||
| − | I've installed the latest MediaWiki on a site at the Uni and was using some of your automated wikiLogon, wikiEdit code. I discovered that they have changed the login form slightly and the regexp provided in this article did not work. So here is the modified line of code that I have tested and it works. I'm not sure how best to integrate this. I have a feeling the regexp could be generalised to deal with both cases. I was tripped up by the | + | I've installed the latest MediaWiki on a site at the Uni and was using some of your automated wikiLogon, wikiEdit code. I discovered that they have changed the login form slightly and the regexp provided in this article did not work. So here is the modified line of code that I have tested and it works. I'm not sure how best to integrate this. I have a feeling the regexp could be generalised to deal with both cases. I was tripped up by the forward matching style of the source HTML where the value comes before the key, but making the last bit greedy fixed it, providing the Token is the last thing in the form we want to grab. |
/^<input type='hidden' value="(.*?)" name="wpSection".+?value="(\d*?)" name="wpEdittime".+<input type='hidden' value="(.*?)" name="wpEditToken"/sm ) { | /^<input type='hidden' value="(.*?)" name="wpSection".+?value="(\d*?)" name="wpEdittime".+<input type='hidden' value="(.*?)" name="wpEditToken"/sm ) { | ||
Revision as of 03:09, 7 June 2006
- Todo
- Sync direction
- Wikilogin only if not logged in
- Wiki version
Couldnt see any functions which determine the wiki version that wikid is accessing, this could be useful. --Sven 15:09, 7 Jun 2006 (NZST)
- Modifications to work with MediaWiki 1.6.5
I've installed the latest MediaWiki on a site at the Uni and was using some of your automated wikiLogon, wikiEdit code. I discovered that they have changed the login form slightly and the regexp provided in this article did not work. So here is the modified line of code that I have tested and it works. I'm not sure how best to integrate this. I have a feeling the regexp could be generalised to deal with both cases. I was tripped up by the forward matching style of the source HTML where the value comes before the key, but making the last bit greedy fixed it, providing the Token is the last thing in the form we want to grab.
/^<input type='hidden' value="(.*?)" name="wpSection".+?value="(\d*?)" name="wpEdittime".+<input type='hidden' value="(.*?)" name="wpEditToken"/sm ) {
# Loop through all the tags and compile them into a tree
my $ptr = my $root = {};
my @path = ();
while ( $#_ >= 0 ) {
my ( $close, $name, $atts, $leaf, $text ) = ( shift, shift, shift, shift, shift );
# Create a new node in the current content and update ptr if <tag/> or <tag>
# - Includes hash of atts: /PATTERN/g returns a key,val list which can be treated as a hash
unless ($close) {
my $node = { -name => $name, $atts =~ /([-a-z0-9_:]+)\s*=\s*"(.*?)"/gi };
push @{$$ptr{-content}}, $node; # Push the node onto the current content list
push @path, $ptr; # Move current focus into the new node
$ptr = $node;
}
$ptr = pop @path if $close or $leaf; # Move ptr up one level is </tag> or <tag/>
push @{$$ptr{-content}}, $text if $text; # Add the after-node-content part to the current level
}
return $root;
}
--Rob 14:00, 15 May 2006 (NZST)



