(www-page-display-dir): Add new optional argument `hide-cgi'.
authortomo <tomo>
Tue, 3 Apr 2007 15:39:35 +0000 (15:39 +0000)
committertomo <tomo>
Tue, 3 Apr 2007 15:39:35 +0000 (15:39 +0000)
(www-page-display-page): Likewise.
(www-page-batch-get): Support new command-line option `hide-cgi'.

www-page.el

index 6b30268..9d1f04b 100644 (file)
@@ -67,7 +67,7 @@
         coding-system))))
 
 (defun www-page-display-dir (url-dir &optional size image-root
-                                            lang title parent-url)
+                                    lang title parent-url hide-cgi)
   (setq url-dir (file-name-as-directory url-dir))
   (princ "Content-Type: text/html; charset=UTF-8
 
 ")
       (dolist (image-file source-images)
        (setq file (file-name-nondirectory image-file))
-       (insert "<a href=\"page.cgi?")
-       (insert url-dir)
+       (insert "<a href=\"")
+       (unless hide-cgi
+         (insert "page.cgi?")
+         (insert url-dir)
+         )
        (insert file)
        (insert (format ".html.%s&size=%s\">"
                        (or lang 'en)
                        (or size 'VGA)))
-       (insert (format "<img alt=\"%s\" src=\"img.cgi?%s%s&size=thumbnail\">"
-                       file url-dir file))
+        (insert (format "<img alt=\"%s\" src=\"" file))
+       (unless hide-cgi
+         (insert (format "img.cgi?%s"  url-dir)))
+       (insert file)
+       (insert "&size=thumbnail\">")
        (insert "</a>\n"))
 
       (setq i 1)
            (insert "))\n")
            (write-region (point-min)(point-max) file-desc)))
        (setq file (file-name-nondirectory ref-file))
-       (insert "<a href=\"page.cgi?")
-       (insert url-dir)
+       (insert "<a href=\"")
+       (unless hide-cgi
+         (insert "page.cgi?")
+         (insert url-dir)
+         )
        (insert (format "%d.html.%s&size=%s\">"
                        i
                        (or lang 'en)
       )))
 
 (defun www-page-display-page (file &optional size image-root
-                                   lang prev-file next-file)
+                                  lang prev-file next-file hide-cgi)
   (if (stringp size)
       (setq size (intern size)))
   (if (stringp lang)
        (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)))
+      (when prev-file
+        (insert "<a href=\"")
+       (unless hide-cgi
+         (insert (format "page.cgi?%s" (file-name-directory file))))
+       (insert (format "%s.html.%s&size=%s\">"
+                       prev-file
+                       (or lang 'en)
+                       size))
+       )
       (cond ((eq lang 'ja)
             (insert "[\e$BA0\e(B]")
             )
          (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)))
+      (when next-file
+        (insert "<a href=\"")
+       (unless hide-cgi
+         (insert (format "page.cgi?%s" (file-name-directory file))))
+       (insert (format "%s.html.%s&size=%s\">"
+                       next-file
+                       (or lang 'en)
+                       size))
+       )
       (cond ((eq lang 'ja)
             (insert "[\e$B<!\e(B]")
             )
          (insert "</a>"))
       (insert "\n")
 
-      (if prev-grade
-         (insert (format "<a href=\"page.cgi?%s.html.%s&size=%s\">"
-                         file
-                         (or lang 'en)
-                         prev-grade)))
+      (when prev-grade
+       (insert "<a href=\"")
+       (unless hide-cgi
+         (insert (format "page.cgi?%s" (file-name-directory file))))
+       (insert (format "%s.html.%s&size=%s\">"
+                       (file-name-nondirectory file)
+                       (or lang 'en)
+                       prev-grade))
+       )
       (cond ((eq lang 'ja)
             (insert "[\e$B=L>.\e(B]")
             )
          (insert "</a>"))
       (insert "\n")
 
-      (if next-grade
-         (insert (format "<a href=\"page.cgi?%s.html.%s&size=%s\">"
-                         file
-                         (or lang 'en)
-                         next-grade)))
+      (when next-grade
+        (insert "<a href=\"")
+       (unless hide-cgi
+         (insert (format "page.cgi?%s" (file-name-directory file))))
+       (insert (format "%s.html.%s&size=%s\">"
+                       (file-name-nondirectory file)
+                       (or lang 'en)
+                       next-grade))
+       )
       (cond ((eq lang 'ja)
             (insert "[\e$B3HBg\e(B]")
             )
       (insert "
 <hr>
 ")
+      (when next-file
+       (insert "<a href=\"")
+       (unless hide-cgi
+         (insert (format "page.cgi?%s" (file-name-directory file))))
+       (insert (format "%s.html.%s&size=%s\">"
+                       next-file
+                       (or lang 'en)
+                       size))
+       )
+      (cond
+       (image-ref
+       (insert
+        (format "<img alt=\"%s\" src=\"%s&size=%s\">"
+                file image-ref size))
+       )
+       (t ; (file-exists-p (expand-file-name image-file image-root))
+       (insert (format "<img alt=\"%s\" src=\"" file))
+       (unless hide-cgi
+         (insert (format "img.cgi?%s" (file-name-directory image-file))))
+       (insert (format "%s&size=%s\">"
+                       (file-name-nondirectory image-file) size))
+       )
+       (t
+       (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))))
+      
       (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)))
-       (if image-ref
-          (insert
-           (format "<img alt=\"%s\" src=\"%s&size=%s\">"
-                   file image-ref size))
-        (if (file-exists-p (expand-file-name image-file image-root))
-            (insert
-             (format "<img alt=\"%s\" src=\"img.cgi?%s&size=%s\">"
-                     file image-file size))
-          (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))))
-
-       (if next-file
-          (insert "</a>"))
-       )
+         (insert "</a>"))
+      )
     (insert "
 <hr>
 
 ")
-    (insert
-     (format "<a href=\"page.cgi?%s&lang=%s&size=%s\">[index]</a>"
-            (file-name-directory file)
-            (or lang 'en)
-            size))
+    ;; (insert
+    ;;  (format "<a href=\"page.cgi?%s&lang=%s&size=%s\">[index]</a>"
+    ;;          (file-name-directory file)
+    ;;          (or lang 'en)
+    ;;          size))
+    (insert "<a href=\"")
+    (unless hide-cgi
+      (insert (format "page.cgi?%s" (file-name-directory file))))
+    (insert (format "&lang=%s&size=%s\">[index]</a>"
+                   (or lang 'en)
+                   size))
     (insert "
 </body>
 </html>
   ;;  '(iso-7 iso-8-2 utf-8 big5 shift-jis
   ;;          iso-8-designate iso-8-1 iso-lock-shift no-conversion))
   ;; (set-coding-category-system 'utf-8 'utf-8-jp)
-  (let (target params method size key image-root lang ret)
+  (let (target params method size key image-root lang ret hide-cgi)
     (let ((rest (car command-line-args-left))
          arg val)
       (if rest
     (if (setq ret (cdr (assoc "lang" params)))
        (setq lang (car ret)))
     (setq command-line-args-left (cdr command-line-args-left))
+    (setq hide-cgi (string= (car command-line-args-left) "hide-cgi"))
+    (setq command-line-args-left (cdr command-line-args-left))
     (setq image-root (or (car command-line-args-left)
                         (expand-file-name
                          www-page-default-base-directory
                          default-directory)))
     (setq command-line-args-left (cdr command-line-args-left))
     (cond ((eq method 'dir)
-          (www-page-display-dir target size image-root lang)
+          (www-page-display-dir target size image-root lang
+                                nil nil hide-cgi)
           )
          ((eq method 'page)
-          (www-page-display-page target size image-root lang)
+          (www-page-display-page target size image-root lang
+                                 nil nil hide-cgi)
           )
          (t
           (www-page-display-image target size image-root)