update.
[chise/est.git] / cwiki-edit.el
index aa0007c..0c9a07b 100644 (file)
 (defvar chise-wiki-view-url "view.cgi")
 (defvar chise-wiki-edit-url "edit.cgi")
 
-(require 'cwiki-common)
-(require 'est-xml)
+;; (require 'cwiki-format)
+(require 'cwiki-view)
 
-(defun www-edit-display-input-box (object name value &optional format)
-  (when (stringp format)
-    (setq format (intern format)))
-  (let (prefix)
-    (if (or (eq format 'HEX)
-           (eq format 'hex))
-       (if (integerp value)
-           (setq prefix "0x")))
-    (princ (www-format-encode-string
-           (format "%s \u2190 %s"
-                   name
-                   (or prefix ""))))
-    (princ
-     (format "<input type=\"text\" name=\"%s\"
-size=\"30\" maxlength=\"30\" value=\"%s\">
-<input type=\"submit\" value=\"set\" />
+;; (defun www-edit-display-input-box (object name value &optional format)
+;;   (when (stringp format)
+;;     (setq format (intern format)))
+;;   (let (prefix)
+;;     (if (or (eq format 'HEX)
+;;             (eq format 'hex))
+;;         (if (integerp value)
+;;             (setq prefix "0x")))
+;;     (princ (www-format-encode-string
+;;             (format "%s \u2190 %s"
+;;                     name
+;;                     (or prefix ""))))
+;;     (princ
+;;      (format "<input type=\"text\" name=\"%s\"
+;; size=\"30\" maxlength=\"30\" value=\"%s\">
+;; <input type=\"submit\" value=\"set\" />
+;; 
+;; "
+;;              (www-format-encode-string
+;;               (format "%s" name) 'without-tags)
+;;              (www-format-apply-value object name
+;;                                      format nil value
+;;                                      nil nil
+;;                                      'without-tags)
+;;              ))))
 
-"
-            (www-format-encode-string
-             (format "%s" name) 'without-tags)
-             (www-format-apply-value object name
-                                    format nil value
-                                    nil nil
-                                    'without-tags)
-            ))))
-
-(defun www-edit-display-feature-input-box (char feature-name
-                                               &optional format value)
-  (unless format
-    (setq format 'default))
-  (unless value
-    (setq value (www-get-feature-value char feature-name)))
-  (princ
-   (format "<p><input type=\"text\" name=\"feature-name\"
-size=\"32\" maxlength=\"256\" value=\"%s\">"
-          feature-name))
-  (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
-  (princ
-   (format "%s<input type=\"text\" name=\"%s\"
-size=\"64\" maxlength=\"256\" value=\"%s\">
-<input type=\"submit\" value=\"set\" /></p>
-"
-          (if (or (eq format 'HEX)(eq format 'hex))
-              "0x"
-            "")
-          format
-          (mapconcat (lambda (c)
-                       (cond
-                         ;; ((eq c ?<) "&amp;lt;")
-                         ;; ((eq c ?>) "&amp;gt;")
-                        ((eq c ?\u0022) "&quot;")
-                        (t
-                         (char-to-string c))))
-                     (www-format-value char feature-name
-                                       value format 'without-tags)
-                     "")))
-  )
+;; (defun www-edit-display-feature-input-box (char feature-name
+;;                                                 &optional format value)
+;;   (unless format
+;;     (setq format 'default))
+;;   (unless value
+;;     (setq value (www-get-feature-value char feature-name)))
+;;   (princ
+;;    (format "<p><input type=\"text\" name=\"feature-name\"
+;; size=\"32\" maxlength=\"256\" value=\"%s\">"
+;;            feature-name))
+;;   (princ (encode-coding-string " \u2190 " 'utf-8-mcs-er))
+;;   (princ
+;;    (format "%s<input type=\"text\" name=\"%s\"
+;; size=\"64\" maxlength=\"256\" value=\"%s\">
+;; <input type=\"submit\" value=\"set\" /></p>
+;; "
+;;            (if (or (eq format 'HEX)(eq format 'hex))
+;;                "0x"
+;;              "")
+;;            format
+;;            (mapconcat (lambda (c)
+;;                         (cond
+;;                          ;; ((eq c ?<) "&amp;lt;")
+;;                          ;; ((eq c ?>) "&amp;gt;")
+;;                          ((eq c ?\u0022) "&quot;")
+;;                          (t
+;;                           (char-to-string c))))
+;;                       (est-format-unit
+;;                        (est-eval-unit
+;;                         (if (symbolp format)
+;;                             (list format)
+;;                           format)
+;;                         char feature-name)
+;;                        'without-tags)
+;;                       ;; (www-format-value char feature-name
+;;                       ;;                   value format 'without-tags)
+;;                       "")))
+;;   )
 
 (defun www-edit-display-object-desc (genre uri-object uri-feature-name
                                           &optional lang format)
-  (when (stringp format)
-    (setq format (intern format)))
-  (let ((object (www-uri-decode-object genre uri-object))
-       (feature-name (www-uri-decode-feature-name uri-feature-name))
-       base-name metadata-name
-       object-spec str)
-    (when (characterp object)
-      (princ
-       (format "<head>
-<title>CHISE-wiki character: %s</title>
-</head>\n"
-              (encode-coding-string
-               (decode-uri-string uri-object 'utf-8-mcs-er)
-               'utf-8-mcs-er)))
-      (princ "<body>\n")
-      (princ
-       (format "<h1>%s</h1>\n"
-              (www-format-encode-string (char-to-string object))))
-      (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-object 'utf-8-mcs-er))
-       'utf-8-mcs-er))
-      (setq object-spec (char-attribute-alist object))
-      (if (string-match "\\*" (setq str (symbol-name feature-name)))
-         (setq base-name (intern (substring str 0 (match-beginning 0)))
-               metadata-name (intern (substring str (match-end 0))))
-       (setq base-name feature-name))
-      (unless (assq base-name object-spec)
-       (setq object-spec (cons (cons base-name nil)
-                             object-spec)))
-      (dolist (cell (sort object-spec
-                         (lambda (a b)
-                           (char-attribute-name< (car a)(car b)))))
-       (cond
-        ((eq (car cell) feature-name)
-         (www-edit-display-feature-input-box object feature-name format)
-         )
-        (t
-         (princ "<p>")
-         (princ
-          (www-format-eval-list
-           (or (char-feature-property (car cell) 'format)
-               '((name) " : " (value)))
-           object (car cell) lang uri-object))
-         (princ "</p>\n")
-         (when (and (eq base-name (car cell)) metadata-name)
-           (princ "<ul>\n")
-           (princ "<li>")
-            (www-edit-display-feature-input-box object feature-name format)
-           (princ "</li>")
-           (princ "</ul>"))
-         ))
-       )
-      (princ "</form>\n")
-      )))
+  (www-display-object-desc genre uri-object nil lang 1 nil
+                          uri-feature-name format))
+
+;; (defun www-edit-display-object-desc (genre uri-object uri-feature-name
+;;                                            &optional lang format)
+;;   (when (stringp format)
+;;     (setq format (intern format)))
+;;   (let ((object (www-uri-decode-object genre uri-object))
+;;         (feature-name (www-uri-decode-feature-name uri-feature-name))
+;;         base-name metadata-name
+;;         parents
+;;         object-spec str)
+;;     (when object
+;;       (princ
+;;        (encode-coding-string
+;;         (format "<head>
+;; <title>EsT %s = %s</title>
+;; </head>\n"
+;;                 genre
+;;                 (decode-uri-string uri-object 'utf-8-mcs-er))
+;;         'utf-8-mcs-er))
+;;       (princ "<body>\n")
+;;       (when (eq genre 'character)
+;;         (dolist (feature (char-feature-property '$object 'additional-features))
+;;           (mount-char-attribute-table
+;;            (char-feature-name-at-domain feature '$rev=latest))))
+;;       (when (setq parents (www-get-feature-value object '<-denotational))
+;;         (princ (format "<p>%s %s</p>\n<hr>\n"
+;;                        (www-format-value-as-char-list parents)
+;;                        (www-format-feature-name '->denotational lang))))
+;;       (when (setq parents (www-get-feature-value object '<-subsumptive))
+;;         (princ (format "<p>%s %s</p>\n<hr>\n"
+;;                        (www-format-value-as-char-list parents)
+;;                        (www-format-feature-name '->subsumptive lang))))
+;;       (princ
+;;        (format "<h1>%s</h1>\n"
+;;                (www-format-encode-string (est-format-object object))))
+;;       (princ "<form action=\"set.cgi\" method=\"GET\">\n")
+;;       (princ
+;;        (encode-coding-string
+;;         (format "<p>(%s : <input type=\"text\" name=\"%s\"
+;; size=\"30\" maxlength=\"30\" value=\"%s\">)</p>
+;; "
+;;                 genre genre
+;;                 (decode-uri-string uri-object 'utf-8-mcs-er))
+;;         'utf-8-mcs-er))
+;;       (setq object-spec
+;;             (if (eq genre 'character)
+;;                 (char-attribute-alist object)
+;;               (concord-object-spec object)))
+;;       (if (string-match "\\*" (setq str (symbol-name feature-name)))
+;;           (setq base-name (intern (substring str 0 (match-beginning 0)))
+;;                 metadata-name (intern (substring str (match-end 0))))
+;;         (setq base-name feature-name))
+;;       (unless (assq base-name object-spec)
+;;         (setq object-spec (cons (cons base-name nil)
+;;                               object-spec)))
+;;       (dolist (cell (sort object-spec
+;;                           (lambda (a b)
+;;                             (char-attribute-name< (car a)(car b)))))
+;;         (cond
+;;          ((eq (car cell) feature-name)
+;;           (www-edit-display-feature-input-box object feature-name format)
+;;           )
+;;          (t
+;;           (princ "<p>")
+;;           (princ
+;;            (www-format-eval-list
+;;             (or (char-feature-property (car cell) 'format)
+;;                 '((name) " : " (value)))
+;;             object (car cell) lang uri-object))
+;;           (princ "</p>\n")
+;;           (when (and (eq base-name (car cell)) metadata-name)
+;;             (princ "<ul>\n")
+;;             (princ "<li>")
+;;             (www-edit-display-feature-input-box object feature-name format)
+;;             (princ "</li>")
+;;             (princ "</ul>"))
+;;           ))
+;;         )
+;;       (princ "</form>\n")
+;;       )))
 
 (defun www-edit-display-feature-desc (uri-feature-name
                                      uri-property-name
-                                     &optional lang uri-object)
+                                     &optional lang
+                                     object-genre uri-object)
   (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
        (property-name (www-uri-decode-feature-name uri-property-name))
        name@lang)
@@ -201,6 +232,18 @@ size=\"30\" maxlength=\"30\" value=\"%s\">に限\u5B9Aしない)
                (or (www-feature-value-format feature-name)
                    'default))
               uri-feature-name)))
+    (if (eq property-name 'value-presentation-format)
+       (www-edit-display-feature-input-box
+        feature-name property-name
+        'default ; 'wiki-text
+        (or (www-feature-value-format feature-name)
+            'default))
+      (www-html-display-paragraph
+       (format "value-presentation-format : %s [[[edit|edit.cgi?feature=%s&property=value-presentation-format]]]"
+              (www-xml-format-list
+               (or (www-feature-value-format feature-name)
+                   'default))
+              uri-feature-name)))
     (if (eq property-name 'format)
        (www-edit-display-feature-input-box
         feature-name property-name
@@ -274,10 +317,10 @@ size=\"30\" maxlength=\"30\" value=\"%s\">に限\u5B9Aしない)
                (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)
-               )
+               (car (nth 3 target))
+                (cdr (nth 3 target))
+                ;; (cdr (assq 'char target))
+                )
               )
              (t
               (www-edit-display-object-desc
@@ -305,3 +348,5 @@ size=\"30\" maxlength=\"30\" value=\"%s\">に限\u5B9Aしない)
     (error nil
           (princ (format "%S" err)))
     ))
+
+(provide 'cwiki-edit)