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 uri-feature-name
47 uri-feature-name-to-edit editing-format)
50 (let ((object (www-uri-decode-object genre uri-object))
51 (est-eval-list-feature-items-limit est-eval-list-feature-items-limit)
52 feature-name-to-display feature-name-to-edit
53 base-name-to-edit metadata-name-to-edit
55 logical-feature chise-wiki-displayed-features
57 GlyphWiki-id ret object-spec)
61 (setq without-header t))
63 (when uri-feature-name-to-edit
64 (setq feature-name-to-edit
65 (www-uri-decode-feature-name uri-feature-name-to-edit))
66 (setq ret (symbol-name feature-name-to-edit))
67 (if (string-match "\\*" ret)
68 (setq base-name-to-edit (intern
69 (substring ret 0 (match-beginning 0)))
70 metadata-name-to-edit (intern
71 (substring ret (match-end 0))))
72 (setq base-name-to-edit feature-name-to-edit))
73 (when (stringp editing-format)
74 (setq editing-format (intern editing-format))))
75 (when (and (eq genre 'character)
76 (= (length uri-object) 1))
77 (setq uri-object (www-uri-encode-object object)))
82 <title>EsT %s = %s</title>
85 (decode-uri-string uri-object 'utf-8-mcs-er))
88 (when (eq genre 'character)
89 (dolist (feature (char-feature-property '$object 'additional-features))
90 (mount-char-attribute-table
91 (char-feature-name-at-domain feature '$rev=latest))))
95 "<div style=\"text-align:right;\">
96 <a href=\"edit/view.cgi?%s=%s\">
97 <input type=\"submit\" value=\"Edit\" />
99 <input type=\"submit\" value=\"New Account\" />
100 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
101 <input type=\"submit\" value=\"RDF\" />
105 "<div style=\"text-align:right;\">
106 <a href=\"../view.cgi?%s=%s\">
107 <input type=\"submit\" value=\"Simple\" />
109 <input type=\"submit\" value=\"New Account\" />
110 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
111 <input type=\"submit\" value=\"RDF\" />
117 (when (setq parents (www-get-feature-value object '<-denotational))
118 (princ (format "<p>%s %s</p>\n<hr>\n"
119 (www-format-value-as-char-list parents)
120 (www-format-feature-name '->denotational lang))))
121 (when (setq parents (www-get-feature-value object '<-subsumptive))
122 (princ (format "<p>%s %s</p>\n<hr>\n"
123 (www-format-value-as-char-list parents)
124 (www-format-feature-name '->subsumptive lang))))
125 (when (eq genre 'character)
126 (setq GlyphWiki-id (char-GlyphWiki-id object)))
127 (setq ret (www-format-encode-string
128 (est-format-object object 'readable)))
129 (princ (format "<h%d>%s%s</h%d>\n"
132 (format "<a href=\"%s\">%s</a>"
133 (www-uri-make-object-url object uri-object)
138 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
140 GlyphWiki-id GlyphWiki-id)
145 (when feature-name-to-edit
146 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
148 (encode-coding-string
149 (format "<p>(%s : <input type=\"text\" name=\"%s\"
150 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
153 (decode-uri-string uri-object 'utf-8-mcs-er))
158 (setq feature-name-to-display
159 (www-uri-decode-feature-name uri-feature-name))
160 (setq est-eval-list-feature-items-limit nil)
162 (cons feature-name-to-display
163 (if (eq genre 'character)
164 (get-char-attribute object feature-name-to-display)
165 (concord-object-get object feature-name-to-display)))))
167 (if (eq genre 'character)
168 (char-attribute-alist object)
169 (concord-object-spec object)))))
170 (when feature-name-to-edit
171 (unless (assq base-name-to-edit object-spec)
172 (setq object-spec (cons (cons base-name-to-edit nil)
174 (dolist (cell (sort object-spec
176 (char-attribute-name<
177 (char-feature-name-sans-versions (car a))
178 (char-feature-name-sans-versions (car b))))))
179 (setq logical-feature (char-feature-name-sans-versions (car cell)))
180 (unless (memq logical-feature chise-wiki-displayed-features)
181 (push logical-feature chise-wiki-displayed-features)
183 ((and feature-name-to-edit
184 (eq (car cell) feature-name-to-edit))
185 (www-edit-display-feature-input-box
186 object feature-name-to-edit editing-format)
191 "<div class=\"feature\" style=\"line-height:150%\">\n"
194 (www-format-eval-list
195 (www-feature-format logical-feature)
197 logical-feature ; (car cell)
202 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
203 ><input type=\"submit\" value=\"note\" /></a>"
206 (www-format-encode-string uri-object)
207 (www-format-encode-string
208 (www-uri-encode-feature-name
209 (intern (format "%s*note"
210 logical-feature ; (car cell)
212 (when (and feature-name-to-edit
213 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
216 (www-edit-display-feature-input-box
217 object feature-name-to-edit editing-format)
230 (when feature-name-to-edit
234 (format "<a href=\"%s?%s=%s\"
235 ><input type=\"submit\" value=\"add feature\" /></a>
239 (www-format-encode-string uri-object))))
244 (when (eq genre 'character)
246 "<form action=\"http://www.chise.org/ids-find\">\n")
248 (www-format-encode-string
249 (est-format-object object)
250 ;; (if (eq genre 'character)
251 ;; (format "%c" object)
252 ;; (format "%s" (concord-object-id object)))
256 " <input type=\"text\" name=\"components\"
257 size=\"30\" maxlength=\"30\" value=\"%s\" />"
258 (encode-coding-string
259 (est-format-object object)
260 ;; (if (eq genre 'character)
261 ;; (char-to-string object)
262 ;; (format "%s" (concord-object-id object)))
265 (www-format-encode-string
266 "ă\u542Bă\u6F22\u5B57ă\u63A2ă"))
267 (princ " <input type=\"submit\" value=\"search\" />\n")
275 (defun www-display-feature-desc (uri-feature-name genre uri-object
276 &optional lang simple)
277 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
278 (name@lang (intern (format "name@%s" lang))))
280 (encode-coding-string
282 <title>EsT feature: %s</title>
290 "<div style=\"text-align:right;\">
291 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
292 <input type=\"submit\" value=\"Edit\" />
294 <input type=\"submit\" value=\"New Account\" />
297 "<div style=\"text-align:right;\">
298 <a href=\"../view.cgi?feature=%s&%s=%s\">
299 <input type=\"submit\" value=\"Simple\" />
303 uri-feature-name genre uri-object))
305 (format "<h1>%s</h1>\n"
306 (www-format-encode-string
307 (symbol-name feature-name))))
308 (princ (format "<p>name : %s "
309 (or (www-format-feature-name feature-name) "")))
313 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
318 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
323 (www-format-encode-string
326 (or (char-feature-property feature-name name@lang) ""))))
330 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
336 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
338 (www-html-display-paragraph
340 (or (www-feature-type feature-name)
341 ;; (char-feature-property feature-name 'type)
343 (princ (format "<p>value-format : %s "
346 (or (www-feature-value-format feature-name)
354 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
360 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
363 (princ (format "<p>value-presentation-format : %s "
365 nil 'value-presentation-format
366 (or (www-feature-value-format feature-name)
374 " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
380 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
383 (princ "<p>format : ")
384 (www-html-display-text
385 (decode-coding-string
387 (www-feature-format feature-name))
392 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
398 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
401 (www-html-display-paragraph
402 (format "description : %s"
403 (or (char-feature-property feature-name 'description)
406 (www-html-display-paragraph
407 (format "description@%s : %s"
409 (or (char-feature-property
411 (intern (format "description@%s" lang)))
415 (defun www-batch-view ()
416 (setq terminal-coding-system 'binary)
418 (let* ((target (pop command-line-args-left))
419 (user (pop command-line-args-left))
420 (accept-language (pop command-line-args-left))
421 (mode (intern (pop command-line-args-left)))
426 (car (split-string accept-language ","))
430 (princ "Content-Type: text/html; charset=UTF-8
432 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
433 \"http://www.w3.org/TR/html4/loose.dtd\">
438 (when (string-match "^char=\\(&[^&;]+;\\)" target)
439 (setq ret (match-end 0))
442 (www-uri-encode-object
443 (www-uri-decode-object
444 'character (match-string 1 target)))
445 (substring target ret))))
447 (mapcar (lambda (cell)
448 (if (string-match "=" cell)
450 (setq genre (substring cell 0 (match-beginning 0))
451 ret (substring cell (match-end 0)))
454 (decode-uri-string genre 'utf-8-mcs-er))
456 (list (decode-uri-string cell 'utf-8-mcs-er))))
457 (split-string target "&")))
458 (setq ret (car target))
459 (cond ((eq (car ret) 'char)
460 (www-display-object-desc
461 'character (cdr ret) (cdr (assq 'feature target))
465 ((eq (car ret) 'feature)
466 (www-display-feature-desc
467 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
474 (www-display-object-desc
475 (car ret) (cdr ret) (cdr (assq 'feature target))
481 (princ (format "mode=%S\n" mode))
482 (princ (format "user=%s\n" user))
483 ;; (princ (format "local user=%s\n" (user-login-name)))
484 (princ (format "lang=%S\n" lang))
485 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
487 ;; (princ xemacs-chise-version)
493 (princ (format "%S" err)))
496 (provide 'cwiki-view)