1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-common)
4 (defvar chise-wiki-view-url "view.cgi")
5 (defvar chise-wiki-edit-url "edit/edit.cgi")
6 (defvar chise-wiki-add-url "edit/add.cgi")
8 (defun www-display-char-desc (uri-char &optional lang level)
11 (let ((char (www-uri-decode-char uri-char))
12 logical-feature displayed-features
14 (when (characterp char)
15 (when (= (length uri-char) 1)
16 (setq uri-char (www-uri-encode-char char)))
21 <title>CHISE-wiki character: %s</title>
23 (decode-uri-string uri-char 'utf-8-mcs-er))
26 (dolist (feature (char-feature-property '$object 'additional-features))
27 (mount-char-attribute-table
28 (char-feature-name-at-domain feature '$rev=latest)))
29 (when (setq parents (www-char-feature char '<-denotational))
30 (princ (format "<p>%s %s</p>\n<hr>\n"
31 (www-format-value-as-char-list parents)
32 (www-format-feature-name '->denotational lang))))
33 (when (setq parents (www-char-feature char '<-subsumptive))
34 (princ (format "<p>%s %s</p>\n<hr>\n"
35 (www-format-value-as-char-list parents)
36 (www-format-feature-name '->subsumptive lang))))
37 (princ (format "<h%d>%s</h%d>\n"
39 (www-format-encode-string (char-to-string char))
43 (dolist (cell (sort (char-attribute-alist char)
45 (char-attribute-name< (car a)(car b)))))
46 (setq logical-feature (char-feature-name-sans-versions (car cell)))
47 (unless (memq logical-feature displayed-features)
48 (push logical-feature displayed-features)
55 (or (char-feature-property logical-feature ; (car cell)
57 '((name) " : " (value)))
59 logical-feature ; (car cell)
62 (format " <a href=\"%s?char=%s&feature=%s&format=wiki-text\"
63 ><input type=\"submit\" value=\"note\" /></a>"
65 (www-format-encode-string uri-char)
66 (www-format-encode-string
67 (www-uri-encode-feature-name
68 (intern (format "%s*note"
69 logical-feature ; (car cell)
81 (format "<a href=\"%s?char=%s\"
82 ><input type=\"submit\" value=\"add feature\" /></a>
85 (www-format-encode-string uri-char)))
92 (defun www-display-feature-desc (uri-feature-name uri-char &optional lang)
93 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
94 (name@lang (intern (format "name@%s" lang))))
98 <title>CHISE-wiki feature: %s</title>
104 (format "<h1>%s</h1>\n"
105 (www-format-encode-string
106 (symbol-name feature-name))))
107 (princ (format "<p>name : %s "
108 (or (www-format-feature-name feature-name) "")))
110 (format " <a href=\"%s?feature=%s&property=name&format=string&char=%s\"
111 ><input type=\"submit\" value=\"edit\" /></a>"
115 ;; (www-html-display-text
116 ;; (format "[[[edit|%s?feature=%s&property=name&char=%s]]]"
117 ;; ;; (char-feature-property feature-name 'name)
118 ;; chise-wiki-edit-url
119 ;; uri-feature-name ; (www-uri-encode-feature-name feature-name)
125 (www-format-encode-string
128 (or (char-feature-property feature-name name@lang) ""))))
130 (format " <a href=\"%s?feature=%s&property=%s&format=string&char=%s\"
131 ><input type=\"submit\" value=\"edit\" /></a>"
136 ;; (www-html-display-text
137 ;; (format " [[[edit|%s?feature=%s&property=%s&char=%s]]]"
138 ;; chise-wiki-edit-url
143 (www-html-display-paragraph
145 (or (www-feature-type feature-name)
146 ;; (char-feature-property feature-name 'type)
148 (princ (format "<p>value-format : %s "
151 (or (www-feature-value-format feature-name)
155 ;; (www-html-display-paragraph
156 ;; (format "value-format : %s"
157 ;; (www-xml-format-list
158 ;; (or (www-feature-value-format feature-name)
162 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&char=%s\"
163 ><input type=\"submit\" value=\"edit\" /></a></p>"
168 (www-html-display-paragraph
169 (format "format : %s"
171 (or (char-feature-property feature-name 'format)
172 '((name) " : " (value))))))
173 (www-html-display-paragraph
174 (format "description : %s"
175 (or (char-feature-property feature-name 'description)
178 (www-html-display-paragraph
179 (format "description@%s : %s"
181 (or (char-feature-property
183 (intern (format "description@%s" lang)))
187 (defun www-batch-view ()
188 (setq terminal-coding-system 'binary)
190 (let* ((target (pop command-line-args-left))
191 (user (pop command-line-args-left))
192 (accept-language (pop command-line-args-left))
197 (car (split-string accept-language ","))
201 (princ "Content-Type: text/html; charset=UTF-8
203 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
204 \"http://www.w3.org/TR/html4/loose.dtd\">
210 (mapcar (lambda (cell)
211 (if (string-match "=" cell)
215 (substring cell 0 (match-beginning 0))
217 (substring cell (match-end 0)))
218 (list (decode-uri-string cell 'utf-8-mcs-er))))
219 (split-string target "&")))
220 (setq ret (car target))
221 (cond ((eq (car ret) 'char)
222 (www-display-char-desc
223 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
226 ((eq (car ret) 'feature)
227 (www-display-feature-desc
228 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
229 (cdr (assq 'char target))
230 ;; (decode-uri-string (cdr (assq 'char target)))
235 (princ (format "user=%s\n" user))
236 (princ (format "local user=%s\n" (user-login-name)))
237 (princ (format "lang=%S\n" lang))
238 (princ emacs-version)
240 (princ xemacs-chise-version)
246 (princ (format "%S" err)))
249 (provide 'cwiki-view)