WikiLink - The Mediawiki Interface: Difference between revisions

From Knot Atlas
Jump to navigationJump to search
No edit summary
Line 83: Line 83:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{HelpLine|
{{HelpLine|
n = 7 |
n = 6 |
in = <nowiki>WikiUserName</nowiki> |
in = <nowiki>WikiUserName</nowiki> |
out= <nowiki>WikiUserName[] returns either the name of the user you are logged in as, your IP address if you're not logged in, or $Failed if something more complicated has happened!</nowiki>}}
out= <nowiki>WikiUserName[] returns either the name of the user you are logged in as, your IP address if you're not logged in, or $Failed if something more complicated has happened!</nowiki>}}
Line 90: Line 90:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{InOut|
{{InOut|
n = 8 |
n = 7 |
in = <nowiki>WikiUserName[]</nowiki> |
in = <nowiki>WikiUserName[]</nowiki> |
out= <nowiki>ScottManualRobot</nowiki>}}
out= <nowiki>ScottManualRobot</nowiki>}}
Line 101: Line 101:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{HelpLine|
{{HelpLine|
n = 9 |
n = 8 |
in = <nowiki>WikiGetPageText</nowiki> |
in = <nowiki>WikiGetPageText</nowiki> |
out= <nowiki>WikiGetPageText[pagename] returns the raw text of the specified page.</nowiki>}}
out= <nowiki>WikiGetPageText[pagename] returns the raw text of the specified page.</nowiki>}}
Line 108: Line 108:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{HelpLine|
{{HelpLine|
n = 10 |
n = 9 |
in = <nowiki>WikiSetPageText</nowiki> |
in = <nowiki>WikiSetPageText</nowiki> |
out= <nowiki>WikiSetPageText[pagename, text] overwrites the contents of the specificied page with the given text.
out= <nowiki>WikiSetPageText[pagename, text] overwrites the contents of the specificied page with the given text.
Line 116: Line 116:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{HelpLine|
{{HelpLine|
n = 11 |
n = 10 |
in = <nowiki>WikiSetPageTexts</nowiki> |
in = <nowiki>WikiSetPageTexts</nowiki> |
out= <nowiki>WikiSetPageText[{{pagename1, text1},{pagename2,text2},...}] efficiently sets multiple pages, by first checking which texts are already up to date.</nowiki>}}
out= <nowiki>WikiSetPageText[{{pagename1, text1},{pagename2,text2},...}] efficiently sets multiple pages, by first checking which texts are already up to date.</nowiki>}}
Line 123: Line 123:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{HelpLine|
{{HelpLine|
n = 12 |
n = 11 |
in = <nowiki>WikiUploadFile</nowiki> |
in = <nowiki>WikiUploadFile</nowiki> |
out= <nowiki>WikiUploadFile[name, description] uploads the specified file to the wiki.</nowiki>}}
out= <nowiki>WikiUploadFile[name, description] uploads the specified file to the wiki.</nowiki>}}
Line 132: Line 132:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{InOut|
{{InOut|
n = 13 |
n = 12 |
in = <nowiki>WikiSetPageText["Sandbox", "A robotic edit, by --[[User:Scott&#124;Scott]]"]</nowiki> |
in = <nowiki>WikiSetPageText["Sandbox", "A robotic edit, at 19:39, 31-August-2005."]</nowiki> |
out= <nowiki>True</nowiki>}}
out= <nowiki>True</nowiki>}}
<!--END-->
<!--END-->
Line 140: Line 140:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{InOut|
{{InOut|
n = 14 |
n = 13 |
in = <nowiki>WikiGetPageText["Sandbox"]</nowiki> |
in = <nowiki>WikiGetPageText["Sandbox"]</nowiki> |
out= <nowiki>A robotic edit, by --[[User:Scott&#124;Scott]]</nowiki>}}
out= <nowiki>A robotic edit, at 19:39, 31-August-2005.</nowiki>}}
<!--END-->
<!--END-->


Line 150: Line 150:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{InOut|
{{InOut|
n = 15 |
n = 14 |
in = <nowiki>WikiSetPageTexts[{{"Sandbox", "A robotic edit, by --[[User:Scott&#124;Scott]]"}, {"Sandbox2", "The determinant of the knot [[3_1]] is 3."}}]</nowiki> |
in = <nowiki>WikiSetPageTexts[{{"Sandbox", "A robotic edit, by --"<>"[[User:Scott&#124;Scott]] 15:39, 31 Aug 2005 (EDT)"}, {"Sandbox2", "The determinant of the knot [[3_1]] is 3."}}]</nowiki> |
out= <nowiki>{}</nowiki>}}
out= <nowiki>{}</nowiki>}}
<!--END-->
<!--END-->
Line 157: Line 157:
<!--Robot Land, no human edits to "END"-->
<!--Robot Land, no human edits to "END"-->
{{InOut|
{{InOut|
n = 16 |
n = 15 |
in = <nowiki>WikiGetPageText["Sandbox2"]</nowiki> |
in = <nowiki>WikiGetPageText["Sandbox2"]</nowiki> |
out= <nowiki>The determinant of the knot [[3_1]] is 3.</nowiki>}}
out= <nowiki>The determinant of the knot [[3_1]] is 3.</nowiki>}}

Revision as of 15:48, 31 August 2005


WikiLink is actually two separate things; firstly, a java class for interfacing with a mediawiki server, and secondly, a Mathematica package providing a wrapper around this. This page documents the Mathematica package, whie the java class, and its addition functionality, will be documented elsewhere.

License

WikiLink.nb, WikiLink.m and wikilink.jar are copyright Scott Morrison, available under your choice of the MIT or GPL licenses. The other components are copyright by other parties, all available under the Apache license.

Download

Download WikiLink.zip (file description). Unzip this, probably in the same place you've unzipped the KnotTheory` package. This will create a subdirectory called WikiLink, containing (at least) these files:

Filename Description
WikiLink.nb The Mathematica notebook containing wrapper function definitions.
WikiLink.m The Mathematica package automatically generated from WikiLink.nb.
wikilink.jar The WikiLink java class and source code (MediawikiConnection.java).

jdom.jar
commons-httpclient-3.0-rc2.jar
commons-codec-1.3.jar
commons-lang-2.1.jar
commons-logging.jar

Libraries (all available under either GPL or the Apache license) required by wikilink.jar

Importing the package in Mathematica

First, you'll need to set some paths, so WikiLink` can find the java files it needs.

In[1]:= KnotAtlasPath = "c:\\scott\\math.berkeley.edu\\Work\\Mathematica\\KnotAtlas\\";
In[2]:= AppendTo[$Path, KnotAtlasPath];
In[3]:= SetDirectory[KnotAtlasPath];
In[4]:= << "WikiLink\\WikiLink.m"
In[5]:= SetJarPath[KnotAtlasPath <> "WikiLink\\"];

We then try to connect to the wiki. Executing this line will prompt you for a username and password.

In[6]:= CreateWikiConnection[ "http://katlas.math.toronto.edu/w/index.php", InputString["Enter Your Username:"], InputString["Enter Your Password"] ]

The function WikiUserName[] checks that we're logged in

In[6]:= ?WikiUserName
WikiUserName[] returns either the name of the user you are logged in as, your IP address if you're not logged in, or $Failed if something more complicated has happened!
In[7]:= WikiUserName[]
Out[7]= ScottManualRobot

Usage

WikiLink` provides only a few functions.

In[8]:= ?WikiGetPageText
WikiGetPageText[pagename] returns the raw text of the specified page.
In[9]:= ?WikiSetPageText
WikiSetPageText[pagename, text] overwrites the contents of the specificied page with the given text. WikiSetPageText[pagename, text, summary] overwrites the contents of the specificied page with the given text and notes summary in the change log.
In[10]:= ?WikiSetPageTexts
WikiSetPageText[{{pagename1, text1},{pagename2,text2},...}] efficiently sets multiple pages, by first checking which texts are already up to date.
In[11]:= ?WikiUploadFile
WikiUploadFile[name, description] uploads the specified file to the wiki.

Thus for example after

In[12]:= WikiSetPageText["Sandbox", "A robotic edit, at 19:39, 31-August-2005."]
Out[12]= True

we get

In[13]:= WikiGetPageText["Sandbox"]
Out[13]= A robotic edit, at 19:39, 31-August-2005.

The function WikiSetPageTexts is most useful for batch uploads, as it does considerably more error checking, and filters out edits which won't change the page text. It takes as argument a list of {"title", "text"} pairs, and returns a list of those pairs which failed.

In[14]:= WikiSetPageTexts[{{"Sandbox", "A robotic edit, by --"<>"[[User:Scott|Scott]] 15:39, 31 Aug 2005 (EDT)"}, {"Sandbox2", "The determinant of the knot [[3_1]] is 3."}}]
Out[14]= {}
In[15]:= WikiGetPageText["Sandbox2"]
Out[15]= The determinant of the knot [[3_1]] is 3.

Troubleshooting

The instruction ShowJavaConsole[] will bring up a window in which some debugging information is displayed.

Compatibility

WikiLink has been tested against mediawiki 1.4.5beta3 and 1.4.7.