From 34d4fd8cbbdb321f571e5ad98b1f9b5f78cabf18 Mon Sep 17 00:00:00 2001 From: tomo Date: Wed, 24 May 2006 13:27:05 +0000 Subject: [PATCH] (www-page-display-page): Display error message if file is not found. --- www-page.el | 281 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 146 insertions(+), 135 deletions(-) diff --git a/www-page.el b/www-page.el index 324b807..9f92a1a 100644 --- a/www-page.el +++ b/www-page.el @@ -207,149 +207,160 @@ (insert "\n") ;; (insert (format "

%s

\n" file)) - (let* ((desc-file (expand-file-name (concat file ".desc") image-root)) - (params + (if (file-exists-p (expand-file-name file image-root)) + (let* ((desc-file (expand-file-name (concat file ".desc") image-root)) + (params + (with-temp-buffer + (when (file-exists-p desc-file) + (insert-file-contents desc-file) + (read (current-buffer))))) + dir-desc-file + image-file image-ref + prev-file next-file + prev-grade next-grade + rest spec ret) + (unless params + (setq dir-desc-file + (expand-file-name "dir.desc" + (expand-file-name (file-name-directory file) + image-root))) + (setq params + (with-temp-buffer + (when (file-exists-p dir-desc-file) + (insert-file-contents dir-desc-file) + (read (current-buffer))))) + (when (setq rest (assq 'files params)) + (setq rest (cdr rest))) + (setq ret (file-name-nondirectory file)) + (while (and rest + (not (string= (car rest) ret))) + (setq prev-file (car rest) + rest (cdr rest))) + (setq next-file (car (cdr rest))) + (if prev-file + (setq params (list (cons 'prev-file prev-file)))) + (if next-file + (setq params (cons (cons 'next-file next-file) + params))) (with-temp-buffer - (when (file-exists-p desc-file) - (insert-file-contents desc-file) - (read (current-buffer))))) - dir-desc-file - image-file image-ref - prev-file next-file - prev-grade next-grade - rest spec ret) - (unless params - (setq dir-desc-file - (expand-file-name "dir.desc" - (expand-file-name (file-name-directory file) - image-root))) - (setq params - (with-temp-buffer - (when (file-exists-p dir-desc-file) - (insert-file-contents dir-desc-file) - (read (current-buffer))))) - (when (setq rest (assq 'files params)) - (setq rest (cdr rest))) - (setq ret (file-name-nondirectory file)) - (while (and rest - (not (string= (car rest) ret))) - (setq prev-file (car rest) - rest (cdr rest))) - (setq next-file (car (cdr rest))) - (if prev-file - (setq params (list (cons 'prev-file prev-file)))) - (if next-file - (setq params (cons (cons 'next-file next-file) - params))) - (with-temp-buffer - (insert (format "%S" params)) - ;; (princ "X-XEmacs-Message: ") - (write-region (point-min)(point-max) desc-file) - ;; (princ "\n") - )) - (if (setq image-ref (assq 'ref params)) - (setq image-ref (cdr image-ref)) - (setq image-file file)) - (if (setq prev-file (assq 'prev-file params)) - (setq prev-file (cdr prev-file))) - (if (setq next-file (assq 'next-file params)) - (setq next-file (cdr next-file))) - (setq rest www-page-size-specs) - (while (and rest - (setq spec (car rest)) - (not (eq (car spec) size))) - (setq prev-grade (car spec) - rest (cdr rest))) - (setq next-grade (car (car (cdr rest)))) - (if prev-file - (insert (format "" - (file-name-directory file) prev-file - (or lang 'en) - size))) - (cond ((eq lang 'ja) - (insert "[前]") - ) - (t - (insert "[Previous]") - )) - (if prev-file - (insert "")) - (insert "\n") - - (if next-file - (insert (format "" - (file-name-directory file) next-file - (or lang 'en) - size))) - (cond ((eq lang 'ja) - (insert "[次]") - ) - (t - (insert "[Next]") - )) - (if next-file - (insert "")) - (insert "\n") - - (if prev-grade - (insert (format "" - file - (or lang 'en) - prev-grade))) - (cond ((eq lang 'ja) - (insert "[縮小]") - ) - (t - (insert "[Smaller]") - )) - (if prev-grade - (insert "")) - (insert "\n") - - (if next-grade - (insert (format "" - file - (or lang 'en) - next-grade))) - (cond ((eq lang 'ja) - (insert "[拡大]") - ) - (t - (insert "[Larger]") - )) - (if next-grade - (insert "")) - (insert "\n") - - (insert " + (insert (format "%S" params)) + ;; (princ "X-XEmacs-Message: ") + (write-region (point-min)(point-max) desc-file) + ;; (princ "\n") + )) + (if (setq image-ref (assq 'ref params)) + (setq image-ref (cdr image-ref)) + (setq image-file file)) + (if (setq prev-file (assq 'prev-file params)) + (setq prev-file (cdr prev-file))) + (if (setq next-file (assq 'next-file params)) + (setq next-file (cdr next-file))) + (setq rest www-page-size-specs) + (while (and rest + (setq spec (car rest)) + (not (eq (car spec) size))) + (setq prev-grade (car spec) + rest (cdr rest))) + (setq next-grade (car (car (cdr rest)))) + (if prev-file + (insert (format "" + (file-name-directory file) prev-file + (or lang 'en) + size))) + (cond ((eq lang 'ja) + (insert "[前]") + ) + (t + (insert "[Previous]") + )) + (if prev-file + (insert "")) + (insert "\n") + + (if next-file + (insert (format "" + (file-name-directory file) next-file + (or lang 'en) + size))) + (cond ((eq lang 'ja) + (insert "[次]") + ) + (t + (insert "[Next]") + )) + (if next-file + (insert "")) + (insert "\n") + + (if prev-grade + (insert (format "" + file + (or lang 'en) + prev-grade))) + (cond ((eq lang 'ja) + (insert "[縮小]") + ) + (t + (insert "[Smaller]") + )) + (if prev-grade + (insert "")) + (insert "\n") + + (if next-grade + (insert (format "" + file + (or lang 'en) + next-grade))) + (cond ((eq lang 'ja) + (insert "[拡大]") + ) + (t + (insert "[Larger]") + )) + (if next-grade + (insert "")) + (insert "\n") + + (insert "
") - (if next-file - (insert (format "" - (file-name-directory file) next-file - (or lang 'en) - size))) - (insert - (if image-ref - (format "\"%s\"" - file image-ref size) - (format "\"%s\"" - file image-file size))) - (if next-file - (insert "")) - (insert " + (if next-file + (insert (format "" + (file-name-directory file) next-file + (or lang 'en) + size))) + (insert + (if image-ref + (format "\"%s\"" + file image-ref size) + (format "\"%s\"" + file image-file size))) + (if next-file + (insert "")) + ) + (insert "

") + (insert (format + (cond + ((eq lang 'ja) + "画像ファイル %s が見付かりません。\n") + (t + "Image file %s is not found.\n")) + file)) + ) + (insert "


") - (insert - (format "[index]" - (file-name-directory file) - (or lang 'en) - size)) - (insert " + (insert + (format "[index]" + (file-name-directory file) + (or lang 'en) + size)) + (insert " -")) +") (encode-coding-region (point-min)(point-max) www-page-coding-system) (princ (buffer-string)) )) -- 1.7.10.4