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)
122 ;; (if (eq genre 'character)
123 ;; (char-to-string object)
124 ;; (format "%s" (concord-object-id object)))
128 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
130 GlyphWiki-id GlyphWiki-id)
135 (when feature-name-to-edit
136 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
138 (encode-coding-string
139 (format "<p>(%s : <input type=\"text\" name=\"%s\"
140 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
143 (decode-uri-string uri-object 'utf-8-mcs-er))
146 (if (eq genre 'character)
147 (char-attribute-alist object)
148 (concord-object-spec object)))
149 (when feature-name-to-edit
150 (unless (assq base-name-to-edit object-spec)
151 (setq object-spec (cons (cons base-name-to-edit nil)
153 (dolist (cell (sort object-spec
155 (char-attribute-name<
156 (char-feature-name-sans-versions (car a))
157 (char-feature-name-sans-versions (car b))))))
158 (setq logical-feature (char-feature-name-sans-versions (car cell)))
159 (unless (memq logical-feature chise-wiki-displayed-features)
160 (push logical-feature chise-wiki-displayed-features)
162 ((and feature-name-to-edit
163 (eq (car cell) feature-name-to-edit))
164 (www-edit-display-feature-input-box
165 object feature-name-to-edit editing-format)
170 "<div class=\"feature\" style=\"line-height:150%\">\n"
173 (www-format-eval-list
174 (www-feature-format logical-feature)
176 logical-feature ; (car cell)
181 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
182 ><input type=\"submit\" value=\"note\" /></a>"
185 (www-format-encode-string uri-object)
186 (www-format-encode-string
187 (www-uri-encode-feature-name
188 (intern (format "%s*note"
189 logical-feature ; (car cell)
191 (when (and feature-name-to-edit
192 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
195 (www-edit-display-feature-input-box
196 object feature-name-to-edit editing-format)
209 (when feature-name-to-edit
213 (format "<a href=\"%s?%s=%s\"
214 ><input type=\"submit\" value=\"add feature\" /></a>
218 (www-format-encode-string uri-object))))
223 (when (eq genre 'character)
225 "<form action=\"http://www.chise.org/ids-find\">\n")
227 (www-format-encode-string
228 (est-format-object object)
229 ;; (if (eq genre 'character)
230 ;; (format "%c" object)
231 ;; (format "%s" (concord-object-id object)))
235 " <input type=\"text\" name=\"components\"
236 size=\"30\" maxlength=\"30\" value=\"%s\" />"
237 (encode-coding-string
238 (est-format-object object)
239 ;; (if (eq genre 'character)
240 ;; (char-to-string object)
241 ;; (format "%s" (concord-object-id object)))
244 (www-format-encode-string
245 "ă\u542Bă\u6F22\u5B57ă\u63A2ă"))
246 (princ " <input type=\"submit\" value=\"search\" />\n")
254 (defun www-display-feature-desc (uri-feature-name genre uri-object
255 &optional lang simple)
256 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
257 (name@lang (intern (format "name@%s" lang))))
259 (encode-coding-string
261 <title>EsT feature: %s</title>
269 "<div style=\"text-align:right;\">
270 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
271 <input type=\"submit\" value=\"Edit\" />
273 <input type=\"submit\" value=\"New Account\" />
276 "<div style=\"text-align:right;\">
277 <a href=\"../view.cgi?feature=%s&%s=%s\">
278 <input type=\"submit\" value=\"Simple\" />
282 uri-feature-name genre uri-object))
284 (format "<h1>%s</h1>\n"
285 (www-format-encode-string
286 (symbol-name feature-name))))
287 (princ (format "<p>name : %s "
288 (or (www-format-feature-name feature-name) "")))
292 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
297 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
302 (www-format-encode-string
305 (or (char-feature-property feature-name name@lang) ""))))
309 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
315 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
317 (www-html-display-paragraph
319 (or (www-feature-type feature-name)
320 ;; (char-feature-property feature-name 'type)
322 (princ (format "<p>value-format : %s "
325 (or (www-feature-value-format feature-name)
333 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
339 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
342 (princ "<p>format : ")
343 (www-html-display-text
344 (decode-coding-string
346 (www-feature-format feature-name))
351 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
357 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
360 (www-html-display-paragraph
361 (format "description : %s"
362 (or (char-feature-property feature-name 'description)
365 (www-html-display-paragraph
366 (format "description@%s : %s"
368 (or (char-feature-property
370 (intern (format "description@%s" lang)))
374 (defun www-batch-view ()
375 (setq terminal-coding-system 'binary)
377 (let* ((target (pop command-line-args-left))
378 (user (pop command-line-args-left))
379 (accept-language (pop command-line-args-left))
380 (mode (intern (pop command-line-args-left)))
385 (car (split-string accept-language ","))
389 (princ "Content-Type: text/html; charset=UTF-8
391 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
392 \"http://www.w3.org/TR/html4/loose.dtd\">
397 (when (string-match "^char=\\(&[^&;]+;\\)" target)
398 (setq ret (match-end 0))
401 (www-uri-encode-object
402 (www-uri-decode-object
403 'character (match-string 1 target)))
404 (substring target ret))))
406 (mapcar (lambda (cell)
407 (if (string-match "=" cell)
411 (substring cell 0 (match-beginning 0))
413 (substring cell (match-end 0)))
414 (list (decode-uri-string cell 'utf-8-mcs-er))))
415 (split-string target "&")))
416 (setq ret (car target))
417 (cond ((eq (car ret) 'char)
418 (www-display-object-desc
424 ((eq (car ret) 'feature)
425 (www-display-feature-desc
426 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
433 (www-display-object-desc
441 (princ (format "mode=%S\n" mode))
442 (princ (format "user=%s\n" user))
443 ;; (princ (format "local user=%s\n" (user-login-name)))
444 (princ (format "lang=%S\n" lang))
445 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
447 ;; (princ xemacs-chise-version)
453 (princ (format "%S" err)))
456 (provide 'cwiki-view)