1 ;; -*- coding: utf-8-mcs-er -*-
2 (defvar chise-wiki-view-url "view.cgi")
3 (defvar chise-wiki-edit-url "edit.cgi")
11 (defun www-xml-parse-string (string)
20 (xml-parse-region (point-min)(point-max))))))
22 (defun www-xml-to-stext-props (props)
25 (setq dest (cons (cdr cell)
26 (cons (intern (format ":%s" (car cell)))
30 (defun www-xml-to-stext-unit (unit)
31 (let (name props children)
36 (setq name (car unit))
39 (setq props (www-xml-to-stext-props (nth 1 unit))
40 children (nthcdr 2 unit))
42 (setq children (www-xml-to-stext-list children)))
43 (when (and (eq name 'link)
44 (consp (car children))
45 (eq (caar children) 'ref))
46 (setq props (list* :ref (nthcdr 2 (car children))
48 children (cdr children)))
50 (list* name props children)
56 (format "%S" unit)))))
58 (defun www-xml-to-stext-list (trees)
61 (www-xml-to-stext-unit trees)
63 ((equal trees '(("")))
66 (mapcar #'www-xml-to-stext-unit
69 (defun www-stext-parse-xml-string (string)
70 (www-xml-to-stext-list
71 (www-xml-parse-string string)))
77 (defun www-parse-string-default (string)
78 (setq string (decode-uri-string string 'utf-8-mcs-er))
81 ;; (mapcar #'read (split-string string " "))))
89 (setq ret (read-from-string string i))
90 (setq dest (cons (car ret) dest)
99 (defun www-parse-string-as-space-separated-char-list (string genre)
101 (dolist (unit (split-string string "\\+"))
102 (if (setq char (www-uri-decode-object genre unit))
103 (setq dest (cons char dest))))
106 (defun www-parse-string-as-space-separated-ids (string)
112 (if (setq char (www-uri-decode-object 'character unit))
113 (char-to-string char)
115 (split-string string "\\+")
118 (defun www-parse-string-as-ku-ten (string)
119 (if (string-match "^\\([0-9][0-9]?\\)-\\([0-9][0-9]?\\)" string)
120 (let ((ku (string-to-int (match-string 1 string)))
121 (ten (string-to-int (match-string 2 string))))
122 (if (and (<= 1 ku)(<= ku 94)
123 (<= 1 ten)(<= ten 94))
127 (defun www-parse-string-as-kangxi-radical (string)
128 (setq string (decode-uri-string string 'utf-8-mcs-er))
130 (len (length string))
132 (while (and (< i len)
133 (setq char (aref string i))
135 (and (setq ret (char-ucs char))
138 (not (setq ret (char-feature char '->radical))))
142 (and (setq ret (car ret))
143 (setq ret (char-ucs ret))
148 (defun www-parse-string-as-wiki-text (string)
149 (www-stext-parse-xml-string
150 (decode-uri-string string 'utf-8-mcs-er))
151 ;; (list (decode-uri-string string 'utf-8-mcs-er))
154 (defun www-feature-parse-string (genre feature-name string &optional format)
156 (setq format (www-feature-value-format feature-name)))
157 (cond ((eq format 'space-separated-char-list)
158 (www-parse-string-as-space-separated-char-list string genre))
159 ((eq format 'space-separated-ids)
160 (www-parse-string-as-space-separated-ids string))
162 (www-parse-string-as-ku-ten string))
163 ((eq format 'decimal)
164 (string-to-number string))
165 ((or (eq format 'HEX)(eq format 'hex))
166 (string-to-number string 16))
168 (decode-uri-string string 'utf-8-mcs-er)
170 ((eq format 'kangxi-radical)
171 (www-parse-string-as-kangxi-radical string))
172 ((eq format 'wiki-text)
173 (www-parse-string-as-wiki-text string)
176 (if (= (length string) 0)
178 (read (decode-uri-string string 'utf-8-mcs-er)))
181 (www-parse-string-default string)
188 (defun www-set-display-object-desc (genre uri-object feature value format
190 (when (stringp feature)
191 (setq feature (intern feature)))
192 (when (stringp format)
193 (setq format (intern format)))
194 (let ((object (www-uri-decode-object genre uri-object))
196 logical-feature displayed-features
200 (encode-coding-string
202 <title>EsT %s = %s</title>
205 (decode-uri-string uri-object 'utf-8-mcs-er))
208 (www-html-display-paragraph
209 (format "object: %S (%S) %S %S %S\n"
210 uri-object genre feature value lang))
211 (setq value (www-feature-parse-string genre feature value format))
212 (www-html-display-paragraph
213 (format "object = %s (%s) : %S \u2190 %S"
214 (est-format-object object) genre feature value))
216 (char-feature-name-at-domain feature '$rev=latest))
218 (if (equal (www-get-feature-value object feature) value)
219 (www-html-display-paragraph
220 "Feature-value is not changed.")
221 ;; (www-html-display-paragraph
222 ;; (format "New feature-value = %S is different from old value %S"
224 ;; (www-get-feature-value object feature)))
227 (put-char-attribute object latest-feature value)
228 (save-char-attribute-table latest-feature)
229 (setq ret (char-feature-property '$object 'additional-features))
230 (unless (memq feature ret)
231 (put-char-feature-property
232 '$object 'additional-features (cons feature ret)))
235 (concord-object-put object latest-feature value)
238 (www-html-display-paragraph
239 "New feature-value is nil, so it is ignored (may be syntax error).")
241 (www-display-object-desc genre uri-object nil lang 1)
242 ;; (princ (format "<h1>%s</h1>\n"
243 ;; (www-format-encode-string (char-to-string object))))
244 ;; (dolist (feature (char-feature-property '$object 'additional-features))
245 ;; (mount-char-attribute-table
246 ;; (char-feature-name-at-domain feature '$rev=latest)))
247 ;; (dolist (cell (sort (char-attribute-alist object)
249 ;; (char-attribute-name< (car a)(car b)))))
250 ;; (setq logical-feature
251 ;; (char-feature-name-sans-versions (car cell)))
252 ;; (unless (memq logical-feature displayed-features)
253 ;; (push logical-feature displayed-features)
256 ;; (www-format-eval-list
257 ;; (or (char-feature-property logical-feature 'format)
258 ;; '((name) " : " (value)))
259 ;; object logical-feature lang uri-object))
261 ;; (format " <a href=\"%s?char=%s&feature=%s&format=wiki-text\"
262 ;;><inpu;; t type=\"submit\" value=\"note\" /></a>"
263 ;; chise-wiki-edit-url
264 ;; (www-format-encode-string uri-object)
265 ;; (www-format-encode-string
266 ;; (www-uri-encode-feature-name
267 ;; (intern (format "%s*note" logical-feature))))))
271 ;; (format "<p><a href=\"%s?char=%s\"
272 ;;><inpu;; t type=\"submit\" value=\"add feature\" /></a></p>"
273 ;; chise-wiki-add-url
274 ;; (www-format-encode-string uri-object)))
277 (defun www-set-display-feature-desc (feature-name property-name value format
278 &optional lang uri-object)
279 (www-html-display-paragraph
281 "set: feature: %S, property-name: %S, format: %S, value: %S, lang: %S, object: %S\n"
282 feature-name property-name format value lang uri-object))
283 (setq value (www-feature-parse-string 'feature property-name value format))
284 (www-html-display-paragraph
286 "set: feature: %S, property-name: %S, format: %S, value: %S, lang: %S, object: %S\n"
287 feature-name property-name format value lang uri-object))
288 (put-char-feature-property feature-name property-name value)
289 (let ((name@lang (intern (format "name@%s" lang)))
290 (uri-feature-name (www-uri-encode-feature-name feature-name)))
292 (encode-coding-string
294 <title>CHISE-wiki feature: %s</title>
300 (encode-coding-string
301 (format "<h1>%s</h1>\n"
305 (format "<p>name : %s <a href=\"%s?feature=%s&property=name\"
306 ><input type=\"submit\" value=\"edit\" /></a></p>
308 (or (www-format-feature-name feature-name) "")
310 ;; (char-feature-property feature-name 'name)
311 uri-feature-name ; (www-uri-encode-feature-name feature-name)
315 (format "<p>%s : %s <a href=\"%s?feature=%s&property=%s\"
316 ><input type=\"submit\" value=\"edit\" /></a></p>
319 (www-format-encode-string
320 (or (char-feature-property feature-name name@lang) ""))
324 (www-html-display-paragraph
326 (or (www-feature-type feature-name)
327 ;; (char-feature-property feature-name 'type)
329 (princ (format "<p>value-format : %s "
332 (or (www-feature-value-format feature-name)
338 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&char=%s\"
339 ><input type=\"submit\" value=\"edit\" /></a></p>"
343 (www-html-display-paragraph
344 (format "description : %s"
345 (or (char-feature-property feature-name 'description)
348 (www-html-display-paragraph
349 (format "description@%s : %s"
351 (or (char-feature-property
353 (intern (format "description@%s" lang)))
356 (www-html-display-paragraph
357 (format "ă[[%c|%s?char=%s]]ăăŤ\u623Bă"
358 (www-uri-decode-object 'character uri-object)
363 (defun www-batch-set ()
364 (setq terminal-coding-system 'binary)
366 (let* ((target (pop command-line-args-left))
367 (user (pop command-line-args-left))
368 (accept-language (pop command-line-args-left))
370 (intern (car (split-string
372 (car (split-string accept-language ","))
376 (princ "Content-Type: text/html; charset=UTF-8
378 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
379 \"http://www.w3.org/TR/html4/loose.dtd\">
383 (mapcar (lambda (cell)
384 (if (string-match "=" cell)
386 (setq name (substring
387 cell 0 (match-beginning 0))
388 val (substring cell (match-end 0)))
391 (decode-uri-string name 'utf-8-mcs-er))
393 (list (decode-uri-string cell 'utf-8-mcs-er))))
394 (split-string target "&")))
395 (setq ret (car target))
396 (cond ((eq (car ret) 'char)
397 (setq prop (nth 2 target))
398 (www-set-display-object-desc
400 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
401 (intern (decode-uri-string
402 (cdr (assq 'feature-name target))
404 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
408 ((eq (car ret) 'feature)
409 (setq prop (nth 3 target))
410 (www-set-display-feature-desc
411 (intern (decode-uri-string (cdr ret) 'utf-8-mcs-er))
412 (intern (decode-uri-string
413 (cdr (assq 'feature-name (cdr target)))
415 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
418 (cdr (assq 'char target))
422 (setq prop (nth 2 target))
423 (www-set-display-object-desc
425 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
426 (intern (decode-uri-string
427 (cdr (assq 'feature-name target))
429 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
433 (www-html-display-paragraph
434 (format "%S" target))
436 (princ (format "user=%s\n" user))
437 (princ (format "local user=%s\n" (user-login-name)))
438 (princ (format "lang=%S\n" lang))
439 (princ emacs-version)
441 (princ (encode-coding-string xemacs-chise-version 'utf-8-jp-er))
447 (princ (format "%S" err)))