(www-display-object-desc):
[chise/est.git] / cwiki-view.el
1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-format)
3 (require 'char-db-json)
4
5 (defvar chise-wiki-view-url "view.cgi")
6 (defvar chise-wiki-edit-url "edit.cgi")
7 (defvar chise-wiki-add-url "add.cgi")
8
9 (defun www-edit-display-feature-input-box (char feature-name
10                                                 &optional format value)
11   (if (symbolp char)
12       (setq char (or (concord-decode-object '=id char 'feature)
13                      (concord-make-object 'feature char))))
14   (unless format
15     (setq format 'default))
16   (unless value
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))))
21   (princ
22    (format "<p><input type=\"text\" name=\"feature-name\"
23 size=\"32\" maxlength=\"256\" value=\"%s\">"
24            feature-name))
25   (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
26   (princ
27    (format "%s<input type=\"text\" name=\"%s\"
28 size=\"64\" maxlength=\"256\" value=\"%s\">
29 <input type=\"submit\" value=\"set\" /></p>
30 "
31            (if (or (eq format 'HEX)(eq format 'hex))
32                "0x"
33              "")
34            format
35            (mapconcat (lambda (c)
36                         (cond
37                          ;; ((eq c ?<) "&amp;lt;")
38                          ;; ((eq c ?>) "&amp;gt;")
39                          ((eq c ?\u0022) "&quot;")
40                          (t
41                           (char-to-string c))))
42                       (est-format-list value format nil nil " ")
43                       "")))
44   )
45
46 (defun www-display-object-desc (genre uri-object &optional uri-feature-name
47                                       image-selection
48                                       lang level simple
49                                       uri-feature-name-to-edit editing-format)
50   (unless level
51     (setq level 0))
52   (let ((object (www-uri-decode-object genre uri-object))
53         (est-eval-list-feature-items-limit est-eval-list-feature-items-limit)
54         (est-view-url-prefix (if uri-feature-name
55                                  "../.."
56                                ".."))
57         (rdf-uri-object (if est-hide-cgi-mode
58                             (if (string-match "=" uri-object)
59                                 (concat
60                                  (est-uri-decode-feature-name-body
61                                   (substring uri-object 0 (match-beginning 0)))
62                                  ":"
63                                  (est-uri-decode-feature-name-body
64                                   (substring uri-object (match-end 0))))
65                               uri-object)))
66         feature-name-to-display feature-name-to-edit
67         base-name-to-edit metadata-name-to-edit
68         without-header
69         logical-feature chise-wiki-displayed-features
70         parents
71         GlyphWiki-id HNG-card ret object-spec)
72     (if (eq level 0)
73         (setq level 1
74               without-header nil)
75       (setq without-header t))
76     (when object
77       (when uri-feature-name-to-edit
78         (setq feature-name-to-edit
79               (www-uri-decode-feature-name uri-feature-name-to-edit))
80         (setq ret (symbol-name feature-name-to-edit))
81         (if (string-match "\\*" ret)
82             (setq base-name-to-edit (intern
83                                      (substring ret 0 (match-beginning 0)))
84                   metadata-name-to-edit (intern
85                                          (substring ret (match-end 0))))
86           (setq base-name-to-edit feature-name-to-edit))
87         (when (stringp editing-format)
88           (setq editing-format (intern editing-format))))
89       (when (and (eq genre 'character)
90                  (= (length uri-object) 1))
91         (setq uri-object (www-uri-encode-object object)))
92       (when (= level 1)
93         (princ
94          (encode-coding-string
95           (format "<head>
96 <style type=\"text/css\">
97 <!--
98 hr { color: green; }
99 .ids { vertical-align: middle; font-size: 40px; line-height: 100%%; }
100 a { text-decoration: none; }
101 .ids a { color: black; }
102 ul { margin: 0 0; color: black; }
103 li { margin: 0 0 0 2em; }
104 .feature-name { font-family: sans-serif; font-weight: bold; }
105 .feature-name a { color: black; }
106
107 .tooltip {
108     position: relative;
109     display: inline-block;
110     border-bottom: 1px dotted black;
111 }
112
113 .tooltip .tooltiptext {
114     visibility: hidden;
115     width: 120px;
116     top: 100%%;
117     left: 50%%;
118     margin-left: -60px;
119     background-color: black;
120     color: #fff;
121     text-align: center;
122     padding: 5px 0;
123     border-radius: 6px;
124  
125     position: absolute;
126     z-index: 1;
127 }
128
129 .list .tooltip:hover .tooltiptext {
130     visibility: visible;
131 }
132 -->
133 </style>
134
135 <script
136  src=\"http://hng.chise.org/openseadragon/openseadragon.min.js\"></script>
137
138 <title>EsT %s = %s</title>
139 </head>\n"
140                   genre
141                   (decode-uri-string uri-object 'utf-8-mcs-er))
142           'utf-8-mcs-er))
143         (princ "<body>\n"))
144       (when (eq genre 'character)
145         (dolist (feature (char-feature-property '$object 'additional-features))
146           (mount-char-attribute-table
147            (char-feature-name-at-domain feature '$rev=latest))))
148       (princ
149        (if simple
150            (format
151             (if est-hide-cgi-mode
152                 "<div style=\"text-align:right;\">
153 <a href=\"../../edit/view.cgi?%s=%s\">
154 <input type=\"submit\" value=\"Edit\" />
155 </a>\n"
156               "<div style=\"text-align:right;\">
157 <a href=\"edit/view.cgi?%s=%s\">
158 <input type=\"submit\" value=\"Edit\" />
159 </a>\n")
160             genre rdf-uri-object)
161          (format
162           "<div style=\"text-align:right;\">
163 <a href=\"../view/%s/%s\">
164 <input type=\"submit\" value=\"Simple\" />
165 </a>\n"
166           genre
167           (if (string-match ":" uri-object)
168               (concat
169                (est-uri-encode-feature-name-body
170                 (substring uri-object 0 (match-beginning 0)))
171                "="
172                (est-uri-encode-feature-name-body
173                 (substring uri-object (match-end 0))))))))
174       (princ
175        (format "<input type=\"submit\" value=\"New Account\" />
176 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
177 <input type=\"submit\" value=\"RDF\" />
178 </a>%s
179 </div>
180 <hr />\n"
181                genre rdf-uri-object
182                (if (eq genre 'character)
183                    (format "
184 <a href=\"/est/view/%s/%s/data.json\">
185 <input type=\"submit\" value=\"JSON\" />
186 </a>\n"
187                            genre rdf-uri-object)
188                  "")))
189       (when (setq parents (www-get-feature-value object '<-denotational))
190         (princ (format "<p>%s %s</p>\n<hr>\n"
191                        (www-format-value-as-char-list parents)
192                        (www-format-feature-name '->denotational lang))))
193       (when (setq parents (www-get-feature-value object '<-subsumptive))
194         (princ (format "<p>%s %s</p>\n<hr>\n"
195                        (www-format-value-as-char-list parents)
196                        (www-format-feature-name '->subsumptive lang))))
197       (when (eq genre 'character)
198         (setq GlyphWiki-id (char-GlyphWiki-id object)))
199       (cond
200        ((eq genre 'image-resource)
201         (princ
202          (if (setq ret (concord-object-get object '=location@iiif))
203              (if (concord-object-get object 'image-offset-x)
204                  (format "<img alt=\"%s\" src=\"%s\" />"
205                          ret ret)
206                (format "<div id=\"openseadragon1\"
207  style=\"width: 800px; height: 600px;\"></div>
208
209 <script type=\"text/javascript\">
210     OpenSeadragon({
211         id: \"openseadragon1\",
212         prefixUrl: \"http://hng.chise.org/openseadragon/images/\",
213         preserveViewport:   true,
214         visibilityRatio:    1,
215         minZoomLevel:       1,
216         defaultZoomLevel:   1,
217         sequenceMode:       true,
218         tileSources:   [ \"%s/info.json\" ]
219     });
220 </script>
221 "
222                        ret))
223            (setq ret (concord-object-get object '=location))
224            (format "<img alt=\"%s\" src=\"%s\" />"
225                    ret ret)))
226         )
227        (t
228         (setq ret (www-format-encode-string
229                    (est-format-object object 'readable)))
230         (setq HNG-card
231               (if (string-match
232                    "<img alt=\"HNG\\([0-9]+\\)-\\([0-9]+\\)\"" ret)
233                   (format "HNG/%s/cards/%s.jpg"
234                           (match-string 1 ret)
235                           (match-string 2 ret))))
236         (princ
237          (format "<h%d>%s%s</h%d>\n"
238                  level
239                  (cond
240                   (uri-feature-name
241                    (format "<a href=\"%s\">%s</a>"
242                            ;; (if est-hide-cgi-mode
243                            ;;     "<a href=\"../%s\">%s</a>"
244                            ;;   "<a href=\"%s\">%s</a>")
245                            (www-uri-make-object-url object uri-object)
246                            ret)
247                    )
248                   (HNG-card
249                    (format
250                     "<a href=\"http://hng.chise.org/images/%s\">%s</a>"
251                     HNG-card ret)
252                    )
253                   (t ret))
254                  (if GlyphWiki-id
255                      (format
256                       " <a href=\"http://glyphwiki.org/wiki/%s\"><img alt=\"%s\" src=\"http://glyphwiki.org/glyph/%s.50px.png\" /></a>"
257                       GlyphWiki-id
258                       GlyphWiki-id GlyphWiki-id)
259                    "")
260                  level))
261         ))
262       (if (> level 1)
263           (princ "<ul>"))
264       (when feature-name-to-edit
265         (princ "<form action=\"set.cgi\" method=\"GET\">\n")
266         (princ
267          (encode-coding-string
268           (format "<p>(%s : <input type=\"text\" name=\"%s\"
269 size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
270 "
271                   genre genre
272                   (decode-uri-string uri-object 'utf-8-mcs-er))
273           'utf-8-mcs-er)))
274       (setq object-spec
275             (cond
276              (uri-feature-name
277               (setq feature-name-to-display
278                     (www-uri-decode-feature-name uri-feature-name))
279               (setq est-eval-list-feature-items-limit nil)
280               (list
281                (cons feature-name-to-display
282                      (if (eq genre 'character)
283                          (get-char-attribute object feature-name-to-display)
284                        (concord-object-get object feature-name-to-display)))))
285              (t
286               (if (eq genre 'character)
287                   (char-attribute-alist object)
288                 (concord-object-spec object)))))
289       (when feature-name-to-edit
290         (unless (assq base-name-to-edit object-spec)
291           (setq object-spec (cons (cons base-name-to-edit nil)
292                                   object-spec))))
293       (dolist (cell (sort object-spec
294                           (lambda (a b)
295                             (char-attribute-name<
296                              (char-feature-name-sans-versions (car a))
297                              (char-feature-name-sans-versions (car b))))))
298         (setq logical-feature (char-feature-name-sans-versions (car cell)))
299         (unless (memq logical-feature chise-wiki-displayed-features)
300           (push logical-feature chise-wiki-displayed-features)
301           (cond
302            ((and feature-name-to-edit
303                  (eq (car cell) feature-name-to-edit))
304             (www-edit-display-feature-input-box
305              object feature-name-to-edit editing-format)
306             )
307            (t
308             (princ
309              (if (= level 1)
310                  "<div class=\"feature\" style=\"line-height:150%\">\n"
311                "<li>\n"))
312             (princ
313              (www-format-eval-list
314               (www-feature-format logical-feature)
315               object
316               logical-feature ; (car cell)
317               lang uri-object
318               nil simple))
319             (unless simple
320               (princ
321                (format " <a href=\"%s?%s=%s&feature=%s&format=wiki-text\"
322 ><input type=\"submit\" value=\"note\" /></a>"
323                        chise-wiki-edit-url
324                        genre
325                        (www-format-encode-string uri-object)
326                        (www-format-encode-string
327                         (www-uri-encode-feature-name
328                          (intern (format "%s*note"
329                                          logical-feature ; (car cell)
330                                          )))))))
331             (when (and feature-name-to-edit
332                        (eq base-name-to-edit (car cell)) metadata-name-to-edit)
333               (princ "<ul>\n")
334               (princ "<li>")
335               (www-edit-display-feature-input-box
336                object feature-name-to-edit editing-format)
337               (princ "</li>")
338               (princ "</ul>"))
339             (princ
340              (if (= level 1)
341                  "</div>\n"
342                "<li>\n"))
343             ))
344           ))
345       (princ
346        (if (= level 1)
347            "<p>\n"
348          "<li>\n"))
349       (when feature-name-to-edit
350         (princ "</form>\n"))
351       (unless simple
352         (princ
353          (format "<a href=\"%s?%s=%s\"
354 ><input type=\"submit\" value=\"add feature\" /></a>
355 "
356                  chise-wiki-add-url
357                  genre
358                  (www-format-encode-string uri-object))))
359       (princ
360        (if (= level 1)
361            "<p>\n"
362          "<li>\n"))
363       (when (eq genre 'character)
364         (princ
365          "<form action=\"http://www.chise.org/ids-find\">\n")
366         (princ
367          (www-format-encode-string
368           (est-format-object object)
369           ;; (if (eq genre 'character)
370           ;;     (format "%c" object)
371           ;;   (format "%s" (concord-object-id object)))
372           ))
373         (princ
374          (format
375           " <input type=\"text\" name=\"components\"
376 size=\"30\" maxlength=\"30\" value=\"%s\" />"
377           (encode-coding-string
378            (est-format-object object)
379            ;; (if (eq genre 'character)
380            ;;     (char-to-string object)
381            ;;   (format "%s" (concord-object-id object)))
382            'utf-8-jp-er)))
383         (princ
384          (www-format-encode-string
385           "を\u542Bむ\u6F22\u5B57を\u63A2す"))
386         (princ " <input type=\"submit\" value=\"search\" />\n")
387         (princ "</form>\n")
388
389         (princ
390          "<form action=\"http://www.chise.org/hng-ids-find\">\n")
391         (princ
392          (www-format-encode-string
393           (est-format-object object)
394           ;; (if (eq genre 'character)
395           ;;     (format "%c" object)
396           ;;   (format "%s" (concord-object-id object)))
397           ))
398         (princ
399          (format
400           " <input type=\"text\" name=\"components\"
401 size=\"30\" maxlength=\"30\" value=\"%s\" />"
402           (encode-coding-string
403            (est-format-object object)
404            ;; (if (eq genre 'character)
405            ;;     (char-to-string object)
406            ;;   (format "%s" (concord-object-id object)))
407            'utf-8-jp-er)))
408         (princ
409          (www-format-encode-string
410           "を\u542Bむ HNG の\u6F22\u5B57を\u63A2す"))
411         (princ " <input type=\"submit\" value=\"search\" />\n")
412         (princ "</form>\n")
413         )
414       (princ
415        (if (= level 1)
416            "</p>\n"
417          "<li>\n"))
418       )))
419
420 (defun www-display-feature-desc (uri-feature-name genre uri-object
421                                                   &optional lang simple)
422   (let ((rdf-uri-object (if est-hide-cgi-mode
423                             (if (string-match "=" uri-object)
424                                 (concat
425                                  (est-uri-decode-feature-name-body
426                                   (substring uri-object 0 (match-beginning 0)))
427                                  ":"
428                                  (est-uri-decode-feature-name-body
429                                   (substring uri-object (match-end 0))))
430                               uri-object)))
431         (feature-name (www-uri-decode-feature-name uri-feature-name))
432         (name@lang (intern (format "name@%s" lang))))
433     (princ
434      (encode-coding-string
435       (format "<head>
436 <title>EsT feature: %s</title>
437 </head>\n"
438               feature-name)
439       'utf-8-mcs-er))
440     (princ "<body>\n")
441     (princ
442      (if simple
443          (format
444           (if est-hide-cgi-mode
445               "<div style=\"text-align:right;\">
446 <a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
447 <input type=\"submit\" value=\"Edit\" />
448 </a>
449 <input type=\"submit\" value=\"New Account\" />
450 </div>
451 <hr />\n"
452             "<div style=\"text-align:right;\">
453 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
454 <input type=\"submit\" value=\"Edit\" />
455 </a>
456 <input type=\"submit\" value=\"New Account\" />
457 </div>
458 <hr />\n")
459           uri-feature-name genre rdf-uri-object)
460        (format
461         "<div style=\"text-align:right;\">
462 <a href=\"../view/feature/%s&%s/%s\">
463 <input type=\"submit\" value=\"Simple\" />
464 </a>
465 </div>
466 <hr />\n"
467         uri-feature-name genre uri-object)))
468     (princ
469      (format "<h1>%s</h1>\n"
470              (www-format-encode-string
471               (symbol-name feature-name))))
472     (princ (format "<p>name : %s "
473                    (or (www-format-feature-name feature-name) "")))
474     (unless simple
475       (princ
476        (format
477         " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
478         chise-wiki-edit-url
479         uri-feature-name
480         genre
481         uri-object))
482       (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
483     (princ "</p>\n")
484     (when lang
485       (princ "<p>")
486       (princ
487        (www-format-encode-string
488         (format "%s : %s"
489                 name@lang
490                 (or (char-feature-property feature-name name@lang) ""))))
491       (unless simple
492         (princ
493          (format
494           " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
495           chise-wiki-edit-url
496           uri-feature-name
497           name@lang
498           genre
499           uri-object))
500         (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
501       (princ "</p>\n"))
502     (www-html-display-paragraph
503      (format "type : %s"
504              (or (www-feature-type feature-name)
505                  ;; (char-feature-property feature-name 'type)
506                  'generic)))
507     (princ (format "<p>value-format : %s "
508                    (www-format-value
509                     nil 'value-format 
510                     (or (www-feature-value-format feature-name)
511                         'default)
512                     'default
513                     'without-tags)
514                    ))
515     (unless simple
516       (princ
517        (format
518         " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
519 >"
520         chise-wiki-edit-url
521         uri-feature-name
522         genre
523         uri-object))
524       (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
525     (princ "</p>\n")
526
527     (princ (format "<p>value-presentation-format : %s "
528                    (www-format-value
529                     nil 'value-presentation-format 
530                     (or (www-feature-value-format feature-name)
531                         'default)
532                     'default
533                     'without-tags)
534                    ))
535     (unless simple
536       (princ
537        (format
538         " <a href=\"%s?feature=%s&property=value-presentation-format&format=wiki-text&%s=%s\"
539 >"
540         chise-wiki-edit-url
541         uri-feature-name
542         genre
543         uri-object))
544       (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
545     (princ "</p>\n")
546
547     (princ "<p>format : ")
548     (www-html-display-text
549      (decode-coding-string
550       (www-xml-format-list
551        (www-feature-format feature-name))
552       'utf-8-mcs-er))
553     (unless simple
554       (princ
555        (format
556         " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
557 >"
558         chise-wiki-edit-url
559         uri-feature-name
560         genre
561         uri-object))
562       (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
563     (princ "</p>\n")
564     
565     (www-html-display-paragraph
566      (format "description : %s"
567              (or (decode-coding-string
568                   (char-feature-property feature-name 'description)
569                   'utf-8-mcs-er)
570                  "")))
571     (when lang
572       (www-html-display-paragraph
573        (format "description@%s : %s"
574                lang
575                (or (char-feature-property
576                     feature-name
577                     (intern (format "description@%s" lang)))
578                    ""))))
579     ))
580   
581 (defun www-batch-view ()
582   (setq terminal-coding-system 'binary)
583   (condition-case err
584       (let* ((target (pop command-line-args-left))
585              (user (pop command-line-args-left))
586              (accept-language (pop command-line-args-left))
587              (mode (intern (pop command-line-args-left)))
588              (lang
589               (intern
590                (car (split-string
591                      (car (split-string
592                            (car (split-string accept-language ","))
593                            ";"))
594                      "-"))))
595              ret genre)
596         (princ "Content-Type: text/html; charset=UTF-8
597
598 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
599             \"http://www.w3.org/TR/html4/loose.dtd\">
600 <html lang=\"ja\">
601 ")
602         (cond
603          ((stringp target)
604           (when (string-match "^char=\\(&[^&;]+;\\)" target)
605             (setq ret (match-end 0))
606             (setq target
607                   (concat "char="
608                           (www-uri-encode-object
609                            (www-uri-decode-object
610                             'character (match-string 1 target)))
611                           (substring target ret))))
612           (setq target
613                 (mapcar (lambda (cell)
614                           (if (string-match "=" cell)
615                               (progn
616                                 (setq genre (substring cell 0 (match-beginning 0))
617                                       ret (substring cell (match-end 0)))
618                                 (cons
619                                  (intern
620                                   (decode-uri-string genre 'utf-8-mcs-er))
621                                  ret))
622                             (list (decode-uri-string cell 'utf-8-mcs-er))))
623                         (split-string target "&")))
624           (setq ret (car target))
625           (cond ((eq (car ret) 'char)
626                  (www-display-object-desc
627                   'character (cdr ret) (cdr (assq 'feature target))
628                   nil
629                   lang nil
630                   (eq mode 'simple))
631                  )
632                 ((eq (car ret) 'feature)
633                  (www-display-feature-desc
634                   (decode-uri-string (cdr ret) 'utf-8-mcs-er)
635                   (car (nth 1 target))
636                   (cdr (nth 1 target))
637                   lang
638                   (eq mode 'simple))
639                  )
640                 (t
641                  (www-display-object-desc
642                   (car ret) (cdr ret) (cdr (assq 'feature target))
643                   nil
644                   lang nil
645                   (eq mode 'simple))
646                  ))
647           ))
648         (princ "\n<hr>\n")
649         (princ (format "mode=%S\n" mode))
650         (princ (format "user=%s\n" user))
651         ;; (princ (format "local user=%s\n" (user-login-name)))
652         (princ (format "lang=%S\n" lang))
653         (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
654         ;; (princ " CHISE ")
655         ;; (princ xemacs-chise-version)
656         (princ "
657 </body>
658 </html>")
659         )
660     (error nil
661            (princ (format "%S" err)))
662     ))
663
664 (defun www-batch-view-smart ()
665   (setq debug-on-error t)
666   (setq terminal-coding-system 'binary)
667   (condition-case err
668       (let* ((est-hide-cgi-mode t)
669              (target (pop command-line-args-left))
670              (user (pop command-line-args-left))
671              (accept-language (pop command-line-args-left))
672              (mode (intern (pop command-line-args-left)))
673              (lang
674               (intern
675                (car (split-string
676                      (car (split-string
677                            (car (split-string accept-language ","))
678                            ";"))
679                      "-"))))
680              ret genre feature obj-url json obj)
681         (cond
682          ((stringp target)
683           (when (string-match "/data\\.json$" target)
684             (setq json t
685                   target (substring target 0 (match-beginning 0))))
686           (when (string-match "^char/\\(&[^&;]+;\\)" target)
687             (setq ret (match-end 0))
688             (setq target
689                   (concat "char/"
690                           (www-uri-encode-object
691                            (www-uri-decode-object
692                             'character (match-string 1 target)))
693                           (substring target ret))))
694           (setq target
695                 (mapcar
696                  (lambda (cell)
697                    (if (string-match "/" cell)
698                        (progn
699                          (setq genre (substring cell 0 (match-beginning 0))
700                                ret (substring cell (match-end 0)))
701                          (cons
702                           (intern (decode-uri-string genre 'utf-8-mcs-er))
703                           (if (string-match "/feature=" ret)
704                               (list (substring ret 0 (match-beginning 0))
705                                     (substring ret (match-end 0)))
706                             (list ret))))
707                      (list (decode-uri-string cell 'utf-8-mcs-er)))
708                    ;; (setq ret (split-string cell "/"))
709                    ;; (cons (intern
710                    ;;        (decode-uri-string (car ret) 'utf-8-mcs-er))
711                    ;;       (cdr ret))
712                    )
713                  (split-string target "&")))
714           (setq ret (car target))
715           (if json
716               (princ "Content-Type: application/json; charset=UTF-8
717
718 ")
719             (princ "Content-Type: text/html; charset=UTF-8
720
721 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
722             \"http://www.w3.org/TR/html4/loose.dtd\">
723 <html lang=\"ja\">
724 ")
725             )
726           ;; (princ (format "<p>%S, %S, %S</p>"
727           ;;                (car ret)(nth 1 ret)(nth 2 ret)))
728           ;; (princ (format "// %S %S\n" ret json))
729           (cond ((or (eq (car ret) 'char)
730                      (eq (car ret) 'character))
731                  (if (and json
732                           (setq obj (www-uri-decode-object
733                                      (car ret)(nth 1 ret)))
734                           (characterp obj))
735                      (with-temp-buffer
736                        ;; (princ (encode-coding-string
737                        ;;         (format "// %S\n" obj)
738                        ;;         char-db-file-coding-system))
739                        (char-db-json-char-data-with-variant obj 'printable)
740                        (encode-coding-region
741                         (point-min)(point-max)
742                         char-db-file-coding-system)
743                        (princ (buffer-string))
744                        )
745                    (www-display-object-desc
746                     'character (nth 1 ret) (nth 2 ret)
747                     nil
748                     lang nil
749                     (eq mode 'simple)))
750                  )
751                 ((eq (car ret) 'feature)
752                  (www-display-feature-desc
753                   (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
754                   (car (nth 1 target))
755                   (nth 1 (nth 1 target))
756                   lang
757                   (eq mode 'simple))
758                  )
759                 ;; ((eq (car ret) 'image-resource)
760                 ;; ;;  (cond
761                 ;; ;;   ((string-match "^\\.iiif=" (nth 1 ret))
762                 ;; ;;    (setq obj-url (decode-uri-string
763                 ;; ;;                   (substring (nth 1 ret) (match-end 0))
764                 ;; ;;                   'utf-8-mcs-er))
765                 ;; ;;    (setq obj (concord-images-add-iiif obj-url))
766                 ;; ;;    (www-display-object-desc
767                 ;; ;;     'image-resource
768                 ;; ;;     (www-uri-encode-object obj)
769                 ;; ;;     (nth 2 ret)
770                 ;; ;;     lang nil
771                 ;; ;;     (eq mode 'simple))
772                 ;; ;;    )
773                 ;; ;;   (t
774                 ;;  (princ (nth 1 ret))
775                 ;;  (www-display-object-desc
776                 ;;   'image-resource (nth 1 ret) (nth 2 ret)
777                 ;;   lang nil
778                 ;;   (eq mode 'simple))
779                 ;; ;;    ))
780                 ;;  )
781                 (t
782                  (www-display-object-desc
783                   (car ret) (nth 1 ret) (nth 2 ret)
784                   nil
785                   lang nil
786                   (eq mode 'simple))
787                  ))
788           ))
789         (unless json
790           (princ "\n<hr>\n")
791           (princ (format "mode=%S\n" mode))
792           (princ (format "user=%s\n" user))
793           ;; (princ (format "local user=%s\n" (user-login-name)))
794           (princ (format "lang=%S\n" lang))
795           (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
796           ;; (princ " CHISE ")
797           ;; (princ xemacs-chise-version)
798           (princ "
799 </body>
800 </html>")
801           )
802         )
803     (error nil
804            (princ (format "%S" err)))
805     ))
806
807 (provide 'cwiki-view)