1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-format)
4 (defvar chise-wiki-view-url "view.cgi")
5 (defvar chise-wiki-edit-url "edit.cgi")
6 (defvar chise-wiki-add-url "add.cgi")
8 (defun www-edit-display-feature-input-box (char feature-name
9 &optional format value)
11 (setq format 'default))
13 (setq value (www-get-feature-value char feature-name)))
15 (format "<p><input type=\"text\" name=\"feature-name\"
16 size=\"32\" maxlength=\"256\" value=\"%s\">"
18 (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
20 (format "%s<input type=\"text\" name=\"%s\"
21 size=\"64\" maxlength=\"256\" value=\"%s\">
22 <input type=\"submit\" value=\"set\" /></p>
24 (if (or (eq format 'HEX)(eq format 'hex))
28 (mapconcat (lambda (c)
30 ;; ((eq c ?<) "&lt;")
31 ;; ((eq c ?>) "&gt;")
32 ((eq c ?\u0022) """)
35 (www-format-value char feature-name
36 value format 'without-tags)
40 (defun www-display-object-desc (genre uri-object &optional lang level simple
41 uri-feature-name-to-edit editing-format)
44 (let ((object (www-uri-decode-object genre uri-object))
46 base-name-to-edit metadata-name-to-edit
48 logical-feature chise-wiki-displayed-features
50 GlyphWiki-id ret object-spec)
54 (setq without-header t))
56 (when uri-feature-name-to-edit
57 (setq feature-name-to-edit
58 (www-uri-decode-feature-name uri-feature-name-to-edit))
59 (setq ret (symbol-name feature-name-to-edit))
60 (if (string-match "\\*" ret)
61 (setq base-name-to-edit (intern
62 (substring ret 0 (match-beginning 0)))
63 metadata-name-to-edit (intern
64 (substring ret (match-end 0))))
65 (setq base-name-to-edit feature-name-to-edit))
66 (when (stringp editing-format)
67 (setq editing-format (intern editing-format))))
68 (when (and (eq genre 'character)
69 (= (length uri-object) 1))
70 (setq uri-object (www-uri-encode-object object)))
75 <title>EsT %s = %s</title>
78 (decode-uri-string uri-object 'utf-8-mcs-er))
81 (when (eq genre 'character)
82 (dolist (feature (char-feature-property '$object 'additional-features))
83 (mount-char-attribute-table
84 (char-feature-name-at-domain feature '$rev=latest))))
88 "<div style=\"text-align:right;\">
89 <a href=\"edit/view.cgi?%s=%s\">
90 <input type=\"submit\" value=\"Edit\" />
92 <input type=\"submit\" value=\"New Account\" />
95 "<div style=\"text-align:right;\">
96 <a href=\"../view.cgi?%s=%s\">
97 <input type=\"submit\" value=\"Simple\" />
103 (when (setq parents (www-get-feature-value object '<-denotational))
104 (princ (format "<p>%s %s</p>\n<hr>\n"
105 (www-format-value-as-char-list parents)
106 (www-format-feature-name '->denotational lang))))
107 (when (setq parents (www-get-feature-value object '<-subsumptive))
108 (princ (format "<p>%s %s</p>\n<hr>\n"
109 (www-format-value-as-char-list parents)
110 (www-format-feature-name '->subsumptive lang))))
111 (when (eq genre 'character)
112 (setq GlyphWiki-id (char-GlyphWiki-id object)))
113 (princ (format "<h%d>%s%s</h%d>\n"
115 (www-format-encode-string
116 (est-format-object object)
117 ;; (if (eq genre 'character)
118 ;; (char-to-string object)
119 ;; (format "%s" (concord-object-id object)))
123 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
125 GlyphWiki-id GlyphWiki-id)
130 (when feature-name-to-edit
131 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
133 (encode-coding-string
134 (format "<p>(%s : <input type=\"text\" name=\"%s\"
135 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
138 (decode-uri-string uri-object 'utf-8-mcs-er))
141 (if (eq genre 'character)
142 (char-attribute-alist object)
143 (concord-object-spec object)))
144 (when feature-name-to-edit
145 (unless (assq base-name-to-edit object-spec)
146 (setq object-spec (cons (cons base-name-to-edit nil)
148 (dolist (cell (sort object-spec
150 (char-attribute-name<
151 (char-feature-name-sans-versions (car a))
152 (char-feature-name-sans-versions (car b))))))
153 (setq logical-feature (char-feature-name-sans-versions (car cell)))
154 (unless (memq logical-feature chise-wiki-displayed-features)
155 (push logical-feature chise-wiki-displayed-features)
157 ((and feature-name-to-edit
158 (eq (car cell) feature-name-to-edit))
159 (www-edit-display-feature-input-box
160 object feature-name-to-edit editing-format)
165 "<div class=\"feature\" style=\"line-height:150%\">\n"
168 (www-format-eval-list
169 (www-feature-format logical-feature)
171 logical-feature ; (car cell)
176 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
177 ><input type=\"submit\" value=\"note\" /></a>"
180 (www-format-encode-string uri-object)
181 (www-format-encode-string
182 (www-uri-encode-feature-name
183 (intern (format "%s*note"
184 logical-feature ; (car cell)
186 (when (and feature-name-to-edit
187 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
190 (www-edit-display-feature-input-box
191 object feature-name-to-edit editing-format)
204 (when feature-name-to-edit
208 (format "<a href=\"%s?%s=%s\"
209 ><input type=\"submit\" value=\"add feature\" /></a>
213 (www-format-encode-string uri-object))))
218 (when (eq genre 'character)
220 "<form action=\"http://www.chise.org/ids-find\">\n")
222 (www-format-encode-string
223 (est-format-object object)
224 ;; (if (eq genre 'character)
225 ;; (format "%c" object)
226 ;; (format "%s" (concord-object-id object)))
230 " <input type=\"text\" name=\"components\"
231 size=\"30\" maxlength=\"30\" value=\"%s\" />"
232 (encode-coding-string
233 (est-format-object object)
234 ;; (if (eq genre 'character)
235 ;; (char-to-string object)
236 ;; (format "%s" (concord-object-id object)))
239 (www-format-encode-string
240 "ă\u542Bă\u6F22\u5B57ă\u63A2ă"))
241 (princ " <input type=\"submit\" value=\"search\" />\n")
249 (defun www-display-feature-desc (uri-feature-name genre uri-object
250 &optional lang simple)
251 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
252 (name@lang (intern (format "name@%s" lang))))
254 (encode-coding-string
256 <title>EsT feature: %s</title>
264 "<div style=\"text-align:right;\">
265 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
266 <input type=\"submit\" value=\"Edit\" />
268 <input type=\"submit\" value=\"New Account\" />
271 "<div style=\"text-align:right;\">
272 <a href=\"../view.cgi?feature=%s&%s=%s\">
273 <input type=\"submit\" value=\"Simple\" />
277 uri-feature-name genre uri-object))
279 (format "<h1>%s</h1>\n"
280 (www-format-encode-string
281 (symbol-name feature-name))))
282 (princ (format "<p>name : %s "
283 (or (www-format-feature-name feature-name) "")))
287 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
292 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
297 (www-format-encode-string
300 (or (char-feature-property feature-name name@lang) ""))))
304 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
310 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
312 (www-html-display-paragraph
314 (or (www-feature-type feature-name)
315 ;; (char-feature-property feature-name 'type)
317 (princ (format "<p>value-format : %s "
320 (or (www-feature-value-format feature-name)
327 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
333 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
336 (princ "<p>format : ")
337 (www-html-display-text
338 (decode-coding-string
340 (www-feature-format feature-name))
345 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
351 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
354 (www-html-display-paragraph
355 (format "description : %s"
356 (or (char-feature-property feature-name 'description)
359 (www-html-display-paragraph
360 (format "description@%s : %s"
362 (or (char-feature-property
364 (intern (format "description@%s" lang)))
368 (defun www-batch-view ()
369 (setq terminal-coding-system 'binary)
371 (let* ((target (pop command-line-args-left))
372 (user (pop command-line-args-left))
373 (accept-language (pop command-line-args-left))
374 (mode (intern (pop command-line-args-left)))
379 (car (split-string accept-language ","))
383 (princ "Content-Type: text/html; charset=UTF-8
385 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
386 \"http://www.w3.org/TR/html4/loose.dtd\">
391 (when (string-match "^char=\\(&[^&;]+;\\)" target)
392 (setq ret (match-end 0))
395 (www-uri-encode-object
396 (www-uri-decode-object
397 'character (match-string 1 target)))
398 (substring target ret))))
400 (mapcar (lambda (cell)
401 (if (string-match "=" cell)
405 (substring cell 0 (match-beginning 0))
407 (substring cell (match-end 0)))
408 (list (decode-uri-string cell 'utf-8-mcs-er))))
409 (split-string target "&")))
410 (setq ret (car target))
411 (cond ((eq (car ret) 'char)
412 (www-display-object-desc
418 ((eq (car ret) 'feature)
419 (www-display-feature-desc
420 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
427 (www-display-object-desc
435 (princ (format "mode=%S\n" mode))
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 (encode-coding-string (emacs-version) 'utf-8-jp-er))
441 ;; (princ xemacs-chise-version)
447 (princ (format "%S" err)))
450 (provide 'cwiki-view)