(www-page-display-dir): Renamed from `www-page-display-thumbnails'.
authortomo <tomo>
Tue, 19 Sep 2006 08:37:57 +0000 (08:37 +0000)
committertomo <tomo>
Tue, 19 Sep 2006 08:37:57 +0000 (08:37 +0000)
(www-page-display-image): Check file exists.
(www-page-batch-get): Use `www-page-display-dir' instead of
`www-page-display-thumbnails'.

www-page.el

index cae204f..e4f2bf1 100644 (file)
@@ -66,7 +66,7 @@
         (concat dest (substring string i))
         coding-system))))
 
-(defun www-page-display-thumbnails (url-dir &optional size image-root
+(defun www-page-display-dir (url-dir &optional size image-root
                                             lang title parent-url)
   (setq url-dir (file-name-as-directory url-dir))
   (princ "Content-Type: text/html; charset=UTF-8
 
 (defun www-page-display-image (file &optional size image-root)
   (setq file (expand-file-name file image-root))
-  (let (file-dir file-name
-       resized-file resized-dir
-       spec)
-    (cond
-     (size
-      (setq file-dir (file-name-directory file)
-           file-name (file-name-nondirectory file))
-      (setq resized-file
-           (expand-file-name
-            file-name
-            (setq resized-dir
-                  (expand-file-name
-                   size file-dir))))
-      (unless (file-exists-p resized-file)
-       (setq size (intern size))
-       (if (setq spec (assq size www-page-size-specs))
-           (progn
-             (condition-case nil
-                 (unless (file-exists-p resized-dir)
-                   (make-directory resized-dir))
-               (error nil))
-             (call-process
-              "convert" nil nil nil
-              "-resize" (format "%dx%d>" (nth 1 spec)(nth 2 spec))
-              file resized-file)
-             )
-         (setq resized-file file)))
-      ;; (princ resized-file)
-      (setq file resized-file)
-      )
-     (t
-      ;; (princ file)
-      ))
-    (princ (format "Content-Type: %s"
-                  (with-temp-buffer
-                    (call-process
-                     "file"
-                     nil t t
-                     "-b" "--mime" file)
-                    (insert "\n")
-                    (let ((coding-system-for-read 'binary)
-                          (coding-system-for-write 'binary))
-                      (insert-file-contents-literally file))
-                    (buffer-string))))))
+  (when (file-exists-p file)
+    (let (file-dir file-name
+                  resized-file resized-dir
+                  spec)
+      (cond
+       (size
+       (setq file-dir (file-name-directory file)
+             file-name (file-name-nondirectory file))
+       (setq resized-file
+             (expand-file-name
+              file-name
+              (setq resized-dir
+                    (expand-file-name
+                     size file-dir))))
+       (unless (file-exists-p resized-file)
+         (setq size (intern size))
+         (if (setq spec (assq size www-page-size-specs))
+             (progn
+               (condition-case nil
+                   (unless (file-exists-p resized-dir)
+                     (make-directory resized-dir))
+                 (error nil))
+               (call-process
+                "convert" nil nil nil
+                "-resize" (format "%dx%d>" (nth 1 spec)(nth 2 spec))
+                file resized-file)
+               )
+           (setq resized-file file)))
+       ;; (princ resized-file)
+       (setq file resized-file)
+       )
+       (t
+       ;; (princ file)
+       ))
+      (princ (format "Content-Type: %s"
+                    (with-temp-buffer
+                      (call-process
+                       "file"
+                       nil t t
+                       "-b" "--mime" file)
+                      (insert "\n")
+                      (let ((coding-system-for-read 'binary)
+                            (coding-system-for-write 'binary))
+                        (insert-file-contents-literally file))
+                      (buffer-string)))))))
 
 (defun www-page-batch-get ()
   ;; (set-coding-priority-list
                          default-directory)))
     (setq command-line-args-left (cdr command-line-args-left))
     (cond ((eq method 'dir)
-          (www-page-display-thumbnails target size image-root lang)
+          (www-page-display-dir target size image-root lang)
           )
          ((eq method 'page)
           (www-page-display-page target size image-root lang)