(www-page-display-page): Display error message if file is not found.
authortomo <tomo>
Wed, 24 May 2006 13:27:05 +0000 (13:27 +0000)
committertomo <tomo>
Wed, 24 May 2006 13:27:05 +0000 (13:27 +0000)
www-page.el

index 324b807..9f92a1a 100644 (file)
     (insert "<body>\n")
     ;; (insert (format "<h1>%s</h1>\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 "<a href=\"page.cgi?%s%s.html.%s&size=%s\">"
-                         (file-name-directory file) prev-file
-                         (or lang 'en)
-                         size)))
-      (cond ((eq lang 'ja)
-            (insert "[\e$BA0\e(B]")
-            )
-           (t
-            (insert "[Previous]")
-            ))
-      (if prev-file
-         (insert "</a>"))
-      (insert "\n")
-
-      (if next-file
-         (insert (format "<a href=\"page.cgi?%s%s.html.%s&size=%s\">"
-                         (file-name-directory file) next-file
-                         (or lang 'en)
-                         size)))
-      (cond ((eq lang 'ja)
-            (insert "[\e$B<!\e(B]")
-            )
-           (t
-            (insert "[Next]")
-            ))
-      (if next-file
-         (insert "</a>"))
-      (insert "\n")
-
-      (if prev-grade
-         (insert (format "<a href=\"page.cgi?%s.html.%s&size=%s\">"
-                         file
-                         (or lang 'en)
-                         prev-grade)))
-      (cond ((eq lang 'ja)
-            (insert "[\e$B=L>.\e(B]")
-            )
-           (t
-            (insert "[Smaller]")
-            ))
-      (if prev-grade
-         (insert "</a>"))
-      (insert "\n")
-
-      (if next-grade
-         (insert (format "<a href=\"page.cgi?%s.html.%s&size=%s\">"
-                         file
-                         (or lang 'en)
-                         next-grade)))
-      (cond ((eq lang 'ja)
-            (insert "[\e$B3HBg\e(B]")
-            )
-           (t
-            (insert "[Larger]")
-            ))
-      (if next-grade
-         (insert "</a>"))
-      (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 "<a href=\"page.cgi?%s%s.html.%s&size=%s\">"
+                             (file-name-directory file) prev-file
+                             (or lang 'en)
+                             size)))
+         (cond ((eq lang 'ja)
+                (insert "[\e$BA0\e(B]")
+                )
+               (t
+                (insert "[Previous]")
+                ))
+         (if prev-file
+             (insert "</a>"))
+         (insert "\n")
+
+         (if next-file
+             (insert (format "<a href=\"page.cgi?%s%s.html.%s&size=%s\">"
+                             (file-name-directory file) next-file
+                             (or lang 'en)
+                             size)))
+         (cond ((eq lang 'ja)
+                (insert "[\e$B<!\e(B]")
+                )
+               (t
+                (insert "[Next]")
+                ))
+         (if next-file
+             (insert "</a>"))
+         (insert "\n")
+
+         (if prev-grade
+             (insert (format "<a href=\"page.cgi?%s.html.%s&size=%s\">"
+                             file
+                             (or lang 'en)
+                             prev-grade)))
+         (cond ((eq lang 'ja)
+                (insert "[\e$B=L>.\e(B]")
+                )
+               (t
+                (insert "[Smaller]")
+                ))
+         (if prev-grade
+             (insert "</a>"))
+         (insert "\n")
+
+         (if next-grade
+             (insert (format "<a href=\"page.cgi?%s.html.%s&size=%s\">"
+                             file
+                             (or lang 'en)
+                             next-grade)))
+         (cond ((eq lang 'ja)
+                (insert "[\e$B3HBg\e(B]")
+                )
+               (t
+                (insert "[Larger]")
+                ))
+         (if next-grade
+             (insert "</a>"))
+         (insert "\n")
+
+         (insert "
 <hr>
 ")
-      (if next-file
-         (insert (format "<a href=\"page.cgi?%s%s.html.%s&size=%s\">"
-                         (file-name-directory file) next-file
-                         (or lang 'en)
-                         size)))
-      (insert
-       (if image-ref
-          (format "<img alt=\"%s\" src=\"%s&size=%s\">"
-                  file image-ref size)
-        (format "<img alt=\"%s\" src=\"page.cgi?%s&size=%s\">"
-                file image-file size)))
-      (if next-file
-         (insert "</a>"))
-      (insert "
+         (if next-file
+             (insert (format "<a href=\"page.cgi?%s%s.html.%s&size=%s\">"
+                             (file-name-directory file) next-file
+                             (or lang 'en)
+                             size)))
+         (insert
+          (if image-ref
+              (format "<img alt=\"%s\" src=\"%s&size=%s\">"
+                      file image-ref size)
+            (format "<img alt=\"%s\" src=\"page.cgi?%s&size=%s\">"
+                    file image-file size)))
+         (if next-file
+             (insert "</a>"))
+         )
+      (insert "<p>")
+      (insert (format
+              (cond
+               ((eq lang 'ja)
+                "\e$B2hA|%U%!%$%k\e(B %s \e$B$,8+IU$+$j$^$;$s!#\e(B\n")
+               (t
+                "Image file %s is not found.\n"))
+              file))
+      )
+    (insert "
 <hr>
 
 ")
-      (insert
-       (format "<a href=\"page.cgi?%s&lang=%s&size=%s\">[index]</a>"
-              (file-name-directory file)
-              (or lang 'en)
-              size))
-      (insert "
+    (insert
+     (format "<a href=\"page.cgi?%s&lang=%s&size=%s\">[index]</a>"
+            (file-name-directory file)
+            (or lang 'en)
+            size))
+    (insert "
 </body>
 </html>
-"))
+")
     (encode-coding-region (point-min)(point-max) www-page-coding-system)
     (princ (buffer-string))
     ))