Require `concord-turtle-dump'.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Sat, 15 Dec 2018 21:01:45 +0000 (06:01 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Sat, 15 Dec 2018 21:01:45 +0000 (06:01 +0900)
(www-display-object-desc): Add [Turtle] button.
(www-batch-view-smart): Display Turtle for */index.ttl.

cwiki-view.el

index 6d48331..fe4586f 100644 (file)
@@ -1,6 +1,7 @@
 ;; -*- coding: utf-8-mcs-er -*-
 (require 'cwiki-format)
 (require 'char-db-json)
+(require 'concord-turtle-dump)
 
 (defvar chise-wiki-view-url "view.cgi")
 (defvar chise-wiki-edit-url "edit.cgi")
@@ -179,10 +180,12 @@ li { margin: 0 0 0 2em; }
        (format "<input type=\"submit\" value=\"New Account\" />
 <a href=\"http://www.chise.org/est/rdf.cgi?%s=%s\">
 <input type=\"submit\" value=\"RDF\" />
-</a>%s
+</a>
+<a href=\"./%s/index.ttl\"><input type=\"submit\" value=\"Turtle\" /></a>%s
 </div>
 <hr />\n"
               genre rdf-uri-object
+              rdf-uri-object
               (if (eq genre 'character)
                   (format "
 <a href=\"/est/view/%s/%s/data.json\">
@@ -792,12 +795,18 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />"
                           (car (split-string accept-language ","))
                           ";"))
                     "-"))))
-            ret genre feature obj-url json obj)
+            ret genre feature obj-url json turtle obj)
        (cond
         ((stringp target)
-         (when (string-match "/data\\.json$" target)
+         (cond
+          ((string-match "/data\\.json$" target)
            (setq json t
-                 target (substring target 0 (match-beginning 0))))
+                 target (substring target 0 (match-beginning 0)))
+           )
+          ((string-match "/index\\.ttl$" target)
+           (setq turtle t
+                 target (substring target 0 (match-beginning 0)))
+           ))
          (when (string-match "^char/\\(&[^&;]+;\\)" target)
            (setq ret (match-end 0))
            (setq target
@@ -835,21 +844,40 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />"
                   )
                 (split-string target "&")))
          (setq ret (car target))
-         (if json
-             (princ "Content-Type: application/json; charset=UTF-8
+         (cond (turtle
+                (princ "Content-Type: text/turtle; charset=UTF-8
+
+")
+                )
+               (json
+                (princ "Content-Type: application/json; charset=UTF-8
 
 ")
-           (princ "Content-Type: text/html; charset=UTF-8
+                )
+               (t
+                (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\">
 ")
-           )
+                ))
           ;; (princ (format "<p>%S, %S, %S</p>"
           ;;                (car ret)(nth 1 ret)(nth 2 ret)))
           ;; (princ (format "// %S %S\n" ret json))
-         (cond ((or (eq (car ret) 'char)
+         (cond (turtle
+                (with-temp-buffer
+                  (setq obj (www-uri-decode-object (car ret)(nth 1 ret)))
+                  (concord-turtle-insert-char-data obj)
+                  (goto-char (point-min))
+                  (concord-turtle-insert-prefix)
+                  (insert "\n")
+                  (encode-coding-region
+                   (point-min)(point-max)
+                   char-db-file-coding-system)
+                  (princ (buffer-string)))
+                )
+               ((or (eq (car ret) 'char)
                     (eq (car ret) 'character))
                 (if (and json
                          (setq obj (www-uri-decode-object
@@ -909,7 +937,7 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />"
                  (eq mode 'simple))
                 ))
          ))
-       (unless json
+       (unless (or json turtle)
          (princ "\n<hr>\n")
          (princ (format "mode=%S\n" mode))
          (princ (format "user=%s\n" user))