X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fest.git;a=blobdiff_plain;f=cwiki-view.el;h=ca965f2517ac12de0edc15c7c33fdbcdfaed47fc;hp=1605d6811cce7c374cc1dca5d7cc7b59bf4b776a;hb=HEAD;hpb=19098062c72923a2b738639148e909989ac9e587 diff --git a/cwiki-view.el b/cwiki-view.el index 1605d68..bf0dd07 100644 --- a/cwiki-view.el +++ b/cwiki-view.el @@ -1,5 +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") @@ -14,6 +16,9 @@ (setq format 'default)) (unless value (setq value (www-get-feature-value char feature-name))) + (if (and (symbolp value) + (eq format 'wiki-text)) + (setq value (list (list value)))) (princ (format "
" @@ -35,22 +40,39 @@ size=\"64\" maxlength=\"256\" value=\"%s\"> ((eq c ?\u0022) """) (t (char-to-string c)))) - (www-format-value char feature-name - value format 'without-tags) + (est-format-list value format nil nil " ") ""))) ) -(defun www-display-object-desc (genre uri-object &optional lang level simple +(defun www-display-object-desc (genre uri-object &optional uri-feature-name + image-selection + lang level simple uri-feature-name-to-edit editing-format) (unless level (setq level 0)) (let ((object (www-uri-decode-object genre uri-object)) - feature-name-to-edit + (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 logical-feature chise-wiki-displayed-features parents - GlyphWiki-id ret object-spec) + GlyphWiki-id HNG-card HNG-card-id HNG-card-cobj ret object-spec + ucs + item-code page char-num glyph-image-id + width height image-cobj base-image x y w h) (if (eq level 0) (setq level 1 without-header nil) @@ -75,6 +97,51 @@ size=\"64\" maxlength=\"256\" value=\"%s\"> (princ (encode-coding-string (format "
+ + + +%s %s
\n%s %s
\n\n" "
value-presentation-format : %s " + (www-format-value + nil 'value-presentation-format + (or (www-feature-value-format feature-name) + 'default) + 'default + 'without-tags) + )) + (unless simple + (princ + (format + " " + chise-wiki-edit-url + uri-feature-name + genre + uri-object)) + (princ "\n")) + (princ "
\n") + (princ "format : ") (www-html-display-text (decode-coding-string @@ -356,7 +754,10 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />" (www-html-display-paragraph (format "description : %s" - (or (char-feature-property feature-name 'description) + (or (decode-coding-string + (or (char-feature-property feature-name 'description) + "") + 'utf-8-mcs-er) ""))) (when lang (www-html-display-paragraph @@ -382,7 +783,7 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />" (car (split-string accept-language ",")) ";")) "-")))) - ret) + ret genre) (princ "Content-Type: text/html; charset=UTF-8 " (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))) + (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)) + ret)) (list (decode-uri-string cell 'utf-8-mcs-er)))) (split-string target "&"))) (setq ret (car target)) (cond ((eq (car ret) 'char) (www-display-object-desc - 'character - (cdr ret) + 'character (cdr ret) (cdr (assq 'feature target)) + nil lang nil (eq mode 'simple)) ) @@ -428,8 +830,8 @@ size=\"30\" maxlength=\"30\" value=\"%s\" />" ) (t (www-display-object-desc - (car ret) - (cdr ret) + (car ret) (cdr ret) (cdr (assq 'feature target)) + nil lang nil (eq mode 'simple)) )) @@ -450,4 +852,184 @@ 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 obj-url json turtle obj) + (cond + ((stringp target) + (cond + ((string-match "/data\\.json$" target) + (setq json t + target (substring target 0 (match-beginning 0))) + ) + ((string-match "/index\\.ttl$" target) + (setq turtle t + target (substring target 0 (match-beginning 0))) + ) + ((string-match "/index\\.\\(...*\\)\\.html$" target) + (setq lang (intern (match-string 1 target)) + target (substring target 0 (match-beginning 0))) + )) + (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)) + (cond + ((string-match "/feature=" ret) + (list (substring ret 0 (match-beginning 0)) + (substring ret (match-end 0))) + ) + ((string-match "...$.zoom-xywh=" ret) + (list (substring ret 0 (match-beginning 0)) + nil + (substring ret (match-end 0))) + ) + (t + (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)) + (cond (turtle + (princ "Content-Type: text/turtle; charset=UTF-8 + +") + ) + (json + (princ "Content-Type: application/json; charset=UTF-8 + +") + ) + (t + (princ "Content-Type: text/html; charset=UTF-8 + + + +") + )) + ;; (princ (format "
%S, %S, %S
" + ;; (car ret)(nth 1 ret)(nth 2 ret))) + ;; (princ (format "// %S %S\n" ret json)) + (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 + (car ret)(nth 1 ret))) + (characterp obj)) + (with-temp-buffer + ;; (princ (encode-coding-string + ;; (format "// %S\n" obj) + ;; char-db-file-coding-system)) + (char-db-json-char-data-with-variant obj 'printable) + (encode-coding-region + (point-min)(point-max) + char-db-file-coding-system) + (princ (buffer-string)) + ) + (www-display-object-desc + 'character (nth 1 ret) (nth 2 ret) + nil + 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)) + ) + ;; ((eq (car ret) 'image-resource) + ;; ;; (cond + ;; ;; ((string-match "^\\.iiif=" (nth 1 ret)) + ;; ;; (setq obj-url (decode-uri-string + ;; ;; (substring (nth 1 ret) (match-end 0)) + ;; ;; 'utf-8-mcs-er)) + ;; ;; (setq obj (concord-images-add-iiif obj-url)) + ;; ;; (www-display-object-desc + ;; ;; 'image-resource + ;; ;; (www-uri-encode-object obj) + ;; ;; (nth 2 ret) + ;; ;; lang nil + ;; ;; (eq mode 'simple)) + ;; ;; ) + ;; ;; (t + ;; (princ (nth 1 ret)) + ;; (www-display-object-desc + ;; 'image-resource (nth 1 ret) (nth 2 ret) + ;; lang nil + ;; (eq mode 'simple)) + ;; ;; )) + ;; ) + (t + (www-display-object-desc + (car ret) (nth 1 ret) (nth 2 ret) + (nth 3 ret) + lang nil + (eq mode 'simple)) + )) + )) + (unless (or json turtle) + (princ "\n