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 <title>EsT %s = %s</title>
97 (decode-uri-string uri-object 'utf-8-mcs-er))
100 (when (eq genre 'character)
101 (dolist (feature (char-feature-property '$object 'additional-features))
102 (mount-char-attribute-table
103 (char-feature-name-at-domain feature '$rev=latest))))
107 (if est-hide-cgi-mode
108 "<div style=\"text-align:right;\">
109 <a href=\"../../edit/view.cgi?%s=%s\">
110 <input type=\"submit\" value=\"Edit\" />
112 "<div style=\"text-align:right;\">
113 <a href=\"edit/view.cgi?%s=%s\">
114 <input type=\"submit\" value=\"Edit\" />
116 genre rdf-uri-object)
118 "<div style=\"text-align:right;\">
119 <a href=\"../view/%s/%s\">
120 <input type=\"submit\" value=\"Simple\" />
123 (if (string-match ":" uri-object)
125 (est-uri-encode-feature-name-body
126 (substring uri-object 0 (match-beginning 0)))
128 (est-uri-encode-feature-name-body
129 (substring uri-object (match-end 0))))))))
131 (format "<input type=\"submit\" value=\"New Account\" />
132 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
133 <input type=\"submit\" value=\"RDF\" />
137 genre rdf-uri-object))
138 (when (setq parents (www-get-feature-value object '<-denotational))
139 (princ (format "<p>%s %s</p>\n<hr>\n"
140 (www-format-value-as-char-list parents)
141 (www-format-feature-name '->denotational lang))))
142 (when (setq parents (www-get-feature-value object '<-subsumptive))
143 (princ (format "<p>%s %s</p>\n<hr>\n"
144 (www-format-value-as-char-list parents)
145 (www-format-feature-name '->subsumptive lang))))
146 (when (eq genre 'character)
147 (setq GlyphWiki-id (char-GlyphWiki-id object)))
148 (setq ret (www-format-encode-string
149 (est-format-object object 'readable)))
150 (princ (format "<h%d>%s%s</h%d>\n"
153 (format "<a href=\"%s\">%s</a>"
154 ;; (if est-hide-cgi-mode
155 ;; "<a href=\"../%s\">%s</a>"
156 ;; "<a href=\"%s\">%s</a>")
157 (www-uri-make-object-url object uri-object)
162 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
164 GlyphWiki-id GlyphWiki-id)
169 (when feature-name-to-edit
170 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
172 (encode-coding-string
173 (format "<p>(%s : <input type=\"text\" name=\"%s\"
174 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
177 (decode-uri-string uri-object 'utf-8-mcs-er))
182 (setq feature-name-to-display
183 (www-uri-decode-feature-name uri-feature-name))
184 (setq est-eval-list-feature-items-limit nil)
186 (cons feature-name-to-display
187 (if (eq genre 'character)
188 (get-char-attribute object feature-name-to-display)
189 (concord-object-get object feature-name-to-display)))))
191 (if (eq genre 'character)
192 (char-attribute-alist object)
193 (concord-object-spec object)))))
194 (when feature-name-to-edit
195 (unless (assq base-name-to-edit object-spec)
196 (setq object-spec (cons (cons base-name-to-edit nil)
198 (dolist (cell (sort object-spec
200 (char-attribute-name<
201 (char-feature-name-sans-versions (car a))
202 (char-feature-name-sans-versions (car b))))))
203 (setq logical-feature (char-feature-name-sans-versions (car cell)))
204 (unless (memq logical-feature chise-wiki-displayed-features)
205 (push logical-feature chise-wiki-displayed-features)
207 ((and feature-name-to-edit
208 (eq (car cell) feature-name-to-edit))
209 (www-edit-display-feature-input-box
210 object feature-name-to-edit editing-format)
215 "<div class=\"feature\" style=\"line-height:150%\">\n"
218 (www-format-eval-list
219 (www-feature-format logical-feature)
221 logical-feature ; (car cell)
226 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
227 ><input type=\"submit\" value=\"note\" /></a>"
230 (www-format-encode-string uri-object)
231 (www-format-encode-string
232 (www-uri-encode-feature-name
233 (intern (format "%s*note"
234 logical-feature ; (car cell)
236 (when (and feature-name-to-edit
237 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
240 (www-edit-display-feature-input-box
241 object feature-name-to-edit editing-format)
254 (when feature-name-to-edit
258 (format "<a href=\"%s?%s=%s\"
259 ><input type=\"submit\" value=\"add feature\" /></a>
263 (www-format-encode-string uri-object))))
268 (when (eq genre 'character)
270 "<form action=\"http://www.chise.org/ids-find\">\n")
272 (www-format-encode-string
273 (est-format-object object)
274 ;; (if (eq genre 'character)
275 ;; (format "%c" object)
276 ;; (format "%s" (concord-object-id object)))
280 " <input type=\"text\" name=\"components\"
281 size=\"30\" maxlength=\"30\" value=\"%s\" />"
282 (encode-coding-string
283 (est-format-object object)
284 ;; (if (eq genre 'character)
285 ;; (char-to-string object)
286 ;; (format "%s" (concord-object-id object)))
289 (www-format-encode-string
290 "を\u542Bむ\u6F22\u5B57を\u63A2す"))
291 (princ " <input type=\"submit\" value=\"search\" />\n")
295 "<form action=\"http://www.chise.org/hng-ids-find\">\n")
297 (www-format-encode-string
298 (est-format-object object)
299 ;; (if (eq genre 'character)
300 ;; (format "%c" object)
301 ;; (format "%s" (concord-object-id object)))
305 " <input type=\"text\" name=\"components\"
306 size=\"30\" maxlength=\"30\" value=\"%s\" />"
307 (encode-coding-string
308 (est-format-object object)
309 ;; (if (eq genre 'character)
310 ;; (char-to-string object)
311 ;; (format "%s" (concord-object-id object)))
314 (www-format-encode-string
315 "を\u542Bむ HNG の\u6F22\u5B57を\u63A2す"))
316 (princ " <input type=\"submit\" value=\"search\" />\n")
325 (defun www-display-feature-desc (uri-feature-name genre uri-object
326 &optional lang simple)
327 (let ((rdf-uri-object (if est-hide-cgi-mode
328 (if (string-match "=" uri-object)
330 (est-uri-decode-feature-name-body
331 (substring uri-object 0 (match-beginning 0)))
333 (est-uri-decode-feature-name-body
334 (substring uri-object (match-end 0))))
336 (feature-name (www-uri-decode-feature-name uri-feature-name))
337 (name@lang (intern (format "name@%s" lang))))
339 (encode-coding-string
341 <title>EsT feature: %s</title>
349 (if est-hide-cgi-mode
350 "<div style=\"text-align:right;\">
351 <a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
352 <input type=\"submit\" value=\"Edit\" />
354 <input type=\"submit\" value=\"New Account\" />
357 "<div style=\"text-align:right;\">
358 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
359 <input type=\"submit\" value=\"Edit\" />
361 <input type=\"submit\" value=\"New Account\" />
364 uri-feature-name genre rdf-uri-object)
366 "<div style=\"text-align:right;\">
367 <a href=\"../view/feature/%s&%s/%s\">
368 <input type=\"submit\" value=\"Simple\" />
372 uri-feature-name genre uri-object)))
374 (format "<h1>%s</h1>\n"
375 (www-format-encode-string
376 (symbol-name feature-name))))
377 (princ (format "<p>name : %s "
378 (or (www-format-feature-name feature-name) "")))
382 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
387 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
392 (www-format-encode-string
395 (or (char-feature-property feature-name name@lang) ""))))
399 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
405 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
407 (www-html-display-paragraph
409 (or (www-feature-type feature-name)
410 ;; (char-feature-property feature-name 'type)
412 (princ (format "<p>value-format : %s "
415 (or (www-feature-value-format feature-name)
423 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
429 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
432 (princ (format "<p>value-presentation-format : %s "
434 nil 'value-presentation-format
435 (or (www-feature-value-format feature-name)
443 " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
449 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
452 (princ "<p>format : ")
453 (www-html-display-text
454 (decode-coding-string
456 (www-feature-format feature-name))
461 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
467 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
470 (www-html-display-paragraph
471 (format "description : %s"
472 (or (decode-coding-string
473 (char-feature-property feature-name 'description)
477 (www-html-display-paragraph
478 (format "description@%s : %s"
480 (or (char-feature-property
482 (intern (format "description@%s" lang)))
486 (defun www-batch-view ()
487 (setq terminal-coding-system 'binary)
489 (let* ((target (pop command-line-args-left))
490 (user (pop command-line-args-left))
491 (accept-language (pop command-line-args-left))
492 (mode (intern (pop command-line-args-left)))
497 (car (split-string accept-language ","))
501 (princ "Content-Type: text/html; charset=UTF-8
503 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
504 \"http://www.w3.org/TR/html4/loose.dtd\">
509 (when (string-match "^char=\\(&[^&;]+;\\)" target)
510 (setq ret (match-end 0))
513 (www-uri-encode-object
514 (www-uri-decode-object
515 'character (match-string 1 target)))
516 (substring target ret))))
518 (mapcar (lambda (cell)
519 (if (string-match "=" cell)
521 (setq genre (substring cell 0 (match-beginning 0))
522 ret (substring cell (match-end 0)))
525 (decode-uri-string genre 'utf-8-mcs-er))
527 (list (decode-uri-string cell 'utf-8-mcs-er))))
528 (split-string target "&")))
529 (setq ret (car target))
530 (cond ((eq (car ret) 'char)
531 (www-display-object-desc
532 'character (cdr ret) (cdr (assq 'feature target))
536 ((eq (car ret) 'feature)
537 (www-display-feature-desc
538 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
545 (www-display-object-desc
546 (car ret) (cdr ret) (cdr (assq 'feature target))
552 (princ (format "mode=%S\n" mode))
553 (princ (format "user=%s\n" user))
554 ;; (princ (format "local user=%s\n" (user-login-name)))
555 (princ (format "lang=%S\n" lang))
556 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
558 ;; (princ xemacs-chise-version)
564 (princ (format "%S" err)))
567 (defun www-batch-view-smart ()
568 (setq debug-on-error t)
569 (setq terminal-coding-system 'binary)
571 (let* ((est-hide-cgi-mode t)
572 (target (pop command-line-args-left))
573 (user (pop command-line-args-left))
574 (accept-language (pop command-line-args-left))
575 (mode (intern (pop command-line-args-left)))
580 (car (split-string accept-language ","))
584 (princ "Content-Type: text/html; charset=UTF-8
586 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
587 \"http://www.w3.org/TR/html4/loose.dtd\">
592 (when (string-match "^char/\\(&[^&;]+;\\)" target)
593 (setq ret (match-end 0))
596 (www-uri-encode-object
597 (www-uri-decode-object
598 'character (match-string 1 target)))
599 (substring target ret))))
603 (if (string-match "/" cell)
605 (setq genre (substring cell 0 (match-beginning 0))
606 ret (substring cell (match-end 0)))
608 (intern (decode-uri-string genre 'utf-8-mcs-er))
609 (if (string-match "/feature=" ret)
610 (list (substring ret 0 (match-beginning 0))
611 (substring ret (match-end 0)))
613 (list (decode-uri-string cell 'utf-8-mcs-er)))
614 ;; (setq ret (split-string cell "/"))
616 ;; (decode-uri-string (car ret) 'utf-8-mcs-er))
619 (split-string target "&")))
620 (setq ret (car target))
621 ;; (princ (format "<p>%S, %S, %S</p>"
622 ;; (car ret)(nth 1 ret)(nth 2 ret)))
623 (cond ((eq (car ret) 'char)
624 (www-display-object-desc
625 'character (nth 1 ret) (nth 2 ret)
629 ((eq (car ret) 'feature)
630 (www-display-feature-desc
631 (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
633 (nth 1 (nth 1 target))
638 (www-display-object-desc
639 (car ret) (nth 1 ret) (nth 2 ret)
645 (princ (format "mode=%S\n" mode))
646 (princ (format "user=%s\n" user))
647 ;; (princ (format "local user=%s\n" (user-login-name)))
648 (princ (format "lang=%S\n" lang))
649 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
651 ;; (princ xemacs-chise-version)
657 (princ (format "%S" err)))
660 (provide 'cwiki-view)