File: images.scm

package info (click to toggle)
rscheme 0.7.3pre.1.b39-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 10,036 kB
  • ctags: 14,141
  • sloc: lisp: 40,528; ansic: 40,480; sh: 3,134; cpp: 2,630; makefile: 790; yacc: 202; lex: 175; perl: 20; asm: 13
file content (29 lines) | stat: -rw-r--r-- 883 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

(define (real-html-page-dispatch path)
  (console "real-page: ~s\n" path)
  (let* ((pathn (string->file (string-join #\/ path)))
	 (type (assoc (extension pathn)
		     '(("gif" image/gif)
		       ("jpg" image/jpeg)
		       ("html" text/html)))))
    (if type
	(let ((sub (append-path *root-path* pathn))
	      (t (cadr type)))
	  (console "Checking subfile of [root]: ~a\nfull path: ~a\n"
		   (string-join "/" path) 
		   sub)
	  (let ((s (stat (pathname->os-path sub))))
	    (if s
		(begin
		  (console " File exists (~d bytes), will return type ~s\n"
			   (stat-size s)
			   t)
		  (case t
		    ((text/html)
		     (console " ** will run through pagefilter **\n")
		     (filtered-html-page path pathn))
		    ((image/gif image/jpeg)
		     (display (file->string (pathname->os-path sub)))
		     t)))
		(error/url-not-found *query*))))
	(error/url-not-found *query*))))