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 char (or (concord-decode-object '=id char 'feature)
12 (concord-make-object 'feature char))))
14 (setq format 'default))
16 (setq value (www-get-feature-value char feature-name)))
17 (if (and (symbolp value)
18 (eq format 'wiki-text))
19 (setq value (list (list value))))
21 (format "<p><input type=\"text\" name=\"feature-name\"
22 size=\"32\" maxlength=\"256\" value=\"%s\">"
24 (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
26 (format "%s<input type=\"text\" name=\"%s\"
27 size=\"64\" maxlength=\"256\" value=\"%s\">
28 <input type=\"submit\" value=\"set\" /></p>
30 (if (or (eq format 'HEX)(eq format 'hex))
34 (mapconcat (lambda (c)
36 ;; ((eq c ?<) "&lt;")
37 ;; ((eq c ?>) "&gt;")
38 ((eq c ?\u0022) """)
41 (est-format-list value format nil nil " ")
45 (defun www-display-object-desc (genre uri-object &optional lang level simple
46 uri-feature-name-to-edit editing-format)
49 (let ((object (www-uri-decode-object genre uri-object))
51 base-name-to-edit metadata-name-to-edit
53 logical-feature chise-wiki-displayed-features
55 GlyphWiki-id ret object-spec)
59 (setq without-header t))
61 (when uri-feature-name-to-edit
62 (setq feature-name-to-edit
63 (www-uri-decode-feature-name uri-feature-name-to-edit))
64 (setq ret (symbol-name feature-name-to-edit))
65 (if (string-match "\\*" ret)
66 (setq base-name-to-edit (intern
67 (substring ret 0 (match-beginning 0)))
68 metadata-name-to-edit (intern
69 (substring ret (match-end 0))))
70 (setq base-name-to-edit feature-name-to-edit))
71 (when (stringp editing-format)
72 (setq editing-format (intern editing-format))))
73 (when (and (eq genre 'character)
74 (= (length uri-object) 1))
75 (setq uri-object (www-uri-encode-object object)))
80 <title>EsT %s = %s</title>
83 (decode-uri-string uri-object 'utf-8-mcs-er))
86 (when (eq genre 'character)
87 (dolist (feature (char-feature-property '$object 'additional-features))
88 (mount-char-attribute-table
89 (char-feature-name-at-domain feature '$rev=latest))))
93 "<div style=\"text-align:right;\">
94 <a href=\"edit/view.cgi?%s=%s\">
95 <input type=\"submit\" value=\"Edit\" />
97 <input type=\"submit\" value=\"New Account\" />
100 "<div style=\"text-align:right;\">
101 <a href=\"../view.cgi?%s=%s\">
102 <input type=\"submit\" value=\"Simple\" />
108 (when (setq parents (www-get-feature-value object '<-denotational))
109 (princ (format "<p>%s %s</p>\n<hr>\n"
110 (www-format-value-as-char-list parents)
111 (www-format-feature-name '->denotational lang))))
112 (when (setq parents (www-get-feature-value object '<-subsumptive))
113 (princ (format "<p>%s %s</p>\n<hr>\n"
114 (www-format-value-as-char-list parents)
115 (www-format-feature-name '->subsumptive lang))))
116 (when (eq genre 'character)
117 (setq GlyphWiki-id (char-GlyphWiki-id object)))
118 (princ (format "<h%d>%s%s</h%d>\n"
120 (www-format-encode-string
121 (est-format-object object 'readable))
124 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
126 GlyphWiki-id GlyphWiki-id)
131 (when feature-name-to-edit
132 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
134 (encode-coding-string
135 (format "<p>(%s : <input type=\"text\" name=\"%s\"
136 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
139 (decode-uri-string uri-object 'utf-8-mcs-er))
142 (if (eq genre 'character)
143 (char-attribute-alist object)
144 (concord-object-spec object)))
145 (when feature-name-to-edit
146 (unless (assq base-name-to-edit object-spec)
147 (setq object-spec (cons (cons base-name-to-edit nil)
149 (dolist (cell (sort object-spec
151 (char-attribute-name<
152 (char-feature-name-sans-versions (car a))
153 (char-feature-name-sans-versions (car b))))))
154 (setq logical-feature (char-feature-name-sans-versions (car cell)))
155 (unless (memq logical-feature chise-wiki-displayed-features)
156 (push logical-feature chise-wiki-displayed-features)
158 ((and feature-name-to-edit
159 (eq (car cell) feature-name-to-edit))
160 (www-edit-display-feature-input-box
161 object feature-name-to-edit editing-format)
166 "<div class=\"feature\" style=\"line-height:150%\">\n"
169 (www-format-eval-list
170 (www-feature-format logical-feature)
172 logical-feature ; (car cell)
177 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
178 ><input type=\"submit\" value=\"note\" /></a>"
181 (www-format-encode-string uri-object)
182 (www-format-encode-string
183 (www-uri-encode-feature-name
184 (intern (format "%s*note"
185 logical-feature ; (car cell)
187 (when (and feature-name-to-edit
188 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
191 (www-edit-display-feature-input-box
192 object feature-name-to-edit editing-format)
205 (when feature-name-to-edit
209 (format "<a href=\"%s?%s=%s\"
210 ><input type=\"submit\" value=\"add feature\" /></a>
214 (www-format-encode-string uri-object))))
219 (when (eq genre 'character)
221 "<form action=\"http://www.chise.org/ids-find\">\n")
223 (www-format-encode-string
224 (est-format-object object)
225 ;; (if (eq genre 'character)
226 ;; (format "%c" object)
227 ;; (format "%s" (concord-object-id object)))
231 " <input type=\"text\" name=\"components\"
232 size=\"30\" maxlength=\"30\" value=\"%s\" />"
233 (encode-coding-string
234 (est-format-object object)
235 ;; (if (eq genre 'character)
236 ;; (char-to-string object)
237 ;; (format "%s" (concord-object-id object)))
240 (www-format-encode-string
241 "ă\u542Bă\u6F22\u5B57ă\u63A2ă"))
242 (princ " <input type=\"submit\" value=\"search\" />\n")
250 (defun www-display-feature-desc (uri-feature-name genre uri-object
251 &optional lang simple)
252 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
253 (name@lang (intern (format "name@%s" lang))))
255 (encode-coding-string
257 <title>EsT feature: %s</title>
265 "<div style=\"text-align:right;\">
266 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
267 <input type=\"submit\" value=\"Edit\" />
269 <input type=\"submit\" value=\"New Account\" />
272 "<div style=\"text-align:right;\">
273 <a href=\"../view.cgi?feature=%s&%s=%s\">
274 <input type=\"submit\" value=\"Simple\" />
278 uri-feature-name genre uri-object))
280 (format "<h1>%s</h1>\n"
281 (www-format-encode-string
282 (symbol-name feature-name))))
283 (princ (format "<p>name : %s "
284 (or (www-format-feature-name feature-name) "")))
288 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
293 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
298 (www-format-encode-string
301 (or (char-feature-property feature-name name@lang) ""))))
305 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
311 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
313 (www-html-display-paragraph
315 (or (www-feature-type feature-name)
316 ;; (char-feature-property feature-name 'type)
318 (princ (format "<p>value-format : %s "
321 (or (www-feature-value-format feature-name)
329 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
335 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
338 (princ "<p>format : ")
339 (www-html-display-text
340 (decode-coding-string
342 (www-feature-format feature-name))
347 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
353 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
356 (www-html-display-paragraph
357 (format "description : %s"
358 (or (char-feature-property feature-name 'description)
361 (www-html-display-paragraph
362 (format "description@%s : %s"
364 (or (char-feature-property
366 (intern (format "description@%s" lang)))
370 (defun www-batch-view ()
371 (setq terminal-coding-system 'binary)
373 (let* ((target (pop command-line-args-left))
374 (user (pop command-line-args-left))
375 (accept-language (pop command-line-args-left))
376 (mode (intern (pop command-line-args-left)))
381 (car (split-string accept-language ","))
385 (princ "Content-Type: text/html; charset=UTF-8
387 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
388 \"http://www.w3.org/TR/html4/loose.dtd\">
393 (when (string-match "^char=\\(&[^&;]+;\\)" target)
394 (setq ret (match-end 0))
397 (www-uri-encode-object
398 (www-uri-decode-object
399 'character (match-string 1 target)))
400 (substring target ret))))
402 (mapcar (lambda (cell)
403 (if (string-match "=" cell)
405 (setq genre (substring cell 0 (match-beginning 0))
406 ret (substring cell (match-end 0)))
409 (decode-uri-string genre 'utf-8-mcs-er))
411 (list (decode-uri-string cell 'utf-8-mcs-er))))
412 (split-string target "&")))
413 (setq ret (car target))
414 (cond ((eq (car ret) 'char)
415 (www-display-object-desc
421 ((eq (car ret) 'feature)
422 (www-display-feature-desc
423 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
430 (www-display-object-desc
438 (princ (format "mode=%S\n" mode))
439 (princ (format "user=%s\n" user))
440 ;; (princ (format "local user=%s\n" (user-login-name)))
441 (princ (format "lang=%S\n" lang))
442 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
444 ;; (princ xemacs-chise-version)
450 (princ (format "%S" err)))
453 (provide 'cwiki-view)