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
87 (when (characterp char)
91 <title>CHISE-wiki character: %s</title>
93 (decode-uri-string uri-char 'utf-8-mcs-er))
96 (www-html-display-paragraph
97 (format "char: %S %S %S %S\n"
98 uri-char feature value lang))
99 (setq value (www-feature-parse-string feature value format))
100 (www-html-display-paragraph
101 (format "char = %c : %S \u2190 %S"
104 (char-feature-name-at-domain feature '$rev=latest))
106 (if (equal (www-char-feature char feature) value)
107 (www-html-display-paragraph
108 "Feature-value is not changed.")
109 (www-html-display-paragraph
110 (format "New feature-value = %S is different from old value %S"
112 (www-char-feature char feature)))
113 (put-char-attribute char latest-feature value)
114 (save-char-attribute-table latest-feature)
115 (setq ret (char-feature-property '$object 'additional-features))
116 (unless (memq feature ret)
117 (put-char-feature-property
118 '$object 'additional-features (cons feature ret)))
120 (www-html-display-paragraph
121 "New feature-value is nil, so it is ignored (may be syntax error).")
123 (princ (format "<h1>%s</h1>\n"
124 (www-format-encode-string (char-to-string char))))
125 (dolist (feature (char-feature-property '$object 'additional-features))
126 (mount-char-attribute-table
127 (char-feature-name-at-domain feature '$rev=latest)))
128 (dolist (cell (sort (char-attribute-alist char)
130 (char-attribute-name< (car a)(car b)))))
131 (setq logical-feature
132 (char-feature-name-sans-versions (car cell)))
133 (unless (memq logical-feature displayed-features)
134 (push logical-feature displayed-features)
137 (www-format-eval-list
138 (or (char-feature-property logical-feature 'format)
139 '((name) " : " (value)))
140 char logical-feature lang uri-char))
142 (format " <a href=\"%s?char=%s&feature=%s&format=wiki-text\"
143 ><input type=\"submit\" value=\"note\" /></a>"
145 (www-format-encode-string uri-char)
146 (www-format-encode-string
147 (www-uri-encode-feature-name
148 (intern (format "%s*note" logical-feature))))))
152 (format "<p><a href=\"%s?char=%s\"
153 ><input type=\"submit\" value=\"add feature\" /></a></p>"
155 (www-format-encode-string uri-char)))
158 (defun www-set-display-feature-desc (feature-name property-name value
159 &optional lang uri-char)
160 (www-html-display-paragraph
162 "set: feature: %S, property-name: %S, value: %S, lang: %S, char: %S\n"
163 feature-name property-name value lang uri-char))
164 (put-char-feature-property feature-name property-name value)
165 (let ((name@lang (intern (format "name@%s" lang)))
166 (uri-feature-name (www-uri-encode-feature-name feature-name)))
168 (encode-coding-string
170 <title>CHISE-wiki feature: %s</title>
176 (encode-coding-string
177 (format "<h1>%s</h1>\n"
181 (format "<p>name : %s <a href=\"%s?feature=%s&property=name\"
182 ><input type=\"submit\" value=\"edit\" /></a></p>
184 (or (www-format-feature-name feature-name) "")
186 ;; (char-feature-property feature-name 'name)
187 uri-feature-name ; (www-uri-encode-feature-name feature-name)
191 (format "<p>%s : %s <a href=\"%s?feature=%s&property=%s\"
192 ><input type=\"submit\" value=\"edit\" /></a></p>
195 (www-format-encode-string
196 (or (char-feature-property feature-name name@lang) ""))
200 (www-html-display-paragraph
202 (or (www-feature-type feature-name)
203 ;; (char-feature-property feature-name 'type)
205 (www-html-display-paragraph
206 (format "description : %s"
207 (or (char-feature-property feature-name 'description)
210 (www-html-display-paragraph
211 (format "description@%s : %s"
213 (or (char-feature-property
215 (intern (format "description@%s" lang)))
218 (www-html-display-paragraph
219 (format "ă[[%c|../view.cgi?char=%s]]ăăŤ\u623Bă"
220 (www-uri-decode-char uri-char) uri-char))
223 (defun www-batch-set ()
224 (setq terminal-coding-system 'binary)
226 (let* ((target (pop command-line-args-left))
227 (user (pop command-line-args-left))
228 (accept-language (pop command-line-args-left))
230 (intern (car (split-string
232 (car (split-string accept-language ","))
236 (princ "Content-Type: text/html; charset=UTF-8
238 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
239 \"http://www.w3.org/TR/html4/loose.dtd\">
243 (mapcar (lambda (cell)
244 (if (string-match "=" cell)
246 (setq name (substring
247 cell 0 (match-beginning 0))
248 val (substring cell (match-end 0)))
251 (decode-uri-string name 'utf-8-mcs-er))
253 (list (decode-uri-string cell 'utf-8-mcs-er))))
254 (split-string target "&")))
255 (setq ret (car target))
256 (cond ((eq (car ret) 'char)
257 (setq prop (nth 2 target))
258 (www-set-display-char-desc
259 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
260 (intern (decode-uri-string
261 (cdr (assq 'feature-name target))
263 (cdr prop) ; (decode-uri-string (cdr prop) 'utf-8-mcs-er)
267 ((eq (car ret) 'feature)
268 (setq prop (nth 2 target))
269 (www-set-display-feature-desc
270 (intern (decode-uri-string (cdr ret) 'utf-8-mcs-er))
272 (decode-uri-string (cdr prop) 'utf-8-mcs-er)
274 (cdr (assq 'char target))
275 ;; (decode-uri-string (cdr (assq 'char target)))
278 (www-html-display-paragraph
279 (format "%S" target))
281 (princ (format "user=%s\n" user))
282 (princ (format "local user=%s\n" (user-login-name)))
283 (princ (format "lang=%S\n" lang))
284 (princ emacs-version)
286 (princ xemacs-chise-version)
292 (princ (format "%S" err)))