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\" />
98 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
99 <input type=\"submit\" value=\"RDF\" />
103 "<div style=\"text-align:right;\">
104 <a href=\"../view.cgi?%s=%s\">
105 <input type=\"submit\" value=\"Simple\" />
107 <input type=\"submit\" value=\"New Account\" />
108 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
109 <input type=\"submit\" value=\"RDF\" />
115 (when (setq parents (www-get-feature-value object '<-denotational))
116 (princ (format "<p>%s %s</p>\n<hr>\n"
117 (www-format-value-as-char-list parents)
118 (www-format-feature-name '->denotational lang))))
119 (when (setq parents (www-get-feature-value object '<-subsumptive))
120 (princ (format "<p>%s %s</p>\n<hr>\n"
121 (www-format-value-as-char-list parents)
122 (www-format-feature-name '->subsumptive lang))))
123 (when (eq genre 'character)
124 (setq GlyphWiki-id (char-GlyphWiki-id object)))
125 (princ (format "<h%d>%s%s</h%d>\n"
127 (www-format-encode-string
128 (est-format-object object 'readable))
131 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
133 GlyphWiki-id GlyphWiki-id)
138 (when feature-name-to-edit
139 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
141 (encode-coding-string
142 (format "<p>(%s : <input type=\"text\" name=\"%s\"
143 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
146 (decode-uri-string uri-object 'utf-8-mcs-er))
149 (if (eq genre 'character)
150 (char-attribute-alist object)
151 (concord-object-spec object)))
152 (when feature-name-to-edit
153 (unless (assq base-name-to-edit object-spec)
154 (setq object-spec (cons (cons base-name-to-edit nil)
156 (dolist (cell (sort object-spec
158 (char-attribute-name<
159 (char-feature-name-sans-versions (car a))
160 (char-feature-name-sans-versions (car b))))))
161 (setq logical-feature (char-feature-name-sans-versions (car cell)))
162 (unless (memq logical-feature chise-wiki-displayed-features)
163 (push logical-feature chise-wiki-displayed-features)
165 ((and feature-name-to-edit
166 (eq (car cell) feature-name-to-edit))
167 (www-edit-display-feature-input-box
168 object feature-name-to-edit editing-format)
173 "<div class=\"feature\" style=\"line-height:150%\">\n"
176 (www-format-eval-list
177 (www-feature-format logical-feature)
179 logical-feature ; (car cell)
184 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
185 ><input type=\"submit\" value=\"note\" /></a>"
188 (www-format-encode-string uri-object)
189 (www-format-encode-string
190 (www-uri-encode-feature-name
191 (intern (format "%s*note"
192 logical-feature ; (car cell)
194 (when (and feature-name-to-edit
195 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
198 (www-edit-display-feature-input-box
199 object feature-name-to-edit editing-format)
212 (when feature-name-to-edit
216 (format "<a href=\"%s?%s=%s\"
217 ><input type=\"submit\" value=\"add feature\" /></a>
221 (www-format-encode-string uri-object))))
226 (when (eq genre 'character)
228 "<form action=\"http://www.chise.org/ids-find\">\n")
230 (www-format-encode-string
231 (est-format-object object)
232 ;; (if (eq genre 'character)
233 ;; (format "%c" object)
234 ;; (format "%s" (concord-object-id object)))
238 " <input type=\"text\" name=\"components\"
239 size=\"30\" maxlength=\"30\" value=\"%s\" />"
240 (encode-coding-string
241 (est-format-object object)
242 ;; (if (eq genre 'character)
243 ;; (char-to-string object)
244 ;; (format "%s" (concord-object-id object)))
247 (www-format-encode-string
248 "ă\u542Bă\u6F22\u5B57ă\u63A2ă"))
249 (princ " <input type=\"submit\" value=\"search\" />\n")
257 (defun www-display-feature-desc (uri-feature-name genre uri-object
258 &optional lang simple)
259 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
260 (name@lang (intern (format "name@%s" lang))))
262 (encode-coding-string
264 <title>EsT feature: %s</title>
272 "<div style=\"text-align:right;\">
273 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
274 <input type=\"submit\" value=\"Edit\" />
276 <input type=\"submit\" value=\"New Account\" />
279 "<div style=\"text-align:right;\">
280 <a href=\"../view.cgi?feature=%s&%s=%s\">
281 <input type=\"submit\" value=\"Simple\" />
285 uri-feature-name genre uri-object))
287 (format "<h1>%s</h1>\n"
288 (www-format-encode-string
289 (symbol-name feature-name))))
290 (princ (format "<p>name : %s "
291 (or (www-format-feature-name feature-name) "")))
295 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
300 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
305 (www-format-encode-string
308 (or (char-feature-property feature-name name@lang) ""))))
312 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
318 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
320 (www-html-display-paragraph
322 (or (www-feature-type feature-name)
323 ;; (char-feature-property feature-name 'type)
325 (princ (format "<p>value-format : %s "
328 (or (www-feature-value-format feature-name)
336 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
342 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
345 (princ "<p>format : ")
346 (www-html-display-text
347 (decode-coding-string
349 (www-feature-format feature-name))
354 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
360 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
363 (www-html-display-paragraph
364 (format "description : %s"
365 (or (char-feature-property feature-name 'description)
368 (www-html-display-paragraph
369 (format "description@%s : %s"
371 (or (char-feature-property
373 (intern (format "description@%s" lang)))
377 (defun www-batch-view ()
378 (setq terminal-coding-system 'binary)
380 (let* ((target (pop command-line-args-left))
381 (user (pop command-line-args-left))
382 (accept-language (pop command-line-args-left))
383 (mode (intern (pop command-line-args-left)))
388 (car (split-string accept-language ","))
392 (princ "Content-Type: text/html; charset=UTF-8
394 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
395 \"http://www.w3.org/TR/html4/loose.dtd\">
400 (when (string-match "^char=\\(&[^&;]+;\\)" target)
401 (setq ret (match-end 0))
404 (www-uri-encode-object
405 (www-uri-decode-object
406 'character (match-string 1 target)))
407 (substring target ret))))
409 (mapcar (lambda (cell)
410 (if (string-match "=" cell)
412 (setq genre (substring cell 0 (match-beginning 0))
413 ret (substring cell (match-end 0)))
416 (decode-uri-string genre 'utf-8-mcs-er))
418 (list (decode-uri-string cell 'utf-8-mcs-er))))
419 (split-string target "&")))
420 (setq ret (car target))
421 (cond ((eq (car ret) 'char)
422 (www-display-object-desc
428 ((eq (car ret) 'feature)
429 (www-display-feature-desc
430 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
437 (www-display-object-desc
445 (princ (format "mode=%S\n" mode))
446 (princ (format "user=%s\n" user))
447 ;; (princ (format "local user=%s\n" (user-login-name)))
448 (princ (format "lang=%S\n" lang))
449 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
451 ;; (princ xemacs-chise-version)
457 (princ (format "%S" err)))
460 (provide 'cwiki-view)