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-char-display-feature-default (char feature-name &optional value
11 (setq value (char-feature char feature-name)))
13 (setq uri-char (char-to-string char)))
14 (www-html-display-paragraph
15 (format "[[%s|%?feature=%s&char=%s]] : %s [[[edit|%s?char=%s&feature=%s]]]"
16 (www-format-feature-name feature-name lang)
18 (www-uri-encode-feature-name feature-name)
20 (www-format-value value feature-name)
23 (www-uri-encode-feature-name feature-name)
26 (defun www-char-display-feature-as-ucs (char feature-name &optional value)
28 (setq value (char-feature char feature-name)))
29 (www-html-display-paragraph
30 (format "= [[U+%s|http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=%s]] (%d)"
31 (www-format-value-as-HEX value)
32 (www-format-value-as-HEX value)
35 (defun www-display-char-desc (uri-char &optional lang level)
38 (let ((char (www-uri-decode-char uri-char)))
39 (when (characterp char)
40 (when (= (length uri-char) 1)
41 (setq uri-char (www-uri-encode-char char)))
46 <title>CHISE-wiki character: %s</title>
48 (decode-uri-string uri-char 'utf-8-mcs-er))
51 (princ (format "<h%d>%s</h%d>\n"
53 (www-format-encode-string (char-to-string char))
57 (dolist (cell (sort (char-attribute-alist char)
59 (char-attribute-name< (car a)(car b)))))
66 (or (char-feature-property (car cell) 'format)
67 '((name) " : " (value)))
68 char (car cell) lang uri-char))
70 (format " <a href=\"%s?char=%s&feature=%s\"
71 ><input type=\"submit\" value=\"note\" /></a>"
73 (www-format-encode-string uri-char)
74 (www-format-encode-string
75 (www-uri-encode-feature-name
76 (intern (format "%s*note" (car cell)))))))
87 (format "<a href=\"%s?char=%s\"
88 ><input type=\"submit\" value=\"add feature\" /></a>
91 (www-format-encode-string uri-char)))
98 (defun www-display-feature-desc (uri-feature-name uri-char &optional lang)
99 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
100 (name@lang (intern (format "name@%s" lang))))
102 (encode-coding-string
104 <title>CHISE-wiki feature: %s</title>
110 (format "<h1>%s</h1>\n"
111 (www-format-encode-string
112 (symbol-name feature-name))))
113 (princ (format "<p>name : %s "
114 (or (www-format-feature-name feature-name) "")))
115 (www-html-display-text
116 (format "[[[edit|%s?feature=%s&property=name&char=%s]]]"
117 ;; (char-feature-property feature-name 'name)
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) ""))))
129 (www-html-display-text
130 (format " [[[edit|%s?feature=%s&property=%s&char=%s]]]"
136 (www-html-display-paragraph
138 (or (www-feature-type feature-name)
139 ;; (char-feature-property feature-name 'type)
141 (www-html-display-paragraph
142 (format "description : %s"
143 (or (char-feature-property feature-name 'description)
146 (www-html-display-paragraph
147 (format "description@%s : %s"
149 (or (char-feature-property
151 (intern (format "description@%s" lang)))
155 (defun www-batch-view ()
156 (setq terminal-coding-system 'binary)
158 (let* ((target (pop command-line-args-left))
159 (user (pop command-line-args-left))
160 (accept-language (pop command-line-args-left))
165 (car (split-string accept-language ","))
169 (princ "Content-Type: text/html; charset=UTF-8
171 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
172 \"http://www.w3.org/TR/html4/loose.dtd\">
178 (mapcar (lambda (cell)
179 (if (string-match "=" cell)
183 (substring cell 0 (match-beginning 0))
185 (substring cell (match-end 0)))
186 (list (decode-uri-string cell 'utf-8-mcs-er))))
187 (split-string target "&")))
188 (setq ret (car target))
189 (cond ((eq (car ret) 'char)
190 (www-display-char-desc
191 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
194 ((eq (car ret) 'feature)
195 (www-display-feature-desc
196 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
197 (cdr (assq 'char target))
198 ;; (decode-uri-string (cdr (assq 'char target)))
203 (princ (format "user=%s\n" user))
204 (princ (format "local user=%s\n" (user-login-name)))
205 (princ (format "lang=%S\n" lang))
206 (princ emacs-version)
208 (princ xemacs-chise-version)
214 (princ (format "%S" err)))
217 (provide 'cwiki-view)