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")
299 (defun www-display-feature-desc (uri-feature-name genre uri-object
300 &optional lang simple)
301 (let ((rdf-uri-object (if est-hide-cgi-mode
302 (if (string-match "=" uri-object)
304 (est-uri-decode-feature-name-body
305 (substring uri-object 0 (match-beginning 0)))
307 (est-uri-decode-feature-name-body
308 (substring uri-object (match-end 0))))
310 (feature-name (www-uri-decode-feature-name uri-feature-name))
311 (name@lang (intern (format "name@%s" lang))))
313 (encode-coding-string
315 <title>EsT feature: %s</title>
323 (if est-hide-cgi-mode
324 "<div style=\"text-align:right;\">
325 <a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
326 <input type=\"submit\" value=\"Edit\" />
328 <input type=\"submit\" value=\"New Account\" />
331 "<div style=\"text-align:right;\">
332 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
333 <input type=\"submit\" value=\"Edit\" />
335 <input type=\"submit\" value=\"New Account\" />
338 uri-feature-name genre rdf-uri-object)
340 "<div style=\"text-align:right;\">
341 <a href=\"../view/feature/%s&%s/%s\">
342 <input type=\"submit\" value=\"Simple\" />
346 uri-feature-name genre uri-object)))
348 (format "<h1>%s</h1>\n"
349 (www-format-encode-string
350 (symbol-name feature-name))))
351 (princ (format "<p>name : %s "
352 (or (www-format-feature-name feature-name) "")))
356 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
361 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
366 (www-format-encode-string
369 (or (char-feature-property feature-name name@lang) ""))))
373 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
379 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
381 (www-html-display-paragraph
383 (or (www-feature-type feature-name)
384 ;; (char-feature-property feature-name 'type)
386 (princ (format "<p>value-format : %s "
389 (or (www-feature-value-format feature-name)
397 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
403 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
406 (princ (format "<p>value-presentation-format : %s "
408 nil 'value-presentation-format
409 (or (www-feature-value-format feature-name)
417 " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
423 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
426 (princ "<p>format : ")
427 (www-html-display-text
428 (decode-coding-string
430 (www-feature-format feature-name))
435 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
441 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
444 (www-html-display-paragraph
445 (format "description : %s"
446 (or (char-feature-property feature-name 'description)
449 (www-html-display-paragraph
450 (format "description@%s : %s"
452 (or (char-feature-property
454 (intern (format "description@%s" lang)))
458 (defun www-batch-view ()
459 (setq terminal-coding-system 'binary)
461 (let* ((target (pop command-line-args-left))
462 (user (pop command-line-args-left))
463 (accept-language (pop command-line-args-left))
464 (mode (intern (pop command-line-args-left)))
469 (car (split-string accept-language ","))
473 (princ "Content-Type: text/html; charset=UTF-8
475 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
476 \"http://www.w3.org/TR/html4/loose.dtd\">
481 (when (string-match "^char=\\(&[^&;]+;\\)" target)
482 (setq ret (match-end 0))
485 (www-uri-encode-object
486 (www-uri-decode-object
487 'character (match-string 1 target)))
488 (substring target ret))))
490 (mapcar (lambda (cell)
491 (if (string-match "=" cell)
493 (setq genre (substring cell 0 (match-beginning 0))
494 ret (substring cell (match-end 0)))
497 (decode-uri-string genre 'utf-8-mcs-er))
499 (list (decode-uri-string cell 'utf-8-mcs-er))))
500 (split-string target "&")))
501 (setq ret (car target))
502 (cond ((eq (car ret) 'char)
503 (www-display-object-desc
504 'character (cdr ret) (cdr (assq 'feature target))
508 ((eq (car ret) 'feature)
509 (www-display-feature-desc
510 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
517 (www-display-object-desc
518 (car ret) (cdr ret) (cdr (assq 'feature target))
524 (princ (format "mode=%S\n" mode))
525 (princ (format "user=%s\n" user))
526 ;; (princ (format "local user=%s\n" (user-login-name)))
527 (princ (format "lang=%S\n" lang))
528 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
530 ;; (princ xemacs-chise-version)
536 (princ (format "%S" err)))
539 (defun www-batch-view-smart ()
540 (setq debug-on-error t)
541 (setq terminal-coding-system 'binary)
543 (let* ((est-hide-cgi-mode t)
544 (target (pop command-line-args-left))
545 (user (pop command-line-args-left))
546 (accept-language (pop command-line-args-left))
547 (mode (intern (pop command-line-args-left)))
552 (car (split-string accept-language ","))
556 (princ "Content-Type: text/html; charset=UTF-8
558 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
559 \"http://www.w3.org/TR/html4/loose.dtd\">
564 (when (string-match "^char/\\(&[^&;]+;\\)" target)
565 (setq ret (match-end 0))
568 (www-uri-encode-object
569 (www-uri-decode-object
570 'character (match-string 1 target)))
571 (substring target ret))))
575 (if (string-match "/" cell)
577 (setq genre (substring cell 0 (match-beginning 0))
578 ret (substring cell (match-end 0)))
580 (intern (decode-uri-string genre 'utf-8-mcs-er))
581 (if (string-match "/feature=" ret)
582 (list (substring ret 0 (match-beginning 0))
583 (substring ret (match-end 0)))
585 (list (decode-uri-string cell 'utf-8-mcs-er)))
586 ;; (setq ret (split-string cell "/"))
588 ;; (decode-uri-string (car ret) 'utf-8-mcs-er))
591 (split-string target "&")))
592 (setq ret (car target))
593 ;; (princ (format "<p>%S, %S, %S</p>"
594 ;; (car ret)(nth 1 ret)(nth 2 ret)))
595 (cond ((eq (car ret) 'char)
596 (www-display-object-desc
597 'character (nth 1 ret) (nth 2 ret)
601 ((eq (car ret) 'feature)
602 (www-display-feature-desc
603 (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
605 (nth 1 (nth 1 target))
610 (www-display-object-desc
611 (car ret) (nth 1 ret) (nth 2 ret)
617 (princ (format "mode=%S\n" mode))
618 (princ (format "user=%s\n" user))
619 ;; (princ (format "local user=%s\n" (user-login-name)))
620 (princ (format "lang=%S\n" lang))
621 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
623 ;; (princ xemacs-chise-version)
629 (princ (format "%S" err)))
632 (provide 'cwiki-view)