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)))
18 (format "<p><input type=\"text\" name=\"feature-name\"
19 size=\"32\" maxlength=\"256\" value=\"%s\">"
21 (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
23 (format "%s<input type=\"text\" name=\"%s\"
24 size=\"64\" maxlength=\"256\" value=\"%s\">
25 <input type=\"submit\" value=\"set\" /></p>
27 (if (or (eq format 'HEX)(eq format 'hex))
31 (mapconcat (lambda (c)
33 ;; ((eq c ?<) "&lt;")
34 ;; ((eq c ?>) "&gt;")
35 ((eq c ?\u0022) """)
38 (www-format-value char feature-name
39 value format 'without-tags)
43 (defun www-display-object-desc (genre uri-object &optional lang level simple
44 uri-feature-name-to-edit editing-format)
47 (let ((object (www-uri-decode-object genre uri-object))
49 base-name-to-edit metadata-name-to-edit
51 logical-feature chise-wiki-displayed-features
53 GlyphWiki-id ret object-spec)
57 (setq without-header t))
59 (when uri-feature-name-to-edit
60 (setq feature-name-to-edit
61 (www-uri-decode-feature-name uri-feature-name-to-edit))
62 (setq ret (symbol-name feature-name-to-edit))
63 (if (string-match "\\*" ret)
64 (setq base-name-to-edit (intern
65 (substring ret 0 (match-beginning 0)))
66 metadata-name-to-edit (intern
67 (substring ret (match-end 0))))
68 (setq base-name-to-edit feature-name-to-edit))
69 (when (stringp editing-format)
70 (setq editing-format (intern editing-format))))
71 (when (and (eq genre 'character)
72 (= (length uri-object) 1))
73 (setq uri-object (www-uri-encode-object object)))
78 <title>EsT %s = %s</title>
81 (decode-uri-string uri-object 'utf-8-mcs-er))
84 (when (eq genre 'character)
85 (dolist (feature (char-feature-property '$object 'additional-features))
86 (mount-char-attribute-table
87 (char-feature-name-at-domain feature '$rev=latest))))
91 "<div style=\"text-align:right;\">
92 <a href=\"edit/view.cgi?%s=%s\">
93 <input type=\"submit\" value=\"Edit\" />
95 <input type=\"submit\" value=\"New Account\" />
98 "<div style=\"text-align:right;\">
99 <a href=\"../view.cgi?%s=%s\">
100 <input type=\"submit\" value=\"Simple\" />
106 (when (setq parents (www-get-feature-value object '<-denotational))
107 (princ (format "<p>%s %s</p>\n<hr>\n"
108 (www-format-value-as-char-list parents)
109 (www-format-feature-name '->denotational lang))))
110 (when (setq parents (www-get-feature-value object '<-subsumptive))
111 (princ (format "<p>%s %s</p>\n<hr>\n"
112 (www-format-value-as-char-list parents)
113 (www-format-feature-name '->subsumptive lang))))
114 (when (eq genre 'character)
115 (setq GlyphWiki-id (char-GlyphWiki-id object)))
116 (princ (format "<h%d>%s%s</h%d>\n"
118 (www-format-encode-string
119 (est-format-object object)
120 ;; (if (eq genre 'character)
121 ;; (char-to-string object)
122 ;; (format "%s" (concord-object-id object)))
126 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
128 GlyphWiki-id GlyphWiki-id)
133 (when feature-name-to-edit
134 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
136 (encode-coding-string
137 (format "<p>(%s : <input type=\"text\" name=\"%s\"
138 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
141 (decode-uri-string uri-object 'utf-8-mcs-er))
144 (if (eq genre 'character)
145 (char-attribute-alist object)
146 (concord-object-spec object)))
147 (when feature-name-to-edit
148 (unless (assq base-name-to-edit object-spec)
149 (setq object-spec (cons (cons base-name-to-edit nil)
151 (dolist (cell (sort object-spec
153 (char-attribute-name<
154 (char-feature-name-sans-versions (car a))
155 (char-feature-name-sans-versions (car b))))))
156 (setq logical-feature (char-feature-name-sans-versions (car cell)))
157 (unless (memq logical-feature chise-wiki-displayed-features)
158 (push logical-feature chise-wiki-displayed-features)
160 ((and feature-name-to-edit
161 (eq (car cell) feature-name-to-edit))
162 (www-edit-display-feature-input-box
163 object feature-name-to-edit editing-format)
168 "<div class=\"feature\" style=\"line-height:150%\">\n"
171 (www-format-eval-list
172 (www-feature-format logical-feature)
174 logical-feature ; (car cell)
179 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
180 ><input type=\"submit\" value=\"note\" /></a>"
183 (www-format-encode-string uri-object)
184 (www-format-encode-string
185 (www-uri-encode-feature-name
186 (intern (format "%s*note"
187 logical-feature ; (car cell)
189 (when (and feature-name-to-edit
190 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
193 (www-edit-display-feature-input-box
194 object feature-name-to-edit editing-format)
207 (when feature-name-to-edit
211 (format "<a href=\"%s?%s=%s\"
212 ><input type=\"submit\" value=\"add feature\" /></a>
216 (www-format-encode-string uri-object))))
221 (when (eq genre 'character)
223 "<form action=\"http://www.chise.org/ids-find\">\n")
225 (www-format-encode-string
226 (est-format-object object)
227 ;; (if (eq genre 'character)
228 ;; (format "%c" object)
229 ;; (format "%s" (concord-object-id object)))
233 " <input type=\"text\" name=\"components\"
234 size=\"30\" maxlength=\"30\" value=\"%s\" />"
235 (encode-coding-string
236 (est-format-object object)
237 ;; (if (eq genre 'character)
238 ;; (char-to-string object)
239 ;; (format "%s" (concord-object-id object)))
242 (www-format-encode-string
243 "ă\u542Bă\u6F22\u5B57ă\u63A2ă"))
244 (princ " <input type=\"submit\" value=\"search\" />\n")
252 (defun www-display-feature-desc (uri-feature-name genre uri-object
253 &optional lang simple)
254 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
255 (name@lang (intern (format "name@%s" lang))))
257 (encode-coding-string
259 <title>EsT feature: %s</title>
267 "<div style=\"text-align:right;\">
268 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
269 <input type=\"submit\" value=\"Edit\" />
271 <input type=\"submit\" value=\"New Account\" />
274 "<div style=\"text-align:right;\">
275 <a href=\"../view.cgi?feature=%s&%s=%s\">
276 <input type=\"submit\" value=\"Simple\" />
280 uri-feature-name genre uri-object))
282 (format "<h1>%s</h1>\n"
283 (www-format-encode-string
284 (symbol-name feature-name))))
285 (princ (format "<p>name : %s "
286 (or (www-format-feature-name feature-name) "")))
290 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
295 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
300 (www-format-encode-string
303 (or (char-feature-property feature-name name@lang) ""))))
307 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
313 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
315 (www-html-display-paragraph
317 (or (www-feature-type feature-name)
318 ;; (char-feature-property feature-name 'type)
320 (princ (format "<p>value-format : %s "
323 (or (www-feature-value-format feature-name)
330 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
336 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
339 (princ "<p>format : ")
340 (www-html-display-text
341 (decode-coding-string
343 (www-feature-format feature-name))
348 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
354 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
357 (www-html-display-paragraph
358 (format "description : %s"
359 (or (char-feature-property feature-name 'description)
362 (www-html-display-paragraph
363 (format "description@%s : %s"
365 (or (char-feature-property
367 (intern (format "description@%s" lang)))
371 (defun www-batch-view ()
372 (setq terminal-coding-system 'binary)
374 (let* ((target (pop command-line-args-left))
375 (user (pop command-line-args-left))
376 (accept-language (pop command-line-args-left))
377 (mode (intern (pop command-line-args-left)))
382 (car (split-string accept-language ","))
386 (princ "Content-Type: text/html; charset=UTF-8
388 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
389 \"http://www.w3.org/TR/html4/loose.dtd\">
394 (when (string-match "^char=\\(&[^&;]+;\\)" target)
395 (setq ret (match-end 0))
398 (www-uri-encode-object
399 (www-uri-decode-object
400 'character (match-string 1 target)))
401 (substring target ret))))
403 (mapcar (lambda (cell)
404 (if (string-match "=" cell)
408 (substring cell 0 (match-beginning 0))
410 (substring cell (match-end 0)))
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)