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 (www-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 (www-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 logical-feature displayed-features)
40 (when (characterp char)
41 (when (= (length uri-char) 1)
42 (setq uri-char (www-uri-encode-char char)))
47 <title>CHISE-wiki character: %s</title>
49 (decode-uri-string uri-char 'utf-8-mcs-er))
52 (princ (format "<h%d>%s</h%d>\n"
54 (www-format-encode-string (char-to-string char))
58 (dolist (cell (sort (char-attribute-alist char)
60 (char-attribute-name< (car a)(car b)))))
61 (setq logical-feature (char-feature-name-sans-versions (car cell)))
62 (unless (memq logical-feature displayed-features)
63 (push logical-feature displayed-features)
70 (or (char-feature-property logical-feature ; (car cell)
72 '((name) " : " (value)))
74 logical-feature ; (car cell)
77 (format " <a href=\"%s?char=%s&feature=%s&format=wiki-text\"
78 ><input type=\"submit\" value=\"note\" /></a>"
80 (www-format-encode-string uri-char)
81 (www-format-encode-string
82 (www-uri-encode-feature-name
83 (intern (format "%s*note"
84 logical-feature ; (car cell)
96 (format "<a href=\"%s?char=%s\"
97 ><input type=\"submit\" value=\"add feature\" /></a>
100 (www-format-encode-string uri-char)))
107 (defun www-display-feature-desc (uri-feature-name uri-char &optional lang)
108 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
109 (name@lang (intern (format "name@%s" lang))))
111 (encode-coding-string
113 <title>CHISE-wiki feature: %s</title>
119 (format "<h1>%s</h1>\n"
120 (www-format-encode-string
121 (symbol-name feature-name))))
122 (princ (format "<p>name : %s "
123 (or (www-format-feature-name feature-name) "")))
124 (www-html-display-text
125 (format "[[[edit|%s?feature=%s&property=name&char=%s]]]"
126 ;; (char-feature-property feature-name 'name)
128 uri-feature-name ; (www-uri-encode-feature-name feature-name)
134 (www-format-encode-string
137 (or (char-feature-property feature-name name@lang) ""))))
138 (www-html-display-text
139 (format " [[[edit|%s?feature=%s&property=%s&char=%s]]]"
145 (www-html-display-paragraph
147 (or (www-feature-type feature-name)
148 ;; (char-feature-property feature-name 'type)
150 (www-html-display-paragraph
151 (format "description : %s"
152 (or (char-feature-property feature-name 'description)
155 (www-html-display-paragraph
156 (format "description@%s : %s"
158 (or (char-feature-property
160 (intern (format "description@%s" lang)))
164 (defun www-batch-view ()
165 (setq terminal-coding-system 'binary)
167 (let* ((target (pop command-line-args-left))
168 (user (pop command-line-args-left))
169 (accept-language (pop command-line-args-left))
174 (car (split-string accept-language ","))
178 (princ "Content-Type: text/html; charset=UTF-8
180 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
181 \"http://www.w3.org/TR/html4/loose.dtd\">
187 (mapcar (lambda (cell)
188 (if (string-match "=" cell)
192 (substring cell 0 (match-beginning 0))
194 (substring cell (match-end 0)))
195 (list (decode-uri-string cell 'utf-8-mcs-er))))
196 (split-string target "&")))
197 (setq ret (car target))
198 (cond ((eq (car ret) 'char)
199 (www-display-char-desc
200 (cdr ret) ; (decode-uri-string (cdr ret) 'utf-8-mcs-er)
203 ((eq (car ret) 'feature)
204 (www-display-feature-desc
205 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
206 (cdr (assq 'char target))
207 ;; (decode-uri-string (cdr (assq 'char target)))
212 (princ (format "user=%s\n" user))
213 (princ (format "local user=%s\n" (user-login-name)))
214 (princ (format "lang=%S\n" lang))
215 (princ emacs-version)
217 (princ xemacs-chise-version)
223 (princ (format "%S" err)))
226 (provide 'cwiki-view)