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 est-rdf-encode-feature-name (feature-name)
9 (let ((str (symbol-name feature-name))
12 (if (string-match "@" str)
13 (setq base (substring str 0 (match-beginning 0))
14 domain (substring str (match-end 0)))
16 (setq ret (mapconcat (lambda (c)
21 (t (char-to-string c))))
23 (if (eq (aref ret 0) ?.)
24 (setq ret (concat "meta" ret)))
28 (split-string domain "/")
31 (www-uri-encode-feature-name (intern ret)))))
33 (defun est-rdf-format-object (obj)
34 (if (or (characterp obj)
35 (concord-object-p obj))
36 (let ((genre (est-object-genre obj))
37 (url-object (www-uri-encode-object obj)))
40 rdf:about=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
43 (encode-coding-string (format "
47 (defun est-rdf-format-object-list (obj-list &optional with-li)
48 ;; (concat (mapconcat #'est-rdf-format-object
57 (setq dest (concat dest
60 (est-rdf-format-object obj)
63 (setq dest (concat dest (est-rdf-format-object obj)))))
65 (setq dest (concat dest (est-rdf-format-object rest))))
68 (defun est-rdf-display-object-desc (genre uri-object &optional lang level)
71 (let ((object (www-uri-decode-object genre uri-object))
72 logical-feature chise-wiki-displayed-features
74 rdf-feature-name rdf-feature-name-space
75 feature-type rdf-container
80 (when (and (eq genre 'character)
81 (= (length uri-object) 1))
82 (setq uri-object (www-uri-encode-object object)))
83 (when (eq genre 'character)
84 (dolist (feature (char-feature-property '$object 'additional-features))
85 (mount-char-attribute-table
86 (char-feature-name-at-domain feature '$rev=latest))))
88 (if (eq genre 'character)
89 (char-attribute-alist object)
90 (concord-object-spec object)))
92 (format "<rdf:Description
93 rdf:about=\"http://www.chise.org/est/rdf.cgi/%s=%s\">\n"
95 (dolist (cell (sort object-spec
98 (char-feature-name-sans-versions (car a))
99 (char-feature-name-sans-versions (car b))))))
100 (setq logical-feature (char-feature-name-sans-versions (car cell)))
101 (unless (memq logical-feature chise-wiki-displayed-features)
102 (push logical-feature chise-wiki-displayed-features)
103 (setq value (www-get-feature-value object logical-feature))
104 (setq ret (est-rdf-encode-feature-name logical-feature))
105 (setq rdf-feature-name (format "%s:%s" (car ret)(cdr ret)))
106 (setq rdf-feature-name-space
107 (format "xmlns:%s=\"http://www.chise.org/est/rdf.cgi?domain=%s/\""
110 (setq feature-type (www-feature-type logical-feature))
111 (if (and (consp value)
114 ((eq feature-type 'structure)
115 (setq rdf-container "rdf:Seq")
117 ;; ((eq feature-type 'relation)
118 ;; (setq rdf-container "rdf:Bag")
121 (setq rdf-container "rdf:Bag")
123 (setq rdf-container nil))
125 (format " <%s\n %s>%s%s%s</%s>\n"
127 rdf-feature-name-space
129 (format "\n <%s>" rdf-container)
131 (est-rdf-format-object-list value rdf-container)
133 (format "</%s>\n " rdf-container)
137 (princ "</rdf:Description>")
140 (defun est-rdf-display-feature-desc (uri-feature-name genre uri-object
141 &optional lang simple)
142 (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
143 (name@lang (intern (format "name@%s" lang))))
145 (encode-coding-string
147 <title>EsT feature: %s</title>
155 "<div style=\"text-align:right;\">
156 <a href=\"edit/view.cgi?feature=%s&%s=%s\">
157 <input type=\"submit\" value=\"Edit\" />
159 <input type=\"submit\" value=\"New Account\" />
162 "<div style=\"text-align:right;\">
163 <a href=\"../view.cgi?feature=%s&%s=%s\">
164 <input type=\"submit\" value=\"Simple\" />
168 uri-feature-name genre uri-object))
170 (format "<h1>%s</h1>\n"
171 (www-format-encode-string
172 (symbol-name feature-name))))
173 (princ (format "<p>name : %s "
174 (or (www-format-feature-name feature-name) "")))
178 " <a href=\"%s?feature=%s&property=name&format=string&%s=%s\">"
183 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
188 (www-format-encode-string
191 (or (char-feature-property feature-name name@lang) ""))))
195 " <a href=\"%s?feature=%s&property=%s&format=string&%s=%s\">"
201 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
203 (www-html-display-paragraph
205 (or (www-feature-type feature-name)
206 ;; (char-feature-property feature-name 'type)
208 (princ (format "<p>value-format : %s "
211 (or (www-feature-value-format feature-name)
219 " <a href=\"%s?feature=%s&property=value-format&format=wiki-text&%s=%s\"
225 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
228 (princ "<p>format : ")
229 (www-html-display-text
230 (decode-coding-string
232 (www-feature-format feature-name))
237 " <a href=\"%s?feature=%s&property=format&format=wiki-text&%s=%s\"
243 (princ "<input type=\"submit\" value=\"edit\" /></a>\n"))
246 (www-html-display-paragraph
247 (format "description : %s"
248 (or (char-feature-property feature-name 'description)
251 (www-html-display-paragraph
252 (format "description@%s : %s"
254 (or (char-feature-property
256 (intern (format "description@%s" lang)))
260 (defun est-rdf-batch-view ()
261 (setq terminal-coding-system 'binary)
263 (let* ((target (pop command-line-args-left))
264 (user (pop command-line-args-left))
265 (accept-language (pop command-line-args-left))
266 (mode (intern (pop command-line-args-left)))
271 (car (split-string accept-language ","))
275 (princ "Content-Type: application/xml
277 <?xml version=\"1.0\" encoding=\"UTF-8\" ?>
279 xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
280 xmlns:dc=\"http://purl.org/dc/elements/1.1/\">
284 (when (string-match "^char=\\(&[^&;]+;\\)" target)
285 (setq ret (match-end 0))
288 (www-uri-encode-object
289 (www-uri-decode-object
290 'character (match-string 1 target)))
291 (substring target ret))))
293 (mapcar (lambda (cell)
294 (if (string-match "=" cell)
296 (setq genre (substring cell 0 (match-beginning 0))
297 ret (substring cell (match-end 0)))
300 (decode-uri-string genre 'utf-8-mcs-er))
302 (list (decode-uri-string cell 'utf-8-mcs-er))))
303 (split-string target "&")))
304 (setq ret (car target))
305 (cond ((eq (car ret) 'char)
306 (est-rdf-display-object-desc
311 ((eq (car ret) 'feature)
312 (est-rdf-display-feature-desc
313 (decode-uri-string (cdr ret) 'utf-8-mcs-er)
320 (est-rdf-display-object-desc
330 (princ (format "%S" err)))
333 (provide 'cwiki-view)