Difference between revisions of "Talk:Wiki.pl"

From Organic Design
Jump to: navigation, search
m (Querying categories)
(Change source-code blocks to standard format)
 
Line 27: Line 27:
  
 
== Test script ==
 
== Test script ==
{{code|<perl>
+
<source lang="perl">
 
{{:WikiTest.pl}}
 
{{:WikiTest.pl}}
</perl>}}
+
</source>
  
 
== Querying categories ==
 
== Querying categories ==
Line 79: Line 79:
  
 
Output the form content and run the perl oneliner on it
 
Output the form content and run the perl oneliner on it
{{code|<PERL>
+
<source lang="PERL">
 
perl -ne '/(<input.*?name=.+?.*?value=.+?.*?>)/m && print "$1\n"' tmp.html
 
perl -ne '/(<input.*?name=.+?.*?value=.+?.*?>)/m && print "$1\n"' tmp.html
</PERL>
+
</source>
}}
 
 
Redirecting output to info.php is also useful to compare header and post request information automated  
 
Redirecting output to info.php is also useful to compare header and post request information automated  
{{code|<PHP>
+
<source lang="PHP">
 
<?php
 
<?php
 
phpinfo();
 
phpinfo();
 
?>
 
?>
</PHP>
+
</source>
}}
 
 
--[[User:Sven|Sven]] 22:07, 17 June 2008 (NZST)
 
--[[User:Sven|Sven]] 22:07, 17 June 2008 (NZST)
  

Latest revision as of 18:11, 22 May 2015


Info.svg Documentation:


Todo
  • RSS and general URL matching notworking proeprly, probably cos all going into 00:00 time... things are showing up in the cache files but not appearing in the changes. --Nad 11:55, 8 Oct 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

--Rob 14:00, 15 May 2006 (NZST)

Note: mixing of single and double quotes should be taken into account in regexes, ['"] --Sven 21:58, 13 July 2008 (NZST)

See also

Test script

{{:WikiTest.pl}}

Querying categories

The code to fetch a bullet list doesn't appear to be available in the form of a function. The query string can be used here to fetch most of the content efficiently. e.g. Using the MW:Manual:Parameters_to_index.php action=render argument in the query sting returns a small amount of structured html in the for of a bullet list. Unfortunately content from the summary itself is also present, so the last bullet list of content is most relevant for parsing.

For example http://www.organicdesign.co.nz/wiki/index.php?title=Category:Nad/Todo&action=render will output a bullet list wrapped in html.

In the Mediawiki MW:API, there is an example query to fetch category content . The maximum number of members that can be fetched is 500 for humans and 5000 for bots. This is documented within http://en.wikipedia.org/w/api.php. --Sven 16:26, 11 June 2008 (NZST)

Updating templates

Example syntax: wikiUpdateTemplate($::wiki, "Sandbox", "

  • Row: [[Row::{{{Row}}} | ]]
  • Column: [[Column::{{{Column}}} | ]]
  • Rank: 1
  • Name: 195011
  • T-statistic: [[T::{{{T}}} | {{{T}}}]]
  • P-value: [[P value:: {{{P value}}} | {{{P value}}}]]

");

e.g. Template:Record

*Gene Rank: [[Rank:: {{{Rank}}} | {{{Rank}}}]]
*Gene name: [[Name:: {{{Name}}} | {{{Name}}}]]
*log<sub>2</sub>(fold change): [[logFC:: {{{logFC}}} | {{{logFC}}} ]]
*Average expression: [[AveExpr:: {{{AveExpr}}} | {{{AveExpr}}}]]
*t-statistic: [[t::{{{t}}} | {{{t}}} ]]
*Unadjusted p-value: [[P.Value:: {{{P.Value}}} | {{{P.Value}}}]]
*Adjusted p-value: [[adj.P.Val:: {{{adj.P.Val}}} | {{{adj.P.Val}}}]]
*B statistic: [[B:: {{{B}}} | {{{B}}}]]
*Description: {{{Description|}}}
<noinclude>
See [[:Category:Test]] for examples of instances of this template
</noinclude>

<includeonly>
[[Category:Test]]
</includeonly>

Debugging

Output the form content and run the perl oneliner on it

perl -ne '/(<input.*?name=.+?.*?value=.+?.*?>)/m && print "$1\n"' tmp.html

Redirecting output to info.php is also useful to compare header and post request information automated

<?php
phpinfo();
?>

--Sven 22:07, 17 June 2008 (NZST)

wpEditToken

Looks like there was an error in my form submission which did not capture the wpEditToken inforamtion properly. For some reason this still worked with wikiDeleteArticle, so there could be a MediaWiki bug in the submission process where it does not utilize the wpEditToken field, and the database gets corrupted, but I need to investigate further. --Sven 09:35, 25 June 2008 (NZST)

HTTPS support in Perl

--Sven 11:38, 14 July 2008 (NZST)

Mediawiki 1.13.x issues

I ran Csv2wiki.pl on an instance of MediaWiki 1.13.2 and no error was provided, but no uploading occured either! I need to check out what is broken in Wiki.pl but I suspect it may be login credentials --Sven 11:40, 21 October 2008 (NZDT)

After running the Test script, the following log as obtained;
perl testArticle.pl
[Enter password]
WikiSysop successfully logged in to http://biodev3.hort.net.nz/wiki/index.php.
Attempting to edit "Sandbox" on http://biodev3.hort.net.nz/wiki/index.php
"Sandbox" updated.
Attempting to edit "Sandbox" on http://biodev3.hort.net.nz/wiki/index.php
"Sandbox" updated.
Attempting to edit "Sandbox" on http://biodev3.hort.net.nz/wiki/index.php
"Sandbox" updated.
23:41, 10 August 2008
Attempting to edit "Foo" on http://biodev3.hort.net.nz/wiki/index.php
"Foo" updated.
WikiSysop successfully deleted Foo.
WikiSysop successfully restored Foo.
WikiSysop successfully deleted Foo.
WikiSysop successfully restored Foo.
Successfully logged out of http://biodev3.hort.net.nz/wiki/index.php.

however when looking at the recent changes, only the deletion and restoration was actually logged in the wiki. This means that the logging in must have been accepted, but not article creating, appending etc.

(Deletion log); 22:36 . . WikiSysop (Talk | contribs | block) restored "Foo" (2 revisions restored: Restoring all revisions)
(Deletion log); 22:36 . . WikiSysop (Talk | contribs | block) deleted "Foo" (Test delete)
(Deletion log); 22:36 . . WikiSysop (Talk | contribs | block) restored "Foo" (1 revision restored: Restoring latest revision)
(Deletion log); 22:36 . . WikiSysop (Talk | contribs | block) deleted "Foo" (Test delete)

--Sven 11:51, 21 October 2008 (NZDT)