X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Falbum.git;a=blobdiff_plain;f=www-page.el;h=30fe875409c7fe4c0e0d9b262fc0e579470a19f5;hp=e4f2bf101bae180b53c5d344143c155e015db350;hb=19733a295d7cc9d30f83d9a45c071ce798d6ed80;hpb=a847e9e911ea6b940506f1a529e591ac8e1977c3 diff --git a/www-page.el b/www-page.el index e4f2bf1..30fe875 100644 --- a/www-page.el +++ b/www-page.el @@ -1,6 +1,6 @@ ;;; www-page.el --- Album page generator for page.cgi. -;; Copyright (C) 2005,2006 MORIOKA Tomohiko +;; Copyright (C) 2005,2006,2007,2009,2010 MORIOKA Tomohiko ;; Keywords: Photo, image, album, HTML, WWW @@ -27,6 +27,8 @@ ;;; Code: +(defconst www-page-version "0.5") + (defvar www-page-coding-system (if (featurep 'chise) 'utf-8-jp-er @@ -49,6 +51,7 @@ (WUXGA 1920 1200) (QXGA 2048 1536) (WQXGA 2560 1600) + (original nil nil) )) (defun decode-url-string (string &optional coding-system) @@ -66,20 +69,32 @@ (concat dest (substring string i)) coding-system)))) +(defun www-page-open-dir (url-dir &optional image-root) + (let* ((path (expand-file-name url-dir image-root)) + (desc-file (expand-file-name "dir.desc" path))) + (cons (cons 'location path) + (with-temp-buffer + (when (file-exists-p desc-file) + (insert-file-contents desc-file) + (read (current-buffer))))))) + +(defun www-page-directory-image-files (url-dir image-root) + (let (source-images) + (dolist (file (directory-files (expand-file-name url-dir image-root) + nil "\\.\\(jpg\\|JPG\\)$" nil t)) + (unless (string-match "_[^_]+GA[^_]*$" + (file-name-sans-extension file)) + (setq source-images (cons file source-images)))) + (nreverse source-images))) + (defun www-page-display-dir (url-dir &optional size image-root - lang title parent-url) + lang title parent-url hide-cgi + pivot-mode) (setq url-dir (file-name-as-directory url-dir)) (princ "Content-Type: text/html; charset=UTF-8 ") - (let* ((desc-file - (expand-file-name "dir.desc" - (expand-file-name url-dir image-root))) - (params - (with-temp-buffer - (when (file-exists-p desc-file) - (insert-file-contents desc-file) - (read (current-buffer))))) + (let* ((params (www-page-open-dir url-dir image-root)) source-images ref-images file i ref-file prev-file next-file file-desc note) @@ -93,6 +108,9 @@ (setq source-images (cdr source-images))) (when (setq ref-images (assq 'refs params)) (setq ref-images (cdr ref-images))) + (unless (or source-images ref-images) + (setq source-images + (www-page-directory-image-files url-dir image-root))) (when (setq note (assq 'note params)) (setq note (cdr note))) (when (setq parent-url (assq 'exit params)) @@ -110,20 +128,36 @@ (insert "\n") (insert "
\n") (insert (format "