(est-eval-value-as-ndl-page-by-tify): New function.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Mon, 17 Jan 2022 07:13:00 +0000 (16:13 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 19 Jan 2022 01:07:23 +0000 (10:07 +0900)
(est-eval-apply-value): Use `est-eval-value-as-ndl-page-by-tify' for
format `tify-url-for-ndl'.
(est-eval-unit): Treat `tify-url-for-ndl' as a value getter.

est-eval.el

index 7d5b55a..8a9a838 100644 (file)
                          (daijiten-page-number-to-ndl-950498 value)))
            value)))
 
+(defun est-eval-value-as-ndl-page-by-tify (value)
+  (if (symbolp value)
+      (setq value (symbol-name value)))
+  (if (stringp value)
+      (if (string-match "/" value)
+         (format "http://image.chise.org/tify/?manifest=https://www.dl.ndl.go.jp/api/iiif/%s/manifest.json&tify={%%22pages%%22:[%s]}"
+                 (substring value 0 (match-beginning 0))
+                 (substring value (match-end 0)))
+       (format "http://image.chise.org/tify/?manifest=https://www.dl.ndl.go.jp/api/iiif/%s/manifest.json"
+               value))
+    value))
+
 (defun est-eval-value-as-Web-yunzi-char (value)
   (if (char-or-char-int-p value)
       (list 'link
          (est-eval-value-as-kuten value))
         ((eq format 'kangxi-radical)
          (est-eval-value-as-kangxi-radical value))
+        ((eq format 'tify-url-for-ndl)
+         (est-eval-value-as-ndl-page-by-tify value)
+         )
         ((eq format 'shuowen-radical)
          (est-eval-value-as-shuowen-radical value))
         ((eq format 'ids)
     (cond
      ((memq (car exp) '(value decimal hex HEX ku-ten
                              kangxi-radical shuowen-radical
-                             S-exp string default))
+                             S-exp string default tify-url-for-ndl))
       (let ((fn (plist-get (nth 1 exp) :feature))
            domain domain-fn ret)
        (when fn