John Fremlin's blog: Teepeedee2 released!

Posted 2009-05-24 08:30:00 GMT

Finally, I've got round to releasing my Common Lisp web application platform.

It is running this blog which has the rather unique feature that comments pop up immediately for everybody whenever anybody comments on an article.

It is faster than all(?) other web application frameworks. Please let me know if you can find a faster one! I gave a talk with benchmarks at the Tokyo Linux User Group.

The main code is at github.

git clone git://github.com/vii/teepeedee2.git

[UPDATE — thanks for your input slashdot and for finding a bug for me triggered by lots of comments. I've patched it now . . .]

And here is the code that runs this blog

(in-package #:tpd2.blog)
 
(defun tech-css ()
  (css-html-style 
    ((".inherit" <input <a)
     :text-decoration "inherit" :color "inherit" 
     :background-color "inherit" 
     :font-size "inherit" :font-weight "inherit"
     :font-family "inherit" 
     :border "none" :padding "0 0 0 0" :margin "0 0 0 0")
    ((<body "h1.title")
      :margin "0 0 0 0"
      :padding "0 0 0 0")
    (<body
      :font-family "georgia, serif"
      :font-weight "lighter"
      :color "black"
      :background-color "white")
    ("[onclick]" :cursor "pointer")
    (".blog-entry-post-comment [onclick]"
     :text-decoration "underline")
    ("div.comment:first-child" 
     :margin-top "3em")
    (".blog-entry"
     :margin-left "2em"
     :margin-right "2em")
    (".blog-entry-story, .blog-entry-comments"
     :font-size "1.3em"
     :x-column-width "30em"
     :x-column-gap "2em")
    (".blog-entry-story P + P"
     :text-indent "1em")
    (".blog-entry-story A"
     :text-decoration "underline")
    (".blog-entry-story P"
     :line-height "1.6em")
    ((<h1 <h2 <h3 <h4)
      :font-family "verdana, sans-serif"
      :font-weight "lighter"
      :font-stretch "narrower"
      :letter-spacing "0.09em"
     :margin-left "1em"
     :margin-right "1em")
    (<h2 :font-size "200%")
    ("h1.title"
      :padding-top "1em"
      :text-align "right"
      :font-size "300%"
      :color "white"
      :background-color "rgb(76,6,81)")
    (".blog-entry-post-comment textarea" 
      :width "100%"
      :height "30em")
    (".time"
     :x-opacity 0.60
     :margin-right "16%"
     :text-align "right"
     :font-size "50%")
    (".time .author"
     :font-size "200%")
    (".blog-entry-post-comment [name=AUTHOR]" 
     :border-bottom "thin solid")))
(defsite *tech-blog-site*
    :dispatcher "127.0.0.1:11111"
    :page-body-start (lambda(title)
		       `(<div :class "header"				      
			      (<h1 :class "title" 
			      	      (<a :href "/" (output-raw-ml ,title)))))
    :page-head (lambda(title)
		 `(with-ml-output
		   (<title (output-raw-ml ,title))
		   (tech-css)
		   (webapp-default-page-head-contents))))
(defparameter *tech* 
  (make-blog 
   :link-base "/" 
   :comment-index-prefix "vii" 
   :name "John Fremlin's blog" :dir "...." 
   :static-base-url "/static-blog/" 
   :site *tech-blog-site*
   :admin-password-file "...."))
(defun read-in-blog ()
  (blog-read-in *tech*))
(in-package #:teepeedee2)
#.(when (find-package :swank)
    (push :tpd2-has-swank *features*)
    nil)
(defun run-thread (name function)
  (with-preserve-specials (*trace-output* 
  			  *standard-output* 
  			  *error-output* 
			  *debug-io*
			  #+tpd2-has-swank 
			  swank::*emacs-connection*)
    (flet ((func ()
	     (with-specials-restored
		 (funcall function))))
      #+sbcl
      (sb-thread:make-thread #'func :name name)
      #+ccl
      (ccl:process-run-function name #'func))))
(loop for port in '(11111) do
      (let ((socket (tpd2.io:make-con-listen :port port)))
	(tpd2.io:launch-io 
	'tpd2.io:accept-forever 
	socket 'tpd2.http::http-serve)))
(run-thread "read in blog" (lambda()
			      (loop do
				    (tpd2.blog::read-in-blog)
				    (sleep 300))))
(run-thread "tpd2.io:event-loop" (lambda()
	    (tpd2.datastore:datastore-use-file "datastore.log")
	    (tpd2.io:event-loop)))

Comments should appear instantly for everyone now. I stupidly managed to break them.

I'm going to go through and weed out the test messages and restore the high quality contributions.

Posted 2009-05-26 04:30:55 GMT by John Fremlin

Annoyingly I seem to have broken the automatic comment popups for other people's comments.

I'll have a go at fixing it on my lunch break in an hour.

Posted 2009-05-26 02:12:25 GMT by John Fremlin

So how do I run it?

Progress so far.. on my Ubuntu 9.04.. install the following packages.. sbcl, cl-clfad (apt-get install... then the following seems load everything at put me in the usual LISP loop.

$ sbcl --load teepeedee2.asd

What next?

Posted 2009-05-26 01:08:41 GMT by Paul

As the commenter asked above, how does this square with your assertion below that automated garbage collection is rubbish?

Posted 2009-05-26 00:49:45 GMT by Curious

Beautiful work, and a great example to support using a functional language for another project I'm working on.

Elegant comment box design by the way.

Posted 2009-05-25 17:48:43 GMT by Bill Glover

Do you think you can match the might of of the slashdot effect? Lets see...

Posted 2009-05-25 17:45:12 GMT by CowboyNeal

Posting on a legendary thread.

Posted 2009-05-25 17:44:02 GMT by St. Paul

Just tried this on the new multi-threaded clisp (*features* :MT), but unfortunately clisp on cygwin has no epoll, so I had to give up. Please somebody try the new clisp on linux.

Posted 2009-07-24 11:11:33 GMT by Reini Urban

<script type="text/javascript">

alert("I am an alert box!");

</script>

Posted 2009-08-05 04:46:36 GMT by Anonymous

Oops, sorry guys, my test comments weren't showing up until I refreshed the entire page. I'll stop bother you now.

Posted 2009-08-09 17:50:33 GMT by Patrick

No they're not. Only the *first* comment I make after refreshing the page appears instantly.

Posted 2009-08-09 17:51:40 GMT by Patrick

well, now everything's working perfectly. I'll be dog.

Posted 2009-08-09 17:52:30 GMT by Patrick

OK, let's see this instant comment thing.

Posted 2009-09-19 10:46:09 GMT by Anonymous

Feel free to test the instantaneous nature of the comments!

Posted 2009-09-19 13:48:10 GMT by John Fremlin

Wunderbar

Posted 2009-10-06 22:31:11 GMT by Anonymous

I love this, it's awesome!

Posted 2009-10-09 19:55:28 GMT by Henrik

Bravo!

Posted 2009-10-11 19:20:26 GMT by exedre

I dare you to display this!

Posted 2009-10-31 00:02:47 GMT by me

Leaving my mark on the world.. one tree at a time

Posted 2009-12-04 00:21:24 GMT by Anonymous

a great piece of software.

Posted 2010-01-19 15:53:06 GMT by Anonymous

Sounds interesting! (And I have to test the comment function. :-) By the way, do you store the IP addresses?)

Posted 2010-11-25 17:07:43 GMT by Anonymous from 85.183.67.144

Is this platform better than Hunchentoot?

Posted 2011-04-26 18:17:18 GMT by Anonymous from 194.44.160.78

Is there a similar framework in scheme?

Posted 2011-06-14 13:16:03 GMT by Anonymous from 144.36.189.69

One more time, then I'll check out the source code.

Posted 2012-02-24 16:46:18 GMT by Anonymous from 108.77.157.187

Cool looking idea. I hope to explore this area myself for my dissertation next year.

Posted 2012-04-17 12:10:28 GMT by Anonymous from 193.1.74.93

Does this still work?

Posted 2015-09-25 12:38:16 GMT by Anonymous from 84.109.235.187

Post a comment