[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Conclusion Re: SchemeQL



Noel Welsh wrote:

> When code = data, SSI is very easy.  

You don't need much to implement SSI.  For instance, below is the
function that acts as the style-sheet for the site

  http://www.nepls.org/

This code even takes care of printing the file modification time.  All
you need to know is Scheme functions and quasiquote.  The XML library
does the rest.  While the FastCGI stuff is great, you don't absolutely
need that either, unless performance is a high priority.  If you're
trying to just do something simple, it's easy!

(define (make-nepls-page title bodies)
  `(html ()
	 (head ()
	       (title ()
		      ,(format-title title)))
	 (body ((bgcolor "white")
		(text "black"))
	       (p ()
		  (table ((width "100%"))
			 (tr ((valign "top"))
			     (td ()
				 (center ()
					 ,logo-img)
				 (br ())
				 (center ()
					 (font ((size "+2"))
					       "N" (br ())
					       "E" (br ())
					       "P" (br ())
					       "L" (br ())
					       "S")))
			     (td ()
				 ,@bodies))))
	       (hr)
	       (p ()
		  (table ((width "100%"))
			 (tr ()
			     (td ((align "LEFT"))
				 "Last modified "
				 ,(date->string
				   (seconds->date
				    (file-or-directory-modify-seconds
				     "./gen.ss"))
				   #t))
			     (td ((align "RIGHT"))
				 "Powered by "
				 (a ((href "http://www.plt-scheme.org/";))
				    (img ((align "CENTER")
					  (src "http://www.cs.rice.edu/CS/PLT/plt-logo.gif";)
					  (width "91")
					  (height "31")
					  (alt "PLT")))))))))))

Or consider the talk schedule table, as on

  http://www.nepls.org/Events/3/

Here's a function that generates that:

(define schedule-table 
  `(table ()
	  ,@(map (lambda (db-entry)
		   (let-values ([(time type tag/label)
				 (apply values db-entry)])
			       `(tr ()
				    (td ((align "center")
					 (valign "top"))
					,time)
				    ,(if (eq? type 'talk)
					 (let ([talk-db-entry
						(assoc tag/label talk-db)])
					   `(td ((align "left"))
						(a ((href
						     ,(string-append
						       abstracts-file-name
						       "#"
						       tag/label)))
						   ,(cadr talk-db-entry))
						(br ())
						,(caddr talk-db-entry)))
					 `(td ((align "left"))
					      ,tag/label)))))
		 schedule-db)))

Shriram