1 (in-package :cl-mediawiki
)
3 (defun check-edit-response (title xml
)
4 "Checks for the expected 'success' message
5 signals match-errors assertion-errors and media-wiki-errors
7 (match-response-with-error-reporting
11 #T
(list &rest ?alist
)))
13 (assert (string-equal "success" (attribute-value "result" alist
))
14 (alist) "Failed to create page: '~a' ~a ~a ~%~%~A" title
(attribute-value "result" alist
) (string-equal "success "(attribute-value "result" alist
)) alist
)
21 (summary "cl-mediawiki:create-page")
23 "Creates a new wiki page
24 If override is true, replace the existing page with the text passed in
26 (let* ((tokens (get-action-tokens title
))
30 (token ,(edit-token tokens
))
32 (basetimestamp ,(timestamp tokens
))
40 (parse-api-response-to-sxml (make-api-request parameters
:method
:post
))))
44 (defun add-new-page-section (title section-title section-text
&key no-create
)
45 "Creates a new == section-title == at the bottom of the page. followed by the specified text"
46 (let* ((tokens (get-action-tokens title
))
50 (token ,(edit-token tokens
))
53 (summary ,section-title
)
54 (basetimestamp ,(timestamp tokens
))
57 (text ,section-text
)))
61 (parse-api-response-to-sxml
62 (make-api-request parameters
:method
:post
)))
65 (defun append-text-to-page
68 (summary "cl-mediawiki:append-text-to-page"))
69 "appends the text the the end of the page (will create the page if neccessary)"
70 (let* ((tokens (get-action-tokens title
))
74 (token ,(edit-token tokens
))
77 (basetimestamp ,(timestamp tokens
))
84 (parse-api-response-to-sxml
85 (make-api-request parameters
:method
:post
)))
88 (defun prepend-text-to-page
90 (summary "cl-mediawiki:prepend-text-to-page")
92 "Adds the text to the beginning of the page
93 (will create the page if neccessary unless no-create is true)"
94 (let* ((tokens (get-action-tokens title
))
98 (token ,(edit-token tokens
))
101 (basetimestamp ,(timestamp tokens
))
104 (prependtext ,text
)))
108 (parse-api-response-to-sxml
109 (make-api-request parameters
:method
:post
)))
112 (defun set-page-content
113 (title text
&key no-create
114 (summary "cl-mediawiki:set-page-content"))
115 "sets the text of a wiki page to the specified text"
116 (let* ((tokens (get-action-tokens title
))
120 (token ,(edit-token tokens
))
123 (basetimestamp ,(timestamp tokens
))
130 (parse-api-response-to-sxml
131 (make-api-request parameters
:method
:post
)))