New file.
authorMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Mon, 13 Sep 2010 07:46:49 +0000 (16:46 +0900)
committerMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Mon, 13 Sep 2010 07:46:49 +0000 (16:46 +0900)
cwiki-add.el [new file with mode: 0644]

diff --git a/cwiki-add.el b/cwiki-add.el
new file mode 100644 (file)
index 0000000..554d048
--- /dev/null
@@ -0,0 +1,129 @@
+;; -*- coding: utf-8-mcs-er -*-
+(defvar chise-wiki-view-url "view.cgi")
+(defvar chise-wiki-edit-url "edit.cgi")
+
+(require 'cwiki-common)
+
+(defun www-add-display-feature-input-box (char &optional format)
+  (unless format
+    (setq format 'default))
+  (princ
+   "<p><input type=\"text\" name=\"feature-name\"
+size=\"32\" maxlength=\"256\" value=\"\">")
+  (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
+  (princ
+   (format "%s<input type=\"text\" name=\"%s\"
+size=\"64\" maxlength=\"256\" value=\"\">
+<input type=\"submit\" value=\"set\" /></p>
+"
+          (if (or (eq format 'HEX)(eq format 'hex))
+              "0x"
+            "")
+          format))
+  )
+
+(defun www-add-display-char-desc (uri-char &optional lang format)
+  (when (stringp format)
+    (setq format (intern format)))
+  (let ((char (www-uri-decode-char uri-char))
+       char-spec)
+    (when (characterp char)
+      (princ
+       (format "<head>
+<title>CHISE-wiki character: %s</title>
+</head>\n"
+              (encode-coding-string
+               (decode-uri-string uri-char 'utf-8-mcs-er)
+               'utf-8-mcs-er)))
+      (princ "<body>\n")
+      (princ
+       (format "<h1>%s</h1>\n"
+              (www-format-encode-string (char-to-string char))))
+      (princ "<form action=\"set.cgi\" method=\"GET\">\n")
+      (princ
+       (encode-coding-string
+       (format "<p>(char : <input type=\"text\" name=\"char\"
+size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
+"
+               (decode-uri-string uri-char 'utf-8-mcs-er))
+       'utf-8-mcs-er))
+      (www-add-display-feature-input-box char format)
+      (setq char-spec (char-attribute-alist char))
+      (dolist (cell (sort char-spec
+                         (lambda (a b)
+                           (char-attribute-name< (car a)(car b)))))
+       (princ "<p>")
+       (princ
+        (www-format-eval-list
+         (or (char-feature-property (car cell) 'format)
+             '((name) " : " (value)))
+         char (car cell) lang uri-char))
+       (princ "</p>\n"))
+      (princ "</form>\n")
+      )))
+  
+(defun www-batch-add ()
+  (setq terminal-coding-system 'binary)
+  (condition-case err
+      (let* ((target (pop command-line-args-left))
+            (user (pop command-line-args-left))
+            (accept-language (pop command-line-args-left))
+            (lang
+             (intern (car (split-string
+                           (car (split-string
+                                 (car (split-string accept-language ","))
+                                 ";"))
+                           "-"))))
+            ret)
+       (princ "Content-Type: text/html; charset=UTF-8
+
+<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
+            \"http://www.w3.org/TR/html4/loose.dtd\">
+<html lang=\"ja\">
+")
+       (setq target
+             (mapcar (lambda (cell)
+                       (if (string-match "=" cell)
+                           (cons
+                            (intern
+                             (decode-uri-string
+                              (substring cell 0 (match-beginning 0))
+                              'utf-8-mcs-er))
+                            (substring cell (match-end 0)))
+                         (list (decode-uri-string cell 'utf-8-mcs-er))))
+                     (split-string target "&")))
+       (setq ret (car target))
+       (cond ((eq (car ret) 'char)
+              (www-add-display-char-desc
+                (cdr ret)
+               lang
+               (decode-uri-string (cdr (assq 'format target))
+                                  'utf-8-mcs-er))
+              )
+              ;; ((eq (car ret) 'feature)
+              ;;  (www-add-display-feature-desc
+              ;;   (decode-uri-string (cdr ret) 'utf-8-mcs-er)
+              ;;   (decode-uri-string (cdr (assq 'property target))
+              ;;                      'utf-8-mcs-er)
+              ;;   lang
+              ;;   (cdr (assq 'char target))
+              ;;   ;; (decode-uri-string (cdr (assq 'char target))
+              ;;   ;;                    'utf-8-mcs-er)
+              ;;   ))
+             )
+       (www-html-display-paragraph
+        (format "%S" target))
+       (princ "\n<hr>\n")
+       (princ (format "user=%s\n" user))
+       (princ (format "local user=%s\n" (user-login-name)))
+       (princ (format "lang=%S\n" lang))
+       (princ emacs-version)
+       (princ " CHISE ")
+       (princ xemacs-chise-version)
+       (princ "
+</body>
+</html>")
+       )
+    (error nil
+          (princ (format "%S" err)))
+    ))