1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-format)
3 (require 'char-db-json)
5 (defvar chise-wiki-view-url "view.cgi")
6 (defvar chise-wiki-edit-url "edit.cgi")
7 (defvar chise-wiki-add-url "add.cgi")
9 (defun www-edit-display-feature-input-box (char feature-name
10 &optional format value)
12 (setq char (or (concord-decode-object '=id char 'feature)
13 (concord-make-object 'feature char))))
15 (setq format 'default))
17 (setq value (www-get-feature-value char feature-name)))
18 (if (and (symbolp value)
19 (eq format 'wiki-text))
20 (setq value (list (list value))))
22 (format "<p><input type=\"text\" name=\"feature-name\"
23 size=\"32\" maxlength=\"256\" value=\"%s\">"
25 (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
27 (format "%s<input type=\"text\" name=\"%s\"
28 size=\"64\" maxlength=\"256\" value=\"%s\">
29 <input type=\"submit\" value=\"set\" /></p>
31 (if (or (eq format 'HEX)(eq format 'hex))
35 (mapconcat (lambda (c)
37 ;; ((eq c ?<) "&lt;")
38 ;; ((eq c ?>) "&gt;")
39 ((eq c ?\u0022) """)
42 (est-format-list value format nil nil " ")
46 (defun www-display-object-desc (genre uri-object &optional uri-feature-name
48 uri-feature-name-to-edit editing-format)
51 (let ((object (www-uri-decode-object genre uri-object))
52 (est-eval-list-feature-items-limit est-eval-list-feature-items-limit)
53 (est-view-url-prefix (if uri-feature-name
56 (rdf-uri-object (if est-hide-cgi-mode
57 (if (string-match "=" uri-object)
59 (est-uri-decode-feature-name-body
60 (substring uri-object 0 (match-beginning 0)))
62 (est-uri-decode-feature-name-body
63 (substring uri-object (match-end 0))))
65 feature-name-to-display feature-name-to-edit
66 base-name-to-edit metadata-name-to-edit
68 logical-feature chise-wiki-displayed-features
70 GlyphWiki-id HNG-card ret object-spec)
74 (setq without-header t))
76 (when uri-feature-name-to-edit
77 (setq feature-name-to-edit
78 (www-uri-decode-feature-name uri-feature-name-to-edit))
79 (setq ret (symbol-name feature-name-to-edit))
80 (if (string-match "\\*" ret)
81 (setq base-name-to-edit (intern
82 (substring ret 0 (match-beginning 0)))
83 metadata-name-to-edit (intern
84 (substring ret (match-end 0))))
85 (setq base-name-to-edit feature-name-to-edit))
86 (when (stringp editing-format)
87 (setq editing-format (intern editing-format))))
88 (when (and (eq genre 'character)
89 (= (length uri-object) 1))
90 (setq uri-object (www-uri-encode-object object)))
95 <style type=\"text/css\">
98 .ids { vertical-align: middle; font-size: 40px; line-height: 100%%; }
99 a { text-decoration: none; }
100 .ids a { color: black; }
101 ul { margin: 0 0; color: black; }
102 li { margin: 0 0 0 2em; }
103 .feature-name { font-family: sans-serif; font-weight: bold; }
104 .feature-name a { color: black; }
108 <title>EsT %s = %s</title>
111 (decode-uri-string uri-object 'utf-8-mcs-er))
114 (when (eq genre 'character)
115 (dolist (feature (char-feature-property '$object 'additional-features))
116 (mount-char-attribute-table
117 (char-feature-name-at-domain feature '$rev=latest))))
121 (if est-hide-cgi-mode
122 "<div style=\"text-align:right;\">
123 <a href=\"../../edit/view.cgi?%s=%s\">
124 <input type=\"submit\" value=\"Edit\" />
126 "<div style=\"text-align:right;\">
127 <a href=\"edit/view.cgi?%s=%s\">
128 <input type=\"submit\" value=\"Edit\" />
130 genre rdf-uri-object)
132 "<div style=\"text-align:right;\">
133 <a href=\"../view/%s/%s\">
134 <input type=\"submit\" value=\"Simple\" />
137 (if (string-match ":" uri-object)
139 (est-uri-encode-feature-name-body
140 (substring uri-object 0 (match-beginning 0)))
142 (est-uri-encode-feature-name-body
143 (substring uri-object (match-end 0))))))))
145 (format "<input type=\"submit\" value=\"New Account\" />
146 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
147 <input type=\"submit\" value=\"RDF\" />
152 (if (eq genre 'character)
154 <a href=\"/est/view/%s/%s/data.json\">
155 <input type=\"submit\" value=\"JSON\" />
157 genre rdf-uri-object)
159 (when (setq parents (www-get-feature-value object '<-denotational))
160 (princ (format "<p>%s %s</p>\n<hr>\n"
161 (www-format-value-as-char-list parents)
162 (www-format-feature-name '->denotational lang))))
163 (when (setq parents (www-get-feature-value object '<-subsumptive))
164 (princ (format "<p>%s %s</p>\n<hr>\n"
165 (www-format-value-as-char-list parents)
166 (www-format-feature-name '->subsumptive lang))))
167 (when (eq genre 'character)
168 (setq GlyphWiki-id (char-GlyphWiki-id object)))
169 (setq ret (www-format-encode-string
170 (est-format-object object 'readable)))
172 (if (string-match "<img alt=\"HNG\\([0-9]+\\)-\\([0-9]+\\)\"" ret)
173 (format "HNG/%s/cards/%s.jpg"
175 (match-string 2 ret))))
176 (princ (format "<h%d>%s%s</h%d>\n"
179 (format "<a href=\"%s\">%s</a>"
180 ;; (if est-hide-cgi-mode
181 ;; "<a href=\"../%s\">%s</a>"
182 ;; "<a href=\"%s\">%s</a>")
183 (www-uri-make-object-url object uri-object)
187 "<a href=\"http://hng.chise.org/images/%s\">%s</a>"
192 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
194 GlyphWiki-id GlyphWiki-id)
199 (when feature-name-to-edit
200 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
202 (encode-coding-string
203 (format "<p>(%s : <input type=\"text\" name=\"%s\"
204 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
207 (decode-uri-string uri-object 'utf-8-mcs-er))
212 (setq feature-name-to-display
213 (www-uri-decode-feature-name uri-feature-name))
214 (setq est-eval-list-feature-items-limit nil)
216 (cons feature-name-to-display
217 (if (eq genre 'character)
218 (get-char-attribute object feature-name-to-display)
219 (concord-object-get object feature-name-to-display)))))
221 (if (eq genre 'character)
222 (char-attribute-alist object)
223 (concord-object-spec object)))))
224 (when feature-name-to-edit
225 (unless (assq base-name-to-edit object-spec)
226 (setq object-spec (cons (cons base-name-to-edit nil)
228 (dolist (cell (sort object-spec
230 (char-attribute-name<
231 (char-feature-name-sans-versions (car a))
232 (char-feature-name-sans-versions (car b))))))
233 (setq logical-feature (char-feature-name-sans-versions (car cell)))
234 (unless (memq logical-feature chise-wiki-displayed-features)
235 (push logical-feature chise-wiki-displayed-features)
237 ((and feature-name-to-edit
238 (eq (car cell) feature-name-to-edit))
239 (www-edit-display-feature-input-box
240 object feature-name-to-edit editing-format)
245 "<div class=\"feature\" style=\"line-height:150%\">\n"
248 (www-format-eval-list
249 (www-feature-format logical-feature)
251 logical-feature ; (car cell)
256 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
257 ><input type=\"submit\" value=\"note\" /></a>"
260 (www-format-encode-string uri-object)
261 (www-format-encode-string
262 (www-uri-encode-feature-name
263 (intern (format "%s*note"
264 logical-feature ; (car cell)
266 (when (and feature-name-to-edit
267 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
270 (www-edit-display-feature-input-box
271 object feature-name-to-edit editing-format)
284 (when feature-name-to-edit
288 (format "<a href=\"%s?%s=%s\"
289 ><input type=\"submit\" value=\"add feature\" /></a>
293 (www-format-encode-string uri-object))))
298 (when (eq genre 'character)
300 "<form action=\"http://www.chise.org/ids-find\">\n")
302 (www-format-encode-string
303 (est-format-object object)
304 ;; (if (eq genre 'character)
305 ;; (format "%c" object)
306 ;; (format "%s" (concord-object-id object)))
310 " <input type=\"text\" name=\"components\"
311 size=\"30\" maxlength=\"30\" value=\"%s\" />"
312 (encode-coding-string
313 (est-format-object object)
314 ;; (if (eq genre 'character)
315 ;; (char-to-string object)
316 ;; (format "%s" (concord-object-id object)))
319 (www-format-encode-string
320 "を\u542Bむ\u6F22\u5B57を\u63A2す"))
321 (princ " <input type=\"submit\" value=\"search\" />\n")
325 "<form action=\"http://www.chise.org/hng-ids-find\">\n")
327 (www-format-encode-string
328 (est-format-object object)
329 ;; (if (eq genre 'character)
330 ;; (format "%c" object)
331 ;; (format "%s" (concord-object-id object)))
335 " <input type=\"text\" name=\"components\"
336 size=\"30\" maxlength=\"30\" value=\"%s\" />"
337 (encode-coding-string
338 (est-format-object object)
339 ;; (if (eq genre 'character)
340 ;; (char-to-string object)
341 ;; (format "%s" (concord-object-id object)))
344 (www-format-encode-string
345 "を\u542Bむ HNG の\u6F22\u5B57を\u63A2す"))
346 (princ " <input type=\"submit\" value=\"search\" />\n")
355 (defun www-display-feature-desc (uri-feature-name genre uri-object
356 &optional lang simple)
357 (let ((rdf-uri-object (if est-hide-cgi-mode
358 (if (string-match "=" uri-object)
360 (est-uri-decode-feature-name-body
361 (substring uri-object 0 (match-beginning 0)))
363 (est-uri-decode-feature-name-body
364 (substring uri-object (match-end 0))))
366 (feature-name (www-uri-decode-feature-name uri-feature-name))
367 (name@lang (intern (format "name@%s" lang))))
369 (encode-coding-string
371 <title>EsT feature: %s</title>
379 (if est-hide-cgi-mode
380 "<div style=\"text-align:right;\">
381 <a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
382 <input type=\"submit\" value=\"Edit\" />
384 <input type=\"submit\" value=\"New Account\" />
387 "<div style=\"text-align:right;\">
388 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
389 <input type=\"submit\" value=\"Edit\" />
391 <input type=\"submit\" value=\"New Account\" />
394 uri-feature-name genre rdf-uri-object)
396 "<div style=\"text-align:right;\">
397 <a href=\"../view/feature/%s&%s/%s\">
398 <input type=\"submit\" value=\"Simple\" />
402 uri-feature-name genre uri-object)))
404 (format "<h1>%s</h1>\n"
405 (www-format-encode-string
406 (symbol-name feature-name))))
407 (princ (format "<p>name : %s "
408 (or (www-format-feature-name feature-name) "")))
412 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
417 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
422 (www-format-encode-string
425 (or (char-feature-property feature-name name@lang) ""))))
429 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
435 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
437 (www-html-display-paragraph
439 (or (www-feature-type feature-name)
440 ;; (char-feature-property feature-name 'type)
442 (princ (format "<p>value-format : %s "
445 (or (www-feature-value-format feature-name)
453 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
459 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
462 (princ (format "<p>value-presentation-format : %s "
464 nil 'value-presentation-format
465 (or (www-feature-value-format feature-name)
473 " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
479 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
482 (princ "<p>format : ")
483 (www-html-display-text
484 (decode-coding-string
486 (www-feature-format feature-name))
491 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
497 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
500 (www-html-display-paragraph
501 (format "description : %s"
502 (or (decode-coding-string
503 (char-feature-property feature-name 'description)
507 (www-html-display-paragraph
508 (format "description@%s : %s"
510 (or (char-feature-property
512 (intern (format "description@%s" lang)))
516 (defun www-batch-view ()
517 (setq terminal-coding-system 'binary)
519 (let* ((target (pop command-line-args-left))
520 (user (pop command-line-args-left))
521 (accept-language (pop command-line-args-left))
522 (mode (intern (pop command-line-args-left)))
527 (car (split-string accept-language ","))
531 (princ "Content-Type: text/html; charset=UTF-8
533 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
534 \"http://www.w3.org/TR/html4/loose.dtd\">
539 (when (string-match "^char=\\(&[^&;]+;\\)" target)
540 (setq ret (match-end 0))
543 (www-uri-encode-object
544 (www-uri-decode-object
545 'character (match-string 1 target)))
546 (substring target ret))))
548 (mapcar (lambda (cell)
549 (if (string-match "=" cell)
551 (setq genre (substring cell 0 (match-beginning 0))
552 ret (substring cell (match-end 0)))
555 (decode-uri-string genre 'utf-8-mcs-er))
557 (list (decode-uri-string cell 'utf-8-mcs-er))))
558 (split-string target "&")))
559 (setq ret (car target))
560 (cond ((eq (car ret) 'char)
561 (www-display-object-desc
562 'character (cdr ret) (cdr (assq 'feature target))
566 ((eq (car ret) 'feature)
567 (www-display-feature-desc
568 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
575 (www-display-object-desc
576 (car ret) (cdr ret) (cdr (assq 'feature target))
582 (princ (format "mode=%S\n" mode))
583 (princ (format "user=%s\n" user))
584 ;; (princ (format "local user=%s\n" (user-login-name)))
585 (princ (format "lang=%S\n" lang))
586 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
588 ;; (princ xemacs-chise-version)
594 (princ (format "%S" err)))
597 (defun www-batch-view-smart ()
598 (setq debug-on-error t)
599 (setq terminal-coding-system 'binary)
601 (let* ((est-hide-cgi-mode t)
602 (target (pop command-line-args-left))
603 (user (pop command-line-args-left))
604 (accept-language (pop command-line-args-left))
605 (mode (intern (pop command-line-args-left)))
610 (car (split-string accept-language ","))
613 ret genre feature json obj)
616 (when (string-match "/data\\.json$" target)
618 target (substring target 0 (match-beginning 0))))
619 (when (string-match "^char/\\(&[^&;]+;\\)" target)
620 (setq ret (match-end 0))
623 (www-uri-encode-object
624 (www-uri-decode-object
625 'character (match-string 1 target)))
626 (substring target ret))))
630 (if (string-match "/" cell)
632 (setq genre (substring cell 0 (match-beginning 0))
633 ret (substring cell (match-end 0)))
635 (intern (decode-uri-string genre 'utf-8-mcs-er))
636 (if (string-match "/feature=" ret)
637 (list (substring ret 0 (match-beginning 0))
638 (substring ret (match-end 0)))
640 (list (decode-uri-string cell 'utf-8-mcs-er)))
641 ;; (setq ret (split-string cell "/"))
643 ;; (decode-uri-string (car ret) 'utf-8-mcs-er))
646 (split-string target "&")))
647 (setq ret (car target))
649 (princ "Content-Type: application/json; charset=UTF-8
652 (princ "Content-Type: text/html; charset=UTF-8
654 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
655 \"http://www.w3.org/TR/html4/loose.dtd\">
659 ;; (princ (format "<p>%S, %S, %S</p>"
660 ;; (car ret)(nth 1 ret)(nth 2 ret)))
661 ;; (princ (format "// %S %S\n" ret json))
662 (cond ((or (eq (car ret) 'char)
663 (eq (car ret) 'character))
665 (setq obj (www-uri-decode-object
666 (car ret)(nth 1 ret)))
669 ;; (princ (encode-coding-string
670 ;; (format "// %S\n" obj)
671 ;; char-db-file-coding-system))
672 (char-db-json-char-data-with-variant obj 'printable)
673 (encode-coding-region
674 (point-min)(point-max)
675 char-db-file-coding-system)
676 (princ (buffer-string))
678 (www-display-object-desc
679 'character (nth 1 ret) (nth 2 ret)
683 ((eq (car ret) 'feature)
684 (www-display-feature-desc
685 (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
687 (nth 1 (nth 1 target))
692 (www-display-object-desc
693 (car ret) (nth 1 ret) (nth 2 ret)
700 (princ (format "mode=%S\n" mode))
701 (princ (format "user=%s\n" user))
702 ;; (princ (format "local user=%s\n" (user-login-name)))
703 (princ (format "lang=%S\n" lang))
704 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
706 ;; (princ xemacs-chise-version)
713 (princ (format "%S" err)))
716 (provide 'cwiki-view)