(daijiten-page-number-to-ndl-950498): New function.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Sat, 30 Mar 2019 15:28:28 +0000 (00:28 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 1 May 2019 07:14:15 +0000 (16:14 +0900)
(est-eval-value-as-daijiten-page): New function.
(est-eval-value-as-daijiten-page-list): New function.
(est-eval-apply-value): Use `est-eval-value-as-daijiten-page-list' for
format `space-separated-daijiten-page-list'.

est-eval.el

index 8076a43..d395637 100644 (file)
            (format "%c" (ideographic-radical value)))
     (est-eval-value-as-S-exp value)))
 
+(defun daijiten-page-number-to-ndl-950498 (page)
+  (+ (/ page 2)
+     (cond ((< page 229)
+           23)
+          ((< page 261)
+           24)
+          ((< page 263)
+           25)
+          ((< page 516) ; 284=285
+           26)
+          (t
+           27))))
+
+(defun est-eval-value-as-daijiten-page (value)
+  (if (integerp value)
+      (list 'link
+           (list :ref
+                 (format "http://image.chise.org/tify/?manifest=https://www.dl.ndl.go.jp/api/iiif/950498/manifest.json&tify={%%22pages%%22:[%d]}"
+                         (daijiten-page-number-to-ndl-950498 value)))
+           value)))
+
 (defun est-eval-value-as-object-list (value &optional separator subtype)
   (if (and (listp value)
           (listp (cdr value)))
                value)))
     (est-eval-value-default value)))
 
+(defun est-eval-value-as-daijiten-page-list (value &optional separator subtype)
+  (if (and (listp value)
+          (listp (cdr value)))
+      (condition-case nil
+         (let (props)
+           (if separator
+               (setq props (list :separator separator)))
+           (if subtype
+               (setq props (list* :subtype subtype props)))
+           (list* 'list props
+                  (mapcar #'est-eval-value-as-daijiten-page value)))
+       (error (format "%s" value)))
+    (format "%s" value)))
+
 (defun est-eval-value-as-creators-names (value &optional subtype)
   (if (listp value)
       (let (role-name)
          (est-eval-value-as-created-works value 'unordered-list))
         ((eq format 'journal-volume-list)
          (est-eval-value-as-journal-volumes value))
+        ((eq format 'space-separated-daijiten-page-list)
+         (est-eval-value-as-daijiten-page-list value " "))
         (t
          (est-eval-value-default value)
          ))