From: tomo Date: Tue, 19 Sep 2006 08:37:57 +0000 (+0000) Subject: (www-page-display-dir): Renamed from `www-page-display-thumbnails'. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a847e9e911ea6b940506f1a529e591ac8e1977c3;p=elisp%2Falbum.git (www-page-display-dir): Renamed from `www-page-display-thumbnails'. (www-page-display-image): Check file exists. (www-page-batch-get): Use `www-page-display-dir' instead of `www-page-display-thumbnails'. --- diff --git a/www-page.el b/www-page.el index cae204f..e4f2bf1 100644 --- a/www-page.el +++ b/www-page.el @@ -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 @@ -370,50 +370,51 @@ (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 @@ -465,7 +466,7 @@ 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)