1 ;; -*- coding: utf-8-mcs-er -*-
2 (defvar chise-wiki-view-url "../view.cgi")
3 (defvar chise-wiki-edit-url "edit.cgi")
5 (require 'cwiki-common)
9 (defun www-parse-string-default (string)
10 (setq string (decode-uri-string string 'utf-8-mcs-er))
13 (mapcar #'read (split-string string " "))))
19 (defun www-parse-string-as-space-separated-char-list (string)
21 (dolist (unit (split-string string "\\+"))
22 (if (setq char (www-uri-decode-char unit))
23 (setq dest (cons char dest))))
26 (defun www-parse-string-as-space-separated-ids (string)
32 (if (setq char (www-uri-decode-char unit))
35 (split-string string "\\+")
38 (defun www-parse-string-as-ku-ten (string)
39 (if (string-match "^\\([0-9][0-9]?\\)-\\([0-9][0-9]?\\)" string)
40 (let ((ku (string-to-int (match-string 1 string)))
41 (ten (string-to-int (match-string 2 string))))
42 (if (and (<= 1 ku)(<= ku 94)
43 (<= 1 ten)(<= ten 94))
47 (defun www-feature-parse-string (feature-name string &optional format)
49 (setq format (www-feature-value-format feature-name)))
50 (cond ((eq format 'space-separated-char-list)
51 (www-parse-string-as-space-separated-char-list string))
52 ((eq format 'space-separated-ids)
53 (www-parse-string-as-space-separated-ids string))
55 (www-parse-string-as-ku-ten string))
57 (string-to-number string))
58 ((or (eq format 'HEX)(eq format 'hex))
59 (string-to-number string 16))
61 (decode-uri-string string 'utf-8-mcs-er)
64 (if (= (length string) 0)
66 (read (decode-uri-string string 'utf-8-mcs-er)))
69 (www-parse-string-default string)
72 (defun www-set-display-char-desc (uri-char feature value format &optional lang)
73 (when (stringp feature)
74 (setq feature (intern feature)))
75 (when (stringp format)
76 (setq format (intern format)))
77 (let ((char (www-uri-decode-char uri-char)))
78 (when (characterp char)
82 <title>CHISE-wiki character: %s</title>
84 (decode-uri-string uri-char 'utf-8-mcs-er))
87 (www-html-display-paragraph
88 (format "char: %S %S %S %S\n"
89 uri-char feature value lang))
90 (setq value (www-feature-parse-string feature value format))
91 (www-html-display-paragraph
92 (format "char = %c" char))
93 (www-html-display-paragraph
94 (format "feature-name = %S" feature))
95 (www-html-display-paragraph
96 (format "feature-value = %S" value))
97 (princ (format "<h1>%s</h1>\n"
98 (www-format-encode-string (char-to-string char))))
99 (dolist (cell (sort (char-attribute-alist char)
101 (char-attribute-name< (car a)(car b)))))
104 (www-format-eval-list
105 (or (char-feature-property (car cell) 'format)
106 '((name) " : " (value)))
107 char (car cell) lang uri-char))
109 (format " <a href=\"%s?char=%s&feature=%s\"
110 ><input type=\"submit\" value=\"note\" /></a>"
112 (www-format-encode-string uri-char)
113 (www-format-encode-string
114 (www-uri-encode-feature-name
115 (intern (format "%s*note" (car cell)))))))
119 (format "<p><a href=\"%s?char=%s\"
120 ><input type=\"submit\" value=\"add feature\" /></a></p>"
122 (www-format-encode-string uri-char)))
125 (defun www-set-display-feature-desc (feature-name property-name value
126 &optional lang uri-char)
127 (www-html-display-paragraph
129 "set: feature: %S, property-name: %S, value: %S, lang: %S, char: %S\n"
130 feature-name property-name value lang uri-char))
131 (put-char-feature-property feature-name property-name value)
132 (let ((name@lang (intern (format "name@%s" lang)))
133 (uri-feature-name (www-uri-encode-feature-name feature-name)))
135 (encode-coding-string
137 <title>CHISE-wiki feature: %s</title>
143 (encode-coding-string
144 (format "<h1>%s</h1>\n"
148 (format "<p>name : %s <a href=\"%s?feature=%s&property=name\"
149 ><input type=\"submit\" value=\"edit\" /></a></p>
151 (or (www-format-feature-name feature-name) "")
153 ;; (char-feature-property feature-name 'name)
154 uri-feature-name ; (www-uri-encode-feature-name feature-name)
158 (format "<p>%s : %s <a href=\"%s?feature=%s&property=%s\"
159 ><input type=\"submit\" value=\"edit\" /></a></p>
162 (www-format-encode-string
163 (or (char-feature-property feature-name name@lang) ""))
167 (www-html-display-paragraph
169 (or (www-feature-type feature-name)
170 ;; (char-feature-property feature-name 'type)
172 (www-html-display-paragraph
173 (format "description : %s"
174 (or (char-feature-property feature-name 'description)
177 (www-html-display-paragraph
178 (format "description@%s : %s"
180 (or (char-feature-property
182 (intern (format "description@%s" lang)))
185 (www-html-display-paragraph
186 (format "ă[[%c|../view.cgi?char=%s]]ăăŤ\u623Bă"
187 (www-uri-decode-char uri-char) uri-char))
190 (defun www-batch-set ()
191 (setq terminal-coding-system 'binary)
193 (let* ((target (pop command-line-args-left))
194 (user (pop command-line-args-left))
195 (accept-language (pop command-line-args-left))
197 (intern (car (split-string
199 (car (split-string accept-language ","))
203 (princ "Content-Type: text/html; charset=UTF-8
205 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
206 \"http://www.w3.org/TR/html4/loose.dtd\">
210 (mapcar (lambda (cell)
211 (if (string-match "=" cell)
213 (setq name (substring
214 cell 0 (match-beginning 0))
215 val (substring cell (match-end 0)))
218 (decode-uri-string name 'utf-8-mcs-er))
220 (list (decode-uri-string cell 'utf-8-mcs-er))))
221 (split-string target "&")))
222 (setq ret (car target))
223 (cond ((eq (car ret) 'char)
224 (setq prop (nth 2 target))
225 (www-set-display-char-desc
226 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
227 (intern (decode-uri-string
228 (cdr (assq 'feature-name target))
230 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
234 ((eq (car ret) 'feature)
235 (setq prop (nth 2 target))
236 (www-set-display-feature-desc
237 (intern (decode-uri-string (cdr ret) 'utf-8-mcs-er))
239 (decode-uri-string (cdr prop) 'utf-8-mcs-er)
241 (cdr (assq 'char target))
242 ;; (decode-uri-string (cdr (assq 'char target)))
245 (www-html-display-paragraph
246 (format "%S" target))
248 (princ (format "user=%s\n" user))
249 (princ (format "local user=%s\n" (user-login-name)))
250 (princ (format "lang=%S\n" lang))
251 (princ emacs-version)
253 (princ xemacs-chise-version)
259 (princ (format "%S" err)))