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-parse-string-as-wiki-text (string)
48 (list (decode-uri-string string 'utf-8-mcs-er)))
50 (defun www-feature-parse-string (feature-name string &optional format)
52 (setq format (www-feature-value-format feature-name)))
53 (cond ((eq format 'space-separated-char-list)
54 (www-parse-string-as-space-separated-char-list string))
55 ((eq format 'space-separated-ids)
56 (www-parse-string-as-space-separated-ids string))
58 (www-parse-string-as-ku-ten string))
60 (string-to-number string))
61 ((or (eq format 'HEX)(eq format 'hex))
62 (string-to-number string 16))
64 (decode-uri-string string 'utf-8-mcs-er)
66 ((eq format 'wiki-text)
67 (www-parse-string-as-wiki-text string)
70 (if (= (length string) 0)
72 (read (decode-uri-string string 'utf-8-mcs-er)))
75 (www-parse-string-default string)
78 (defun www-set-display-char-desc (uri-char feature value format &optional lang)
79 (when (stringp feature)
80 (setq feature (intern feature)))
81 (when (stringp format)
82 (setq format (intern format)))
83 (let ((char (www-uri-decode-char uri-char))
85 logical-feature displayed-features)
86 (when (characterp char)
90 <title>CHISE-wiki character: %s</title>
92 (decode-uri-string uri-char 'utf-8-mcs-er))
95 (www-html-display-paragraph
96 (format "char: %S %S %S %S\n"
97 uri-char feature value lang))
98 (setq value (www-feature-parse-string feature value format))
99 (www-html-display-paragraph
100 (format "char = %c : %S \u2190 %S"
103 (char-feature-name-at-domain feature '$rev=latest))
105 (if (equal (www-char-feature char feature) value)
106 (www-html-display-paragraph
107 "Feature-value is not changed.")
108 (www-html-display-paragraph
109 (format "New feature-value = %S is different from old value %S"
111 (www-char-feature char feature)))
112 (put-char-attribute char latest-feature value)
113 (save-char-attribute-table latest-feature)
115 (www-html-display-paragraph
116 "New feature-value is nil, so it is ignored (may be syntax error).")
118 (princ (format "<h1>%s</h1>\n"
119 (www-format-encode-string (char-to-string char))))
120 (dolist (cell (sort (char-attribute-alist char)
122 (char-attribute-name< (car a)(car b)))))
123 (setq logical-feature
124 (char-feature-name-sans-versions (car cell)))
125 (unless (memq logical-feature displayed-features)
126 (push logical-feature displayed-features)
129 (www-format-eval-list
130 (or (char-feature-property logical-feature 'format)
131 '((name) " : " (value)))
132 char logical-feature lang uri-char))
134 (format " <a href=\"%s?char=%s&feature=%s&format=wiki-text\"
135 ><input type=\"submit\" value=\"note\" /></a>"
137 (www-format-encode-string uri-char)
138 (www-format-encode-string
139 (www-uri-encode-feature-name
140 (intern (format "%s*note" logical-feature))))))
144 (format "<p><a href=\"%s?char=%s\"
145 ><input type=\"submit\" value=\"add feature\" /></a></p>"
147 (www-format-encode-string uri-char)))
150 (defun www-set-display-feature-desc (feature-name property-name value
151 &optional lang uri-char)
152 (www-html-display-paragraph
154 "set: feature: %S, property-name: %S, value: %S, lang: %S, char: %S\n"
155 feature-name property-name value lang uri-char))
156 (put-char-feature-property feature-name property-name value)
157 (let ((name@lang (intern (format "name@%s" lang)))
158 (uri-feature-name (www-uri-encode-feature-name feature-name)))
160 (encode-coding-string
162 <title>CHISE-wiki feature: %s</title>
168 (encode-coding-string
169 (format "<h1>%s</h1>\n"
173 (format "<p>name : %s <a href=\"%s?feature=%s&property=name\"
174 ><input type=\"submit\" value=\"edit\" /></a></p>
176 (or (www-format-feature-name feature-name) "")
178 ;; (char-feature-property feature-name 'name)
179 uri-feature-name ; (www-uri-encode-feature-name feature-name)
183 (format "<p>%s : %s <a href=\"%s?feature=%s&property=%s\"
184 ><input type=\"submit\" value=\"edit\" /></a></p>
187 (www-format-encode-string
188 (or (char-feature-property feature-name name@lang) ""))
192 (www-html-display-paragraph
194 (or (www-feature-type feature-name)
195 ;; (char-feature-property feature-name 'type)
197 (www-html-display-paragraph
198 (format "description : %s"
199 (or (char-feature-property feature-name 'description)
202 (www-html-display-paragraph
203 (format "description@%s : %s"
205 (or (char-feature-property
207 (intern (format "description@%s" lang)))
210 (www-html-display-paragraph
211 (format "ă[[%c|../view.cgi?char=%s]]ăăŤ\u623Bă"
212 (www-uri-decode-char uri-char) uri-char))
215 (defun www-batch-set ()
216 (setq terminal-coding-system 'binary)
218 (let* ((target (pop command-line-args-left))
219 (user (pop command-line-args-left))
220 (accept-language (pop command-line-args-left))
222 (intern (car (split-string
224 (car (split-string accept-language ","))
228 (princ "Content-Type: text/html; charset=UTF-8
230 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
231 \"http://www.w3.org/TR/html4/loose.dtd\">
235 (mapcar (lambda (cell)
236 (if (string-match "=" cell)
238 (setq name (substring
239 cell 0 (match-beginning 0))
240 val (substring cell (match-end 0)))
243 (decode-uri-string name 'utf-8-mcs-er))
245 (list (decode-uri-string cell 'utf-8-mcs-er))))
246 (split-string target "&")))
247 (setq ret (car target))
248 (cond ((eq (car ret) 'char)
249 (setq prop (nth 2 target))
250 (www-set-display-char-desc
251 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
252 (intern (decode-uri-string
253 (cdr (assq 'feature-name target))
255 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
259 ((eq (car ret) 'feature)
260 (setq prop (nth 2 target))
261 (www-set-display-feature-desc
262 (intern (decode-uri-string (cdr ret) 'utf-8-mcs-er))
264 (decode-uri-string (cdr prop) 'utf-8-mcs-er)
266 (cdr (assq 'char target))
267 ;; (decode-uri-string (cdr (assq 'char target)))
270 (www-html-display-paragraph
271 (format "%S" target))
273 (princ (format "user=%s\n" user))
274 (princ (format "local user=%s\n" (user-login-name)))
275 (princ (format "lang=%S\n" lang))
276 (princ emacs-version)
278 (princ xemacs-chise-version)
284 (princ (format "%S" err)))