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)
12 (defun www-xml-parse-string (string)
21 (xml-parse-region (point-min)(point-max))))))
23 (defun www-xml-to-stext-props (props)
26 (setq dest (cons (cdr cell)
27 (cons (intern (format ":%s" (car cell)))
31 (defun www-xml-to-stext-unit (unit)
32 (let (name props children)
37 (setq name (car unit))
40 (setq props (nth 1 unit)
41 children (nthcdr 2 unit))
43 (setq children (www-xml-to-stext-list children)))
46 (www-xml-to-stext-props props)
49 (list name (www-xml-to-stext-props props))
53 (format "%S" unit)))))
55 (defun www-xml-to-stext-list (trees)
58 (www-xml-to-stext-unit trees)
60 ((equal trees '(("")))
63 (mapcar #'www-xml-to-stext-unit
66 (defun www-stext-parse-xml-string (string)
67 (www-xml-to-stext-list
68 (www-xml-parse-string string)))
74 (defun www-parse-string-default (string)
75 (setq string (decode-uri-string string 'utf-8-mcs-er))
78 (mapcar #'read (split-string string " "))))
84 (defun www-parse-string-as-space-separated-char-list (string)
86 (dolist (unit (split-string string "\\+"))
87 (if (setq char (www-uri-decode-char unit))
88 (setq dest (cons char dest))))
91 (defun www-parse-string-as-space-separated-ids (string)
97 (if (setq char (www-uri-decode-char unit))
100 (split-string string "\\+")
103 (defun www-parse-string-as-ku-ten (string)
104 (if (string-match "^\\([0-9][0-9]?\\)-\\([0-9][0-9]?\\)" string)
105 (let ((ku (string-to-int (match-string 1 string)))
106 (ten (string-to-int (match-string 2 string))))
107 (if (and (<= 1 ku)(<= ku 94)
108 (<= 1 ten)(<= ten 94))
112 (defun www-parse-string-as-wiki-text (string)
113 (www-stext-parse-xml-string
114 (decode-uri-string string 'utf-8-mcs-er))
115 ;; (list (decode-uri-string string 'utf-8-mcs-er))
118 (defun www-feature-parse-string (feature-name string &optional format)
120 (setq format (www-feature-value-format feature-name)))
121 (cond ((eq format 'space-separated-char-list)
122 (www-parse-string-as-space-separated-char-list string))
123 ((eq format 'space-separated-ids)
124 (www-parse-string-as-space-separated-ids string))
126 (www-parse-string-as-ku-ten string))
127 ((eq format 'decimal)
128 (string-to-number string))
129 ((or (eq format 'HEX)(eq format 'hex))
130 (string-to-number string 16))
132 (decode-uri-string string 'utf-8-mcs-er)
134 ((eq format 'wiki-text)
135 (www-parse-string-as-wiki-text string)
138 (if (= (length string) 0)
140 (read (decode-uri-string string 'utf-8-mcs-er)))
143 (www-parse-string-default string)
150 (defun www-set-display-char-desc (uri-char feature value format &optional lang)
151 (when (stringp feature)
152 (setq feature (intern feature)))
153 (when (stringp format)
154 (setq format (intern format)))
155 (let ((char (www-uri-decode-char uri-char))
157 logical-feature displayed-features
159 (when (characterp char)
161 (encode-coding-string
163 <title>CHISE-wiki character: %s</title>
165 (decode-uri-string uri-char 'utf-8-mcs-er))
168 (www-html-display-paragraph
169 (format "char: %S %S %S %S\n"
170 uri-char feature value lang))
171 (setq value (www-feature-parse-string feature value format))
172 (www-html-display-paragraph
173 (format "char = %c : %S \u2190 %S"
176 (char-feature-name-at-domain feature '$rev=latest))
178 (if (equal (www-char-feature char feature) value)
179 (www-html-display-paragraph
180 "Feature-value is not changed.")
181 ;; (www-html-display-paragraph
182 ;; (format "New feature-value = %S is different from old value %S"
184 ;; (www-char-feature char feature)))
185 (put-char-attribute char latest-feature value)
186 (save-char-attribute-table latest-feature)
187 (setq ret (char-feature-property '$object 'additional-features))
188 (unless (memq feature ret)
189 (put-char-feature-property
190 '$object 'additional-features (cons feature ret)))
192 (www-html-display-paragraph
193 "New feature-value is nil, so it is ignored (may be syntax error).")
195 (princ (format "<h1>%s</h1>\n"
196 (www-format-encode-string (char-to-string char))))
197 (dolist (feature (char-feature-property '$object 'additional-features))
198 (mount-char-attribute-table
199 (char-feature-name-at-domain feature '$rev=latest)))
200 (dolist (cell (sort (char-attribute-alist char)
202 (char-attribute-name< (car a)(car b)))))
203 (setq logical-feature
204 (char-feature-name-sans-versions (car cell)))
205 (unless (memq logical-feature displayed-features)
206 (push logical-feature displayed-features)
209 (www-format-eval-list
210 (or (char-feature-property logical-feature 'format)
211 '((name) " : " (value)))
212 char logical-feature lang uri-char))
214 (format " <a href=\"%s?char=%s&feature=%s&format=wiki-text\"
215 ><input type=\"submit\" value=\"note\" /></a>"
217 (www-format-encode-string uri-char)
218 (www-format-encode-string
219 (www-uri-encode-feature-name
220 (intern (format "%s*note" logical-feature))))))
224 (format "<p><a href=\"%s?char=%s\"
225 ><input type=\"submit\" value=\"add feature\" /></a></p>"
227 (www-format-encode-string uri-char)))
230 (defun www-set-display-feature-desc (feature-name property-name value
231 &optional lang uri-char)
232 (www-html-display-paragraph
234 "set: feature: %S, property-name: %S, value: %S, lang: %S, char: %S\n"
235 feature-name property-name value lang uri-char))
236 (put-char-feature-property feature-name property-name value)
237 (let ((name@lang (intern (format "name@%s" lang)))
238 (uri-feature-name (www-uri-encode-feature-name feature-name)))
240 (encode-coding-string
242 <title>CHISE-wiki feature: %s</title>
248 (encode-coding-string
249 (format "<h1>%s</h1>\n"
253 (format "<p>name : %s <a href=\"%s?feature=%s&property=name\"
254 ><input type=\"submit\" value=\"edit\" /></a></p>
256 (or (www-format-feature-name feature-name) "")
258 ;; (char-feature-property feature-name 'name)
259 uri-feature-name ; (www-uri-encode-feature-name feature-name)
263 (format "<p>%s : %s <a href=\"%s?feature=%s&property=%s\"
264 ><input type=\"submit\" value=\"edit\" /></a></p>
267 (www-format-encode-string
268 (or (char-feature-property feature-name name@lang) ""))
272 (www-html-display-paragraph
274 (or (www-feature-type feature-name)
275 ;; (char-feature-property feature-name 'type)
277 (www-html-display-paragraph
278 (format "description : %s"
279 (or (char-feature-property feature-name 'description)
282 (www-html-display-paragraph
283 (format "description@%s : %s"
285 (or (char-feature-property
287 (intern (format "description@%s" lang)))
290 (www-html-display-paragraph
291 (format "ă[[%c|../view.cgi?char=%s]]ăăŤ\u623Bă"
292 (www-uri-decode-char uri-char) uri-char))
295 (defun www-batch-set ()
296 (setq terminal-coding-system 'binary)
298 (let* ((target (pop command-line-args-left))
299 (user (pop command-line-args-left))
300 (accept-language (pop command-line-args-left))
302 (intern (car (split-string
304 (car (split-string accept-language ","))
308 (princ "Content-Type: text/html; charset=UTF-8
310 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
311 \"http://www.w3.org/TR/html4/loose.dtd\">
315 (mapcar (lambda (cell)
316 (if (string-match "=" cell)
318 (setq name (substring
319 cell 0 (match-beginning 0))
320 val (substring cell (match-end 0)))
323 (decode-uri-string name 'utf-8-mcs-er))
325 (list (decode-uri-string cell 'utf-8-mcs-er))))
326 (split-string target "&")))
327 (setq ret (car target))
328 (cond ((eq (car ret) 'char)
329 (setq prop (nth 2 target))
330 (www-set-display-char-desc
331 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
332 (intern (decode-uri-string
333 (cdr (assq 'feature-name target))
335 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
339 ((eq (car ret) 'feature)
340 (setq prop (nth 2 target))
341 (www-set-display-feature-desc
342 (intern (decode-uri-string (cdr ret) 'utf-8-mcs-er))
344 (decode-uri-string (cdr prop) 'utf-8-mcs-er)
346 (cdr (assq 'char target))
347 ;; (decode-uri-string (cdr (assq 'char target)))
350 (www-html-display-paragraph
351 (format "%S" target))
353 (princ (format "user=%s\n" user))
354 (princ (format "local user=%s\n" (user-login-name)))
355 (princ (format "lang=%S\n" lang))
356 (princ emacs-version)
358 (princ xemacs-chise-version)
364 (princ (format "%S" err)))