(www-display-object-desc): Support `est-hide-cgi-mode'.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Thu, 19 Jun 2014 23:54:16 +0000 (08:54 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Thu, 19 Jun 2014 23:54:16 +0000 (08:54 +0900)
(www-display-feature-desc): Likewise.
(www-batch-view-smart): New function.

cwiki-view.el

index 9fc844f..ead1465 100644 (file)
@@ -49,6 +49,18 @@ size=\"64\" maxlength=\"256\" value=\"%s\">
     (setq level 0))
   (let ((object (www-uri-decode-object genre uri-object))
        (est-eval-list-feature-items-limit est-eval-list-feature-items-limit)
+       (est-view-url-prefix (if uri-feature-name
+                                "../.."
+                              ".."))
+       (rdf-uri-object (if est-hide-cgi-mode
+                           (if (string-match "=" uri-object)
+                               (concat
+                                (est-uri-decode-feature-name-body
+                                 (substring uri-object 0 (match-beginning 0)))
+                                ":"
+                                (est-uri-decode-feature-name-body
+                                 (substring uri-object (match-end 0))))
+                             uri-object)))
        feature-name-to-display feature-name-to-edit
        base-name-to-edit metadata-name-to-edit
        without-header
@@ -90,30 +102,39 @@ size=\"64\" maxlength=\"256\" value=\"%s\">
          (mount-char-attribute-table
           (char-feature-name-at-domain feature '$rev=latest))))
       (princ
-       (format
-       (if simple
-           "<div style=\"text-align:right;\">
+       (if simple
+          (format
+           (if est-hide-cgi-mode
+               "<div style=\"text-align:right;\">
+<a href=\"../../edit/view.cgi?%s=%s\">
+<input type=\"submit\" value=\"Edit\" />
+</a>\n"
+             "<div style=\"text-align:right;\">
 <a href=\"edit/view.cgi?%s=%s\">
 <input type=\"submit\" value=\"Edit\" />
-</a>
-<input type=\"submit\" value=\"New Account\" />
-<a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
-<input type=\"submit\" value=\"RDF\" />
-</a>
-</div>
-<hr />\n"
+</a>\n")
+           genre rdf-uri-object)
+        (format
          "<div style=\"text-align:right;\">
-<a href=\"../view.cgi?%s=%s\">
+<a href=\"../view/%s/%s\">
 <input type=\"submit\" value=\"Simple\" />
-</a>
-<input type=\"submit\" value=\"New Account\" />
+</a>\n"
+         genre
+         (if (string-match ":" uri-object)
+             (concat
+              (est-uri-encode-feature-name-body
+               (substring uri-object 0 (match-beginning 0)))
+              "="
+              (est-uri-encode-feature-name-body
+               (substring uri-object (match-end 0))))))))
+      (princ
+       (format "<input type=\"submit\" value=\"New Account\" />
 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
 <input type=\"submit\" value=\"RDF\" />
 </a>
 </div>
-<hr />\n")
-       genre uri-object
-       genre uri-object))
+<hr />\n"
+              genre rdf-uri-object))
       (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)
@@ -129,7 +150,10 @@ size=\"64\" maxlength=\"256\" value=\"%s\">
       (princ (format "<h%d>%s%s</h%d>\n"
                     level
                     (if uri-feature-name
-                        (format "<a href=\"%s\">%s</a>"
+                         (format "<a href=\"%s\">%s</a>"
+                                ;; (if est-hide-cgi-mode
+                                 ;;     "<a href=\"../%s\">%s</a>"
+                                 ;;   "<a href=\"%s\">%s</a>")
                                 (www-uri-make-object-url object uri-object)
                                 ret)
                       ret)
@@ -274,7 +298,16 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />"
 
 (defun www-display-feature-desc (uri-feature-name genre uri-object
                                                  &optional lang simple)
-  (let ((feature-name (www-uri-decode-feature-name uri-feature-name))
+  (let ((rdf-uri-object (if est-hide-cgi-mode
+                           (if (string-match "=" uri-object)
+                               (concat
+                                (est-uri-decode-feature-name-body
+                                 (substring uri-object 0 (match-beginning 0)))
+                                ":"
+                                (est-uri-decode-feature-name-body
+                                 (substring uri-object (match-end 0))))
+                             uri-object)))
+       (feature-name (www-uri-decode-feature-name uri-feature-name))
        (name@lang (intern (format "name@%s" lang))))
     (princ
      (encode-coding-string
@@ -285,22 +318,32 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />"
       'utf-8-mcs-er))
     (princ "<body>\n")
     (princ
-     (format
-      (if simple
-         "<div style=\"text-align:right;\">
-<a href=\"edit/view.cgi?feature=%s&%s=%s\">
+     (if simple
+        (format
+         (if est-hide-cgi-mode
+             "<div style=\"text-align:right;\">
+<a href=\"../../../edit/view.cgi?feature=%s&%s=%s\">
 <input type=\"submit\" value=\"Edit\" />
 </a>
 <input type=\"submit\" value=\"New Account\" />
 </div>
 <hr />\n"
-         "<div style=\"text-align:right;\">
-<a href=\"../view.cgi?feature=%s&%s=%s\">
-<input type=\"submit\" value=\"Simple\" />
+           "<div style=\"text-align:right;\">
+<a href=\"edit/view.cgi?feature=%s&%s=%s\">
+<input type=\"submit\" value=\"Edit\" />
 </a>
+<input type=\"submit\" value=\"New Account\" />
 </div>
 <hr />\n")
-      uri-feature-name genre uri-object))
+         uri-feature-name genre rdf-uri-object)
+       (format
+       "<div style=\"text-align:right;\">
+<a href=\"../view/feature/%s&%s/%s\">
+<input type=\"submit\" value=\"Simple\" />
+</a>
+</div>
+<hr />\n"
+       uri-feature-name genre uri-object)))
     (princ
      (format "<h1>%s</h1>\n"
             (www-format-encode-string
@@ -493,4 +536,97 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />"
           (princ (format "%S" err)))
     ))
 
+(defun www-batch-view-smart ()
+  (setq debug-on-error t)
+  (setq terminal-coding-system 'binary)
+  (condition-case err
+      (let* ((est-hide-cgi-mode t)
+            (target (pop command-line-args-left))
+            (user (pop command-line-args-left))
+            (accept-language (pop command-line-args-left))
+            (mode (intern (pop command-line-args-left)))
+            (lang
+             (intern
+              (car (split-string
+                    (car (split-string
+                          (car (split-string accept-language ","))
+                          ";"))
+                    "-"))))
+            ret genre feature)
+       (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\">
+")
+       (cond
+        ((stringp target)
+         (when (string-match "^char/\\(&[^&;]+;\\)" target)
+           (setq ret (match-end 0))
+           (setq target
+                 (concat "char/"
+                         (www-uri-encode-object
+                          (www-uri-decode-object
+                           'character (match-string 1 target)))
+                         (substring target ret))))
+         (setq target
+               (mapcar
+                (lambda (cell)
+                  (if (string-match "/" cell)
+                      (progn
+                        (setq genre (substring cell 0 (match-beginning 0))
+                              ret (substring cell (match-end 0)))
+                        (cons
+                         (intern (decode-uri-string genre 'utf-8-mcs-er))
+                         (if (string-match "/feature=" ret)
+                             (list (substring ret 0 (match-beginning 0))
+                                   (substring ret (match-end 0)))
+                           (list ret))))
+                    (list (decode-uri-string cell 'utf-8-mcs-er)))
+                  ;; (setq ret (split-string cell "/"))
+                  ;; (cons (intern
+                  ;;        (decode-uri-string (car ret) 'utf-8-mcs-er))
+                  ;;       (cdr ret))
+                  )
+                (split-string target "&")))
+         (setq ret (car target))
+          ;; (princ (format "<p>%S, %S, %S</p>"
+          ;;                (car ret)(nth 1 ret)(nth 2 ret)))
+         (cond ((eq (car ret) 'char)
+                (www-display-object-desc
+                 'character (nth 1 ret) (nth 2 ret)
+                 lang nil
+                 (eq mode 'simple))
+                )
+               ((eq (car ret) 'feature)
+                (www-display-feature-desc
+                 (decode-uri-string (nth 1 ret) 'utf-8-mcs-er)
+                 (car (nth 1 target))
+                 (nth 1 (nth 1 target))
+                 lang
+                 (eq mode 'simple))
+                )
+               (t
+                (www-display-object-desc
+                 (car ret) (nth 1 ret) (nth 2 ret)
+                 lang nil
+                 (eq mode 'simple))
+                ))
+         ))
+       (princ "\n<hr>\n")
+       (princ (format "mode=%S\n" mode))
+       (princ (format "user=%s\n" user))
+        ;; (princ (format "local user=%s\n" (user-login-name)))
+       (princ (format "lang=%S\n" lang))
+       (princ (encode-coding-string (emacs-version) 'utf-8-jp-er))
+        ;; (princ " CHISE ")
+        ;; (princ xemacs-chise-version)
+       (princ "
+</body>
+</html>")
+       )
+    (error nil
+          (princ (format "%S" err)))
+    ))
+
 (provide 'cwiki-view)