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 (est-view-url-prefix (if uri-feature-name
55 (rdf-uri-object (if est-hide-cgi-mode
56 (if (string-match "=" uri-object)
58 (est-uri-decode-feature-name-body
59 (substring uri-object 0 (match-beginning 0)))
61 (est-uri-decode-feature-name-body
62 (substring uri-object (match-end 0))))
64 feature-name-to-display feature-name-to-edit
65 base-name-to-edit metadata-name-to-edit
67 logical-feature chise-wiki-displayed-features
69 GlyphWiki-id ret object-spec)
73 (setq without-header t))
75 (when uri-feature-name-to-edit
76 (setq feature-name-to-edit
77 (www-uri-decode-feature-name uri-feature-name-to-edit))
78 (setq ret (symbol-name feature-name-to-edit))
79 (if (string-match "\\*" ret)
80 (setq base-name-to-edit (intern
81 (substring ret 0 (match-beginning 0)))
82 metadata-name-to-edit (intern
83 (substring ret (match-end 0))))
84 (setq base-name-to-edit feature-name-to-edit))
85 (when (stringp editing-format)
86 (setq editing-format (intern editing-format))))
87 (when (and (eq genre 'character)
88 (= (length uri-object) 1))
89 (setq uri-object (www-uri-encode-object object)))
94 <style type=\"text/css\">
97 .ids { vertical-align: middle; font-size: 40px; line-height: 100%%; }
98 a { text-decoration: none; }
99 .ids a { color: black; }
100 ul { margin: 0 0; color: black; }
101 li { margin: 0 0 0 2em; }
102 .feature-name { font-family: sans-serif; font-weight: bold; }
103 .feature-name a { color: black; }
107 <title>EsT %s = %s</title>
110 (decode-uri-string uri-object 'utf-8-mcs-er))
113 (when (eq genre 'character)
114 (dolist (feature (char-feature-property '$object 'additional-features))
115 (mount-char-attribute-table
116 (char-feature-name-at-domain feature '$rev=latest))))
120 (if est-hide-cgi-mode
121 "<div style=\"text-align:right;\">
122 <a href=\"../../edit/view.cgi?%s=%s\">
123 <input type=\"submit\" value=\"Edit\" />
125 "<div style=\"text-align:right;\">
126 <a href=\"edit/view.cgi?%s=%s\">
127 <input type=\"submit\" value=\"Edit\" />
129 genre rdf-uri-object)
131 "<div style=\"text-align:right;\">
132 <a href=\"../view/%s/%s\">
133 <input type=\"submit\" value=\"Simple\" />
136 (if (string-match ":" uri-object)
138 (est-uri-encode-feature-name-body
139 (substring uri-object 0 (match-beginning 0)))
141 (est-uri-encode-feature-name-body
142 (substring uri-object (match-end 0))))))))
144 (format "<input type=\"submit\" value=\"New Account\" />
145 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
146 <input type=\"submit\" value=\"RDF\" />
150 genre rdf-uri-object))
151 (when (setq parents (www-get-feature-value object '<-denotational))
152 (princ (format "<p>%s %s</p>\n<hr>\n"
153 (www-format-value-as-char-list parents)
154 (www-format-feature-name '->denotational lang))))
155 (when (setq parents (www-get-feature-value object '<-subsumptive))
156 (princ (format "<p>%s %s</p>\n<hr>\n"
157 (www-format-value-as-char-list parents)
158 (www-format-feature-name '->subsumptive lang))))
159 (when (eq genre 'character)
160 (setq GlyphWiki-id (char-GlyphWiki-id object)))
161 (setq ret (www-format-encode-string
162 (est-format-object object 'readable)))
163 (princ (format "<h%d>%s%s</h%d>\n"
166 (format "<a href=\"%s\">%s</a>"
167 ;; (if est-hide-cgi-mode
168 ;; "<a href=\"../%s\">%s</a>"
169 ;; "<a href=\"%s\">%s</a>")
170 (www-uri-make-object-url object uri-object)
175 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
177 GlyphWiki-id GlyphWiki-id)
182 (when feature-name-to-edit
183 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
185 (encode-coding-string
186 (format "<p>(%s : <input type=\"text\" name=\"%s\"
187 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
190 (decode-uri-string uri-object 'utf-8-mcs-er))
195 (setq feature-name-to-display
196 (www-uri-decode-feature-name uri-feature-name))
197 (setq est-eval-list-feature-items-limit nil)
199 (cons feature-name-to-display
200 (if (eq genre 'character)
201 (get-char-attribute object feature-name-to-display)
202 (concord-object-get object feature-name-to-display)))))
204 (if (eq genre 'character)
205 (char-attribute-alist object)
206 (concord-object-spec object)))))
207 (when feature-name-to-edit
208 (unless (assq base-name-to-edit object-spec)
209 (setq object-spec (cons (cons base-name-to-edit nil)
211 (dolist (cell (sort object-spec
213 (char-attribute-name<
214 (char-feature-name-sans-versions (car a))
215 (char-feature-name-sans-versions (car b))))))
216 (setq logical-feature (char-feature-name-sans-versions (car cell)))
217 (unless (memq logical-feature chise-wiki-displayed-features)
218 (push logical-feature chise-wiki-displayed-features)
220 ((and feature-name-to-edit
221 (eq (car cell) feature-name-to-edit))
222 (www-edit-display-feature-input-box
223 object feature-name-to-edit editing-format)
228 "<div class=\"feature\" style=\"line-height:150%\">\n"
231 (www-format-eval-list
232 (www-feature-format logical-feature)
234 logical-feature ; (car cell)
239 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
240 ><input type=\"submit\" value=\"note\" /></a>"
243 (www-format-encode-string uri-object)
244 (www-format-encode-string
245 (www-uri-encode-feature-name
246 (intern (format "%s*note"
247 logical-feature ; (car cell)
249 (when (and feature-name-to-edit
250 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
253 (www-edit-display-feature-input-box
254 object feature-name-to-edit editing-format)
267 (when feature-name-to-edit
271 (format "<a href=\"%s?%s=%s\"
272 ><input type=\"submit\" value=\"add feature\" /></a>
276 (www-format-encode-string uri-object))))
281 (when (eq genre 'character)
283 "<form action=\"http://www.chise.org/ids-find\">\n")
285 (www-format-encode-string
286 (est-format-object object)
287 ;; (if (eq genre 'character)
288 ;; (format "%c" object)
289 ;; (format "%s" (concord-object-id object)))
293 " <input type=\"text\" name=\"components\"
294 size=\"30\" maxlength=\"30\" value=\"%s\" />"
295 (encode-coding-string
296 (est-format-object object)
297 ;; (if (eq genre 'character)
298 ;; (char-to-string object)
299 ;; (format "%s" (concord-object-id object)))
302 (www-format-encode-string
303 "を\u542Bむ\u6F22\u5B57を\u63A2す"))
304 (princ " <input type=\"submit\" value=\"search\" />\n")
308 "<form action=\"http://www.chise.org/hng-ids-find\">\n")
310 (www-format-encode-string
311 (est-format-object object)
312 ;; (if (eq genre 'character)
313 ;; (format "%c" object)
314 ;; (format "%s" (concord-object-id object)))
318 " <input type=\"text\" name=\"components\"
319 size=\"30\" maxlength=\"30\" value=\"%s\" />"
320 (encode-coding-string
321 (est-format-object object)
322 ;; (if (eq genre 'character)
323 ;; (char-to-string object)
324 ;; (format "%s" (concord-object-id object)))
327 (www-format-encode-string
328 "を\u542Bむ HNG の\u6F22\u5B57を\u63A2す"))
329 (princ " <input type=\"submit\" value=\"search\" />\n")
338 (defun www-display-feature-desc (uri-feature-name genre uri-object
339 &optional lang simple)
340 (let ((rdf-uri-object (if est-hide-cgi-mode
341 (if (string-match "=" uri-object)
343 (est-uri-decode-feature-name-body
344 (substring uri-object 0 (match-beginning 0)))
346 (est-uri-decode-feature-name-body
347 (substring uri-object (match-end 0))))
349 (feature-name (www-uri-decode-feature-name uri-feature-name))
350 (name@lang (intern (format "name@%s" lang))))
352 (encode-coding-string
354 <title>EsT feature: %s</title>
362 (if est-hide-cgi-mode
363 "<div style=\"text-align:right;\">
364 <a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
365 <input type=\"submit\" value=\"Edit\" />
367 <input type=\"submit\" value=\"New Account\" />
370 "<div style=\"text-align:right;\">
371 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
372 <input type=\"submit\" value=\"Edit\" />
374 <input type=\"submit\" value=\"New Account\" />
377 uri-feature-name genre rdf-uri-object)
379 "<div style=\"text-align:right;\">
380 <a href=\"../view/feature/%s&%s/%s\">
381 <input type=\"submit\" value=\"Simple\" />
385 uri-feature-name genre uri-object)))
387 (format "<h1>%s</h1>\n"
388 (www-format-encode-string
389 (symbol-name feature-name))))
390 (princ (format "<p>name : %s "
391 (or (www-format-feature-name feature-name) "")))
395 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
400 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
405 (www-format-encode-string
408 (or (char-feature-property feature-name name@lang) ""))))
412 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
418 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
420 (www-html-display-paragraph
422 (or (www-feature-type feature-name)
423 ;; (char-feature-property feature-name 'type)
425 (princ (format "<p>value-format : %s "
428 (or (www-feature-value-format feature-name)
436 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
442 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
445 (princ (format "<p>value-presentation-format : %s "
447 nil 'value-presentation-format
448 (or (www-feature-value-format feature-name)
456 " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
462 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
465 (princ "<p>format : ")
466 (www-html-display-text
467 (decode-coding-string
469 (www-feature-format feature-name))
474 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
480 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
483 (www-html-display-paragraph
484 (format "description : %s"
485 (or (decode-coding-string
486 (char-feature-property feature-name 'description)
490 (www-html-display-paragraph
491 (format "description@%s : %s"
493 (or (char-feature-property
495 (intern (format "description@%s" lang)))
499 (defun www-batch-view ()
500 (setq terminal-coding-system 'binary)
502 (let* ((target (pop command-line-args-left))
503 (user (pop command-line-args-left))
504 (accept-language (pop command-line-args-left))
505 (mode (intern (pop command-line-args-left)))
510 (car (split-string accept-language ","))
514 (princ "Content-Type: text/html; charset=UTF-8
516 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
517 \"http://www.w3.org/TR/html4/loose.dtd\">
522 (when (string-match "^char=\\(&[^&;]+;\\)" target)
523 (setq ret (match-end 0))
526 (www-uri-encode-object
527 (www-uri-decode-object
528 'character (match-string 1 target)))
529 (substring target ret))))
531 (mapcar (lambda (cell)
532 (if (string-match "=" cell)
534 (setq genre (substring cell 0 (match-beginning 0))
535 ret (substring cell (match-end 0)))
538 (decode-uri-string genre 'utf-8-mcs-er))
540 (list (decode-uri-string cell 'utf-8-mcs-er))))
541 (split-string target "&")))
542 (setq ret (car target))
543 (cond ((eq (car ret) 'char)
544 (www-display-object-desc
545 'character (cdr ret) (cdr (assq 'feature target))
549 ((eq (car ret) 'feature)
550 (www-display-feature-desc
551 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
558 (www-display-object-desc
559 (car ret) (cdr ret) (cdr (assq 'feature target))
565 (princ (format "mode=%S\n" mode))
566 (princ (format "user=%s\n" user))
567 ;; (princ (format "local user=%s\n" (user-login-name)))
568 (princ (format "lang=%S\n" lang))
569 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
571 ;; (princ xemacs-chise-version)
577 (princ (format "%S" err)))
580 (defun www-batch-view-smart ()
581 (setq debug-on-error t)
582 (setq terminal-coding-system 'binary)
584 (let* ((est-hide-cgi-mode t)
585 (target (pop command-line-args-left))
586 (user (pop command-line-args-left))
587 (accept-language (pop command-line-args-left))
588 (mode (intern (pop command-line-args-left)))
593 (car (split-string accept-language ","))
597 (princ "Content-Type: text/html; charset=UTF-8
599 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
600 \"http://www.w3.org/TR/html4/loose.dtd\">
605 (when (string-match "^char/\\(&[^&;]+;\\)" target)
606 (setq ret (match-end 0))
609 (www-uri-encode-object
610 (www-uri-decode-object
611 'character (match-string 1 target)))
612 (substring target ret))))
616 (if (string-match "/" cell)
618 (setq genre (substring cell 0 (match-beginning 0))
619 ret (substring cell (match-end 0)))
621 (intern (decode-uri-string genre 'utf-8-mcs-er))
622 (if (string-match "/feature=" ret)
623 (list (substring ret 0 (match-beginning 0))
624 (substring ret (match-end 0)))
626 (list (decode-uri-string cell 'utf-8-mcs-er)))
627 ;; (setq ret (split-string cell "/"))
629 ;; (decode-uri-string (car ret) 'utf-8-mcs-er))
632 (split-string target "&")))
633 (setq ret (car target))
634 ;; (princ (format "<p>%S, %S, %S</p>"
635 ;; (car ret)(nth 1 ret)(nth 2 ret)))
636 (cond ((eq (car ret) 'char)
637 (www-display-object-desc
638 'character (nth 1 ret) (nth 2 ret)
642 ((eq (car ret) 'feature)
643 (www-display-feature-desc
644 (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
646 (nth 1 (nth 1 target))
651 (www-display-object-desc
652 (car ret) (nth 1 ret) (nth 2 ret)
658 (princ (format "mode=%S\n" mode))
659 (princ (format "user=%s\n" user))
660 ;; (princ (format "local user=%s\n" (user-login-name)))
661 (princ (format "lang=%S\n" lang))
662 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
664 ;; (princ xemacs-chise-version)
670 (princ (format "%S" err)))
673 (provide 'cwiki-view)