Difference between revisions of "Talk:Wiki.pl"

From Organic Design wiki
(still don't see any url-issue - recommend deleting all that url-related stuff)
(Version parts removed)
Line 2: Line 2:
 
=Urls=
 
=Urls=
 
'''NOTE:''' All urls should use long format and never assume "friendly urls". Long format appears to be generally consistent across all versions.
 
'''NOTE:''' All urls should use long format and never assume "friendly urls". Long format appears to be generally consistent across all versions.
:Look, I don't know what you're on about with this URL stuff, I think your making difficulty where there is none. The URL used for getting the last edit is version independent. I think we should just delete this whole URL section unless you can give me an actual example of an action that wiki.pl needs to do which can't be done with a version-independent URL. --[[User:Nad|Nad]] 17:54, 26 Jun 2006 (NZST)
 
 
 
<table class=document-code><tr><td>
 
<table class=document-code><tr><td>
 
==wikiLogin==
 
==wikiLogin==
Line 9: Line 7:
 
*index.php?title=Special:Userlogin&returnto=Main_Page       
 
*index.php?title=Special:Userlogin&returnto=Main_Page       
 
;Response:  
 
;Response:  
*1.4 - 1.5  index.php?title=Special:Userlogin&action=submitlogin&returnto=Main_Page
+
*index.php?title=Special:Userlogin&action=submitlogin<font color="red">&type=login</font>&returnto=Main_Page
*1.6 index.php?title=Special:Userlogin&action=submitlogin<font color="red">&type=login</font>&returnto=Main_Page
 
 
;Comments:  Dont need a ''returnto=[Previous Article]''
 
;Comments:  Dont need a ''returnto=[Previous Article]''
 
==wikiPageEdit==
 
==wikiPageEdit==
Line 20: Line 17:
 
;Query:
 
;Query:
 
*index.php?title=Main_Page&action=history&limit=1
 
*index.php?title=Main_Page&action=history&limit=1
** 1.4 <s>index.php/Main_Page</s> ''(most recent change)'' // don't use friendly format
 
** 1.5 - 1.6 index.php?title=Main_Page&oldid=[page id] <font color="red">Note: 1.4 doesn't seem to reference the oldid for the most recent edit</font>
 
 
==wikiRawPage==
 
==wikiRawPage==
 
;Query:
 
;Query:
Line 27: Line 22:
 
==wikiGetVersion==
 
==wikiGetVersion==
 
;Query;
 
;Query;
*index.php?title=Special:Version ''<font color="red">or</font>''
+
*index.php?title=Special:Version
*<s>index.php/Special:Version</s> // don't use friendly format
 
 
==wikiLogout==
 
==wikiLogout==
 
*index.php?title=Special:Userlogout&returnto=Main_page
 
*index.php?title=Special:Userlogout&returnto=Main_page

Revision as of 10:38, 26 June 2006

Urls

NOTE: All urls should use long format and never assume "friendly urls". Long format appears to be generally consistent across all versions.

wikiLogin

Query
  • index.php?title=Special:Userlogin&returnto=Main_Page
Response
  • index.php?title=Special:Userlogin&action=submitlogin&type=login&returnto=Main_Page
Comments
Dont need a returnto=[Previous Article]

wikiPageEdit

Query
  • index.php?title=Main_Page&action=edit
Response
  • index.php?title=Main_Page&action=submit

wikiLastEdit

Query
  • index.php?title=Main_Page&action=history&limit=1

wikiRawPage

Query
  • index.php?title=Main_Page&action=raw

wikiGetVersion

Query;
  • index.php?title=Special:Version

wikiLogout

  • index.php?title=Special:Userlogout&returnto=Main_page
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)

I don't think we should need it, I think that they're all similar enough that the regexp's should be able to be generalised to cover them all. --Nad 12:08, 26 Jun 2006 (NZST)
I will continue documenting url changes between versions partly for my own understanding and to easily create regEx's --Sven 12:54, 26 Jun 2006 (NZST)
Well differences in URL's would require a version check like you say, but they're nothing to do with the regexps, those are matching the html content, not the urls --Nad 13:26, 26 Jun 2006 (NZST)
Bugger, thats true --Sven 13:30, 26 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)