This is the cl-mediawiki Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:08:59 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
cl-mediawiki
A tool to help talk to mediawiki’s api.
cxml
(system).
drakma
(system).
alexandria
(system).
src
(module).
Modules are listed depth-first from the system components tree.
cl-mediawiki/src
cl-mediawiki
(system).
packages.lisp
(file).
util.lisp
(file).
main.lisp
(file).
query.lisp
(file).
edit.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
cl-mediawiki/cl-mediawiki.asd
cl-mediawiki/src/packages.lisp
cl-mediawiki/src/util.lisp
cl-mediawiki/src/main.lisp
cl-mediawiki/src/query.lisp
cl-mediawiki/src/edit.lisp
cl-mediawiki/cl-mediawiki.asd
cl-mediawiki
(system).
cl-mediawiki/src/util.lisp
packages.lisp
(file).
src
(module).
ensure-list
(function).
find-nodes-by-name
(function).
find-tree
(function).
map-sxml-tree
(function).
symbolize-string
(function).
cl-mediawiki/src/main.lisp
util.lisp
(file).
src
(module).
*default-external-format*
(special variable).
*mediawiki*
(special variable).
mediawiki
(class).
print-object
(method).
with-mediawiki
(macro).
auth
(reader method).
(setf auth)
(writer method).
check-sxml-for-error
(function).
code
(reader method).
(setf code)
(writer method).
convert-sxml-attribs-to-alist
(function).
cookie-jar
(reader method).
(setf cookie-jar)
(writer method).
ensure-mediawiki
(function).
make-api-request
(function).
make-parameters
(function).
media-wiki-error
(condition).
message
(reader method).
(setf message)
(writer method).
obj
(reader method).
(setf obj)
(writer method).
parse-api-response-to-sxml
(function).
sxml-attribute-value
(function).
url
(reader method).
(setf url)
(writer method).
cl-mediawiki/src/query.lisp
main.lisp
(file).
src
(module).
find-page-section
(function).
get-action-tokens
(function).
get-image-info
(function).
get-links
(function).
get-more-results
(method).
get-page-content
(function).
get-page-info
(function).
get-revisions
(function).
get-revisions-result
(function).
has-more-results-p
(method).
list-all-pages
(function).
list-all-users
(function).
list-page-sections
(function).
login
(function).
pages-that-embed
(function).
print-object
(method).
query-result
(class).
recent-changes
(function).
results
(reader method).
(setf results)
(writer method).
site-info
(function).
user-contribs
(function).
%login
(function).
%parse-text-sections
(function).
+default-query-params+
(special variable).
appendf
(macro).
define-proxy
(macro).
delete-token
(method).
edit-token
(method).
get-more-results-once
(method).
get-page-content-by-revid
(function).
get-revisions-and-closure
(function).
list-category-members
(function).
move-token
(method).
page-attributes
(reader method).
(setf page-attributes)
(writer method).
timestamp
(reader method).
(setf timestamp)
(writer method).
token-bag
(class).
tokens
(reader method).
(setf tokens)
(writer method).
cl-mediawiki/src/edit.lisp
query.lisp
(file).
src
(module).
add-new-page-section
(function).
append-text-to-page
(function).
create-page
(function).
prepend-text-to-page
(function).
regex-replace-all
(function).
set-page-content
(function).
set-section-content
(function).
upload
(function).
check-api-response
(function).
check-edit-response
(function).
Packages are listed by definition order.
net.acceleration.cl-mediawiki
This package provides a client to the mediawiki API, which is used
by Wikipedia among others.
Exported functions fairly closely mirror the command structure of the
API, which is summarized here: http://en.wikipedia.org/w/api.php
Usage example:
;; setup to use only Wikipedia
CL-USER> (setf cl-mediawiki:*mediawiki*
(cl-mediawiki:with-mediawiki ("http://en.wikipedia.org/w")
cl-mediawiki:*mediawiki*))
;; get content of article titled Pigment
CL-USER> (cl-mediawiki:get-page-content "Pigment")
;; get the revids and sizes of its last 10 revisions
CL-USER> (cl-mediawiki:get-revisions "Pigment" :rvprop "ids|user|size" :rvlimit 10)
Further documentation is in README.mediawiki.
cl-mediawiki
common-lisp
.
*default-external-format*
(special variable).
*mediawiki*
(special variable).
add-new-page-section
(function).
append-text-to-page
(function).
create-page
(function).
find-page-section
(function).
get-action-tokens
(function).
get-image-info
(function).
get-links
(function).
get-more-results
(generic function).
get-page-content
(function).
get-page-info
(function).
get-revisions
(function).
get-revisions-result
(function).
has-more-results-p
(generic function).
list-all-pages
(function).
list-all-users
(function).
list-page-sections
(function).
login
(function).
mediawiki
(class).
pages-that-embed
(function).
prepend-text-to-page
(function).
query-result
(class).
recent-changes
(function).
regex-replace-all
(function).
results
(generic reader).
(setf results)
(generic writer).
set-page-content
(function).
set-section-content
(function).
site-info
(function).
upload
(function).
user-contribs
(function).
with-mediawiki
(macro).
%login
(function).
%parse-text-sections
(function).
+default-query-params+
(special variable).
appendf
(macro).
auth
(generic reader).
(setf auth)
(generic writer).
check-api-response
(function).
check-edit-response
(function).
check-sxml-for-error
(function).
code
(generic reader).
(setf code)
(generic writer).
convert-sxml-attribs-to-alist
(function).
cookie-jar
(generic reader).
(setf cookie-jar)
(generic writer).
define-proxy
(macro).
delete-token
(generic function).
edit-token
(generic function).
ensure-list
(function).
ensure-mediawiki
(function).
find-nodes-by-name
(function).
find-tree
(function).
get-more-results-once
(generic function).
get-page-content-by-revid
(function).
get-revisions-and-closure
(function).
list-category-members
(function).
make-api-request
(function).
make-parameters
(function).
map-sxml-tree
(function).
media-wiki-error
(condition).
message
(generic reader).
(setf message)
(generic writer).
move-token
(generic function).
obj
(generic reader).
(setf obj)
(generic writer).
page-attributes
(generic reader).
(setf page-attributes)
(generic writer).
parse-api-response-to-sxml
(function).
sxml-attribute-value
(function).
symbolize-string
(function).
timestamp
(generic reader).
(setf timestamp)
(generic writer).
token-bag
(class).
tokens
(generic reader).
(setf tokens)
(generic writer).
url
(generic reader).
(setf url)
(generic writer).
Definitions are sorted by export status, category, package, and then by lexicographic order.
sets as the drakma default coding system
the current instance of media wiki we are dealing with (mostly for use with with-mediawiki)
Creates a new == section-title == at the bottom of the page. followed by the specified text
appends the text the the end of the page (will create the page if neccessary, unless no-create is passed)
Creates a new wiki page
If override is true, replace the existing page with the text passed in (if the page already exists)
searches the the given page for the given section name. returns nil or (number name anchor rvsection)
Gets the tokens necessary for perform edits.
Parameters:
titles - the title of the page we wish to edit
intoken - which tokens do we want (out of :edit :move :delete :block :unblock or a list of those)
Examples: (get-action-tokens "Physics")
(get-action-tokens "Physics" :intoken ’(:edit :move :delete))
(get-action-tokens ’("Main Page" "User:Russ") :intoken ’(:move :edit :delete :protect))
Returns: a token bag (or list of them if you asked for multiple pages)
Gets the info for a given image (or file) as an alist
Parameters:
titles - the title of the image we wish to retrieve the info of
iiprop - Which properties to get
Possible values (separate with ’|’): timestamp, user, comment, url,
size, sha1, mime, metadata, archivename. Default is all.
iilimit - How many image revisions to return (1 by default)
iistart - Timestamp to start listing from. Use this to continue a previous
query.
iiend - Timestamp to stop listing at
iiurlwidth - If iiprop=url is set, a URL to an image scaled to this width will
be returned as well. Old versions of images can’t be scaled
iiurlheight - Similar to iiurlwidth
Example: (get-image-info "Image:Albert Einstein Head.jpg" :iiprop "user|comment")
Returns: a list of alists of attributes about the requested revisions of the image, and a continuation if there is one.
Gets a list of all links on the provided pages.
Parameters:
titles - the title of the page we wish to retrieve the info of
pllimit - How many links to return. Default: 10. No more than 500 (5000 for bots) allowed.
plcontinue - When more results are available, use this to continue.
plnamespace - Only list links to pages in these namespaces.
(For example, set plnamespace to 0 to get only article links in Wikipedia.)
Examples:
; gets 10 results
(get-links "Pigment" :pllimit 10)
; gets 10 results, then gets 10 more using a continuation token
(multiple-value-bind (firstresults continuation-token)
(get-links "Pigment" :pllimit 10)
(let ((secondresults (get-links "Pigment" :pllimit 10 :plcontinue continuation-token)))
(list firstresults secondresults)))
Get the content for a given page.
Does not accept revid. To get the content of older pages, use
get-revisions with the rvprop content tag.
Parameters:
titles - the title of the page
rvsection - only retrieve the content of this section
(a number indicating which section, not the section name)
Examples: (get-page-content "Physics")
Returns: a string with the given page content
Gets the info for a given page as an alist
Parameters:
titles - the title of the page we wish to retrieve the info of
Returns: an alist of attributes about the page
Gets the revisions of a page.
Parameters:
titles - the title of the page we wish to retrieve the info of
rvprop: - Which properties to get for each revision
Possible values (separate with ’|’): ids, flags, timestamp,
user, comment, size, content. Default is all except content.
rvcontinue: - When more results are available, use this to continue
(This is different from the returned continuation.)
rvlimit: - The maximum number of revisions to return (enum)
rvstartid: - Revision ID to start listing from. (enum)
rvendid: - Revision ID to stop listing at. (enum)
rvstart: - Timestamp to start listing from. (enum)
rvend: - Timestamp to end listing at. (enum)
rvdir: - Direction to list in. (enum)
Possible values: older, newer.
Default: older
rvuser: - Only list revisions made by this user
rvexcludeuser: - Do not list revisions made by this user
rvdiffto: - Revision ID to diff each revision to.
Possible values (an id, "prev", "next" or "cur").
Examples: (get-revisions "Pigment" :rvprop "ids|user|size" :rvlimit 10)
(get-revisions "Physics" :rvlimit 10)
Returns: list of revisions as alists and (if there is one) a continuation, which is the rvstart id to pass in the next call to get more results.
Like get-revisions, but returns a query-result object
List all pages.
Parameters:
aplimit - The maximum number of contributions to return.
No more than 500 (5000 for bots) allowed.
Default: 10
apfrom - Start listing at this title. The title need not exist
List all users.
Parameters:
aulimit - The maximum number of contributions to return.
No more than 500 (5000 for bots) allowed.
Default: 10
aufrom - Start listing at this user.
lists sections in a page, returns list of (number name anchor rvsection)
rvsection is suitable to for the :rvsection param of get-page-content
List pages that embed a given template or other page
Parameters:
eititle - Title to search. If null, titles= parameter will be used instead, but will be obsolete soon.
eicontinue - When more results are available, use this to continue.
einamespace - The namespace to enumerate.
Values (separate with ’|’): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 102, 103
eifilterredir - How to filter for redirects
One value: all, redirects, nonredirects
Default: all
eilimit - How many total pages to return.
No more than 500 (5000 for bots) allowed.
Default: 10
Examples: (pages-that-embed "Template:Client")
Returns: a list of pagetitles and a continuation (if there is one)
Adds the text to the beginning of the page named title
(will create the page if neccessary unless no-create is true)
Enumerates the recent changes
Parameters:
rcstart - The timestamp to start enumerating from.
rcend - The timestamp to end enumerating.
rcdir - In which direction to enumerate.
One value: newer, older
Default: older
rcnamespace - Filter log entries to only this namespace(s)
Values (separate with ’|’): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 102, 103
rctitles - Filter log entries to only these page titles
rcprop - Include additional pieces of information
Values (separate with ’|’): user, comment, flags, timestamp, title, ids, sizes, redirect, patrolled
Default: title|timestamp|ids
rcshow - Show only items that meet this criteria.
For example, to see only minor edits done by logged-in users, set show=minor|!anon
Values (separate with ’|’): minor, !minor, bot, !bot, anon, !anon, redirect, !redirect, patrolled, !patrolled
rclimit - How many total changes to return.
No more than 500 (5000 for bots) allowed.
Default: 10
rctype - Which types of changes to show.
Values (separate with ’|’): edit, new, log
Returns:
Does a regex find/replace on the target page. If the page is empty, will set to default content if provided Works by calling get-content then regex-replacing on the content, then calling set-content
sets the text of a wiki page ’title’ to the specified ’text’,
title: The wiki page to set the content of
text: The new content that the wiki page should have
no-create:, do not create the wiki page if it does not exist
summary: The comment associated with changing the page content
Sets the text of section ’rvsection’ on page ’title’ to ’text’. ’text’ MUST contain the section title markup!
Returns overall site information. Parameters: none
uploads a file from a local path.
returns 2 values:
1. string for the filename according to mediawiki (eg: Foo.png)
2. string for the wikimarkup to link to the file (eg: [[File:Foo.png]])
Get all edits by a user
Parameters:
uclimit - The maximum number of contributions to return.
No more than 500 (5000 for bots) allowed.
Default: 10
ucstart - The start timestamp to return from.
ucend - The end timestamp to return to.
ucuser - The user to retrieve contributions for.
ucuserprefix - Retrieve contibutions for all users whose names begin with this value. Overrides ucuser.
ucdir - The direction to search (older or newer).
One value: newer, older
Default: older
ucnamespace - Only list contributions in these namespaces
Values (separate with ’|’): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 102, 103
ucprop - Include additional pieces of information
Values (separate with ’|’): ids, title, timestamp, comment, flags
Default: ids|title|timestamp|flags|comment
ucshow - Show only items that meet this criteria, e.g. non minor edits only: show=!minor
Values (separate with ’|’): minor, !minor
query-result
) &key at-least pause) ¶Fetches AT-LEAST more results, re-querying every PAUSE seconds if necessary.
If AT-LEAST is nil, repeats until it gets all results.
Updates the query-result object with these new results.
Returns the object, and the number of new items fetched.
query-result
)) ¶Returns nil, or the closure used for a single follow-up query
query-result
)) ¶automatically generated reader method
query-result
)) ¶automatically generated writer method
media-wiki-error
) stream) ¶Accumulating result to a get-revisions-result query.
Use has-more-results-p to check if there are more results available. Use get-more-results to get them through one or more queries.
The parameters that are available for any action=query api call
Modify-macro for APPEND. Appends LISTS to the place designated by the first argument.
Defines a function with NAME with REQ required parameters. The symbols in the BASED-ON and PROPS lists are concatenated with pairs from the CORE list and passed to the MAKE-PARAMETERS function.
This module is used to login and get the authentication tokens. In the event of a successful log-in, a cookie will be attached to your session. In the event of a failed log-in, you will not be able to attempt another log-in through this method for 5 seconds. This is to prevent password guessing by automated password crackers.
This module only accepts POST requests.
Parameters:
lgname - User Name
lgpassword - Password
lgdomain - Domain (optional)
lgtoken - Login token obtained in first request
Example:
api.php?action=login&lgname=user&lgpassword=password
parses the given text and lists sections in that content. returns list of (number name anchor rvsection)
Checks for the expected ’success’ message in the node matching the
name parameter
signals match-errors assertion-errors and media-wiki-errors, printing
datum in error messages.
returns values:
1. the xml response
2. the alist of node attributes for the node we checked for success
Checks for the expected ’success’ message
signals match-errors assertion-errors and media-wiki-errors,
printing datum in error messages.
search the response for <api><error attribs></api>
just ensure that you have alist
find all sxml nodes with a given name
find a tree based on a predicate
Get the content for a given revid
Parameters:
revids - the revision id of the page
rvsection - only retrieve the content of this section
(a number indicating which section, not the section name)
Examples: (get-page-content 446445813)
Returns: a string with the given page content
Like get-revisions, but also returns a closure for a follow-up query.
This closure can be called outside of a with-mediawiki form.
Example:
(multiple-value-list (with-mediawiki ("http://en.wikipedia.org/w")
(get-revisions-and-closure "Pigment" :rvlimit 3)))
(multiple-value-list (funcall (elt * 2)))
(multiple-value-list (funcall (elt * 2)))
etc..
List all pages in a given category.
Parameters:
cmtitle - Which category to enumerate (required). Must include Category: prefix
cmprop - What pieces of information to include
Values (separate with ’|’): ids, title, sortkey, timestamp
Default: ids|title
cmnamespace - Only include pages in these namespaces
Values (separate with ’|’): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101
cmcontinue - For large categories, give the value retured from previous query
cmlimit - The maximum number of pages to return.
No more than 500 (5000 for bots) allowed.
Default: 10
cmsort - Property to sort by. One value: sortkey, timestamp,Default: sortkey
cmdir - In which direction to sort. One value: asc, desc Default: asc
cmstart - Timestamp to start listing from. Can only be used with cmsort=timestamp
cmend - Timestamp to end listing at. Can only be used with cmsort=timestamp
cmstartsortkey - Sortkey to start listing from. Can only be used with cmsort=sortkey
cmendsortkey - Sortkey to end listing at. Can only be used with cmsort=sortkey
Examples:
Get first 10 pages in [[Category:Physics]]:
(list-category-members "Category:Physics")
Get page info about first 10 pages in [[Category:Physics]]:
(list-category-members "Category:Physics" :prop ’info)
Returns a list of alists, each representing a CategoryMember
alist keys are: :title :ns :pageid
Calls the media wiki api providing the specified parameters
Takes a list of bindings (:key :val) and prepares them for transit
by converting them to strings
(if either the pair is nil or the value is nil, we drop that param)
Do a depth first traversal of some set of trees calling fn on every non-nil element.
Turns a string into a happy symbol
ex: ”foo bar_bast” -> FOO-BAR-BAST
media-wiki-error
)) ¶media-wiki-error
)) ¶query-result
)) ¶Fetches more results with one follow-up query.
Updates the query-result object with these new results. Returns the object, and the number of new items fetched.
media-wiki-error
)) ¶media-wiki-error
)) ¶media-wiki-error
)) ¶media-wiki-error
)) ¶An alist of page attributes returned by the api
:page-attributes
:timestamp
either a single token, or an
alist mapping type to value
:tokens
Jump to: | %
(
A C D E F G H L M O P R S T U W |
---|
Jump to: | %
(
A C D E F G H L M O P R S T U W |
---|
Jump to: | *
+
A C M O P R S T U |
---|
Jump to: | *
+
A C M O P R S T U |
---|
Jump to: | C E F M N P Q S T U |
---|
Jump to: | C E F M N P Q S T U |
---|