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 HNG-card 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)))
164 (if (string-match "<img alt=\"HNG\\([0-9]+\\)-\\([0-9]+\\)\"" ret)
165 (format "HNG/%s/cards/%s.jpg"
167 (match-string 2 ret))))
168 (princ (format "<h%d>%s%s</h%d>\n"
171 (format "<a href=\"%s\">%s</a>"
172 ;; (if est-hide-cgi-mode
173 ;; "<a href=\"../%s\">%s</a>"
174 ;; "<a href=\"%s\">%s</a>")
175 (www-uri-make-object-url object uri-object)
179 "<a href=\"http://hng.chise.org/images/%s\">%s</a>"
184 " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
186 GlyphWiki-id GlyphWiki-id)
191 (when feature-name-to-edit
192 (princ "<form action=\"set.cgi\" method=\"GET\">\n")
194 (encode-coding-string
195 (format "<p>(%s : <input type=\"text\" name=\"%s\"
196 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
199 (decode-uri-string uri-object 'utf-8-mcs-er))
204 (setq feature-name-to-display
205 (www-uri-decode-feature-name uri-feature-name))
206 (setq est-eval-list-feature-items-limit nil)
208 (cons feature-name-to-display
209 (if (eq genre 'character)
210 (get-char-attribute object feature-name-to-display)
211 (concord-object-get object feature-name-to-display)))))
213 (if (eq genre 'character)
214 (char-attribute-alist object)
215 (concord-object-spec object)))))
216 (when feature-name-to-edit
217 (unless (assq base-name-to-edit object-spec)
218 (setq object-spec (cons (cons base-name-to-edit nil)
220 (dolist (cell (sort object-spec
222 (char-attribute-name<
223 (char-feature-name-sans-versions (car a))
224 (char-feature-name-sans-versions (car b))))))
225 (setq logical-feature (char-feature-name-sans-versions (car cell)))
226 (unless (memq logical-feature chise-wiki-displayed-features)
227 (push logical-feature chise-wiki-displayed-features)
229 ((and feature-name-to-edit
230 (eq (car cell) feature-name-to-edit))
231 (www-edit-display-feature-input-box
232 object feature-name-to-edit editing-format)
237 "<div class=\"feature\" style=\"line-height:150%\">\n"
240 (www-format-eval-list
241 (www-feature-format logical-feature)
243 logical-feature ; (car cell)
248 (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
249 ><input type=\"submit\" value=\"note\" /></a>"
252 (www-format-encode-string uri-object)
253 (www-format-encode-string
254 (www-uri-encode-feature-name
255 (intern (format "%s*note"
256 logical-feature ; (car cell)
258 (when (and feature-name-to-edit
259 (eq base-name-to-edit (car cell)) metadata-name-to-edit)
262 (www-edit-display-feature-input-box
263 object feature-name-to-edit editing-format)
276 (when feature-name-to-edit
280 (format "<a href=\"%s?%s=%s\"
281 ><input type=\"submit\" value=\"add feature\" /></a>
285 (www-format-encode-string uri-object))))
290 (when (eq genre 'character)
292 "<form action=\"http://www.chise.org/ids-find\">\n")
294 (www-format-encode-string
295 (est-format-object object)
296 ;; (if (eq genre 'character)
297 ;; (format "%c" object)
298 ;; (format "%s" (concord-object-id object)))
302 " <input type=\"text\" name=\"components\"
303 size=\"30\" maxlength=\"30\" value=\"%s\" />"
304 (encode-coding-string
305 (est-format-object object)
306 ;; (if (eq genre 'character)
307 ;; (char-to-string object)
308 ;; (format "%s" (concord-object-id object)))
311 (www-format-encode-string
312 "を\u542Bむ\u6F22\u5B57を\u63A2す"))
313 (princ " <input type=\"submit\" value=\"search\" />\n")
317 "<form action=\"http://www.chise.org/hng-ids-find\">\n")
319 (www-format-encode-string
320 (est-format-object object)
321 ;; (if (eq genre 'character)
322 ;; (format "%c" object)
323 ;; (format "%s" (concord-object-id object)))
327 " <input type=\"text\" name=\"components\"
328 size=\"30\" maxlength=\"30\" value=\"%s\" />"
329 (encode-coding-string
330 (est-format-object object)
331 ;; (if (eq genre 'character)
332 ;; (char-to-string object)
333 ;; (format "%s" (concord-object-id object)))
336 (www-format-encode-string
337 "を\u542Bむ HNG の\u6F22\u5B57を\u63A2す"))
338 (princ " <input type=\"submit\" value=\"search\" />\n")
347 (defun www-display-feature-desc (uri-feature-name genre uri-object
348 &optional lang simple)
349 (let ((rdf-uri-object (if est-hide-cgi-mode
350 (if (string-match "=" uri-object)
352 (est-uri-decode-feature-name-body
353 (substring uri-object 0 (match-beginning 0)))
355 (est-uri-decode-feature-name-body
356 (substring uri-object (match-end 0))))
358 (feature-name (www-uri-decode-feature-name uri-feature-name))
359 (name@lang (intern (format "name@%s" lang))))
361 (encode-coding-string
363 <title>EsT feature: %s</title>
371 (if est-hide-cgi-mode
372 "<div style=\"text-align:right;\">
373 <a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
374 <input type=\"submit\" value=\"Edit\" />
376 <input type=\"submit\" value=\"New Account\" />
379 "<div style=\"text-align:right;\">
380 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
381 <input type=\"submit\" value=\"Edit\" />
383 <input type=\"submit\" value=\"New Account\" />
386 uri-feature-name genre rdf-uri-object)
388 "<div style=\"text-align:right;\">
389 <a href=\"../view/feature/%s&%s/%s\">
390 <input type=\"submit\" value=\"Simple\" />
394 uri-feature-name genre uri-object)))
396 (format "<h1>%s</h1>\n"
397 (www-format-encode-string
398 (symbol-name feature-name))))
399 (princ (format "<p>name : %s "
400 (or (www-format-feature-name feature-name) "")))
404 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
409 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
414 (www-format-encode-string
417 (or (char-feature-property feature-name name@lang) ""))))
421 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
427 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
429 (www-html-display-paragraph
431 (or (www-feature-type feature-name)
432 ;; (char-feature-property feature-name 'type)
434 (princ (format "<p>value-format : %s "
437 (or (www-feature-value-format feature-name)
445 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
451 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
454 (princ (format "<p>value-presentation-format : %s "
456 nil 'value-presentation-format
457 (or (www-feature-value-format feature-name)
465 " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
471 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
474 (princ "<p>format : ")
475 (www-html-display-text
476 (decode-coding-string
478 (www-feature-format feature-name))
483 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
489 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
492 (www-html-display-paragraph
493 (format "description : %s"
494 (or (decode-coding-string
495 (char-feature-property feature-name 'description)
499 (www-html-display-paragraph
500 (format "description@%s : %s"
502 (or (char-feature-property
504 (intern (format "description@%s" lang)))
508 (defun www-batch-view ()
509 (setq terminal-coding-system 'binary)
511 (let* ((target (pop command-line-args-left))
512 (user (pop command-line-args-left))
513 (accept-language (pop command-line-args-left))
514 (mode (intern (pop command-line-args-left)))
519 (car (split-string accept-language ","))
523 (princ "Content-Type: text/html; charset=UTF-8
525 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
526 \"http://www.w3.org/TR/html4/loose.dtd\">
531 (when (string-match "^char=\\(&[^&;]+;\\)" target)
532 (setq ret (match-end 0))
535 (www-uri-encode-object
536 (www-uri-decode-object
537 'character (match-string 1 target)))
538 (substring target ret))))
540 (mapcar (lambda (cell)
541 (if (string-match "=" cell)
543 (setq genre (substring cell 0 (match-beginning 0))
544 ret (substring cell (match-end 0)))
547 (decode-uri-string genre 'utf-8-mcs-er))
549 (list (decode-uri-string cell 'utf-8-mcs-er))))
550 (split-string target "&")))
551 (setq ret (car target))
552 (cond ((eq (car ret) 'char)
553 (www-display-object-desc
554 'character (cdr ret) (cdr (assq 'feature target))
558 ((eq (car ret) 'feature)
559 (www-display-feature-desc
560 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
567 (www-display-object-desc
568 (car ret) (cdr ret) (cdr (assq 'feature target))
574 (princ (format "mode=%S\n" mode))
575 (princ (format "user=%s\n" user))
576 ;; (princ (format "local user=%s\n" (user-login-name)))
577 (princ (format "lang=%S\n" lang))
578 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
580 ;; (princ xemacs-chise-version)
586 (princ (format "%S" err)))
589 (defun www-batch-view-smart ()
590 (setq debug-on-error t)
591 (setq terminal-coding-system 'binary)
593 (let* ((est-hide-cgi-mode t)
594 (target (pop command-line-args-left))
595 (user (pop command-line-args-left))
596 (accept-language (pop command-line-args-left))
597 (mode (intern (pop command-line-args-left)))
602 (car (split-string accept-language ","))
606 (princ "Content-Type: text/html; charset=UTF-8
608 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
609 \"http://www.w3.org/TR/html4/loose.dtd\">
614 (when (string-match "^char/\\(&[^&;]+;\\)" target)
615 (setq ret (match-end 0))
618 (www-uri-encode-object
619 (www-uri-decode-object
620 'character (match-string 1 target)))
621 (substring target ret))))
625 (if (string-match "/" cell)
627 (setq genre (substring cell 0 (match-beginning 0))
628 ret (substring cell (match-end 0)))
630 (intern (decode-uri-string genre 'utf-8-mcs-er))
631 (if (string-match "/feature=" ret)
632 (list (substring ret 0 (match-beginning 0))
633 (substring ret (match-end 0)))
635 (list (decode-uri-string cell 'utf-8-mcs-er)))
636 ;; (setq ret (split-string cell "/"))
638 ;; (decode-uri-string (car ret) 'utf-8-mcs-er))
641 (split-string target "&")))
642 (setq ret (car target))
643 ;; (princ (format "<p>%S, %S, %S</p>"
644 ;; (car ret)(nth 1 ret)(nth 2 ret)))
645 (cond ((eq (car ret) 'char)
646 (www-display-object-desc
647 'character (nth 1 ret) (nth 2 ret)
651 ((eq (car ret) 'feature)
652 (www-display-feature-desc
653 (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
655 (nth 1 (nth 1 target))
660 (www-display-object-desc
661 (car ret) (nth 1 ret) (nth 2 ret)
667 (princ (format "mode=%S\n" mode))
668 (princ (format "user=%s\n" user))
669 ;; (princ (format "local user=%s\n" (user-login-name)))
670 (princ (format "lang=%S\n" lang))
671 (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
673 ;; (princ xemacs-chise-version)
679 (princ (format "%S" err)))
682 (provide 'cwiki-view)