| Paste number 121537: | classical |
| Pasted by: | docgnome |
| When: | 1 year, 1 month ago |
| Share: | Tweet this! | http://paste.lisp.org/+2LS1 |
| Channel: | #chicken |
| Paste contents: |
(use awful awful-postgresql spiffy html-tags postgresql autoform autoform-jquery autoform-postgresql)
(enable-db)
(db-credentials '((dbname . "classical")
(user . "*******")
(password . "********")
(host . "******")))
;;(debug-file "err.log")
;(debug-db-query? #t)
(define-page (main-page-path)
(lambda ()
(let ((& ($db "select * from suggestions order by listened, composer")))
(++
(<p> "Welcome to the Freenode ##classical Piece of the Month Suggestions db!")
(<a> href: "/suggestion/new" "Make a suggestion")
(apply <table> border: 1
(<tr>
(<th> "Piece")
(<th> "Composer")
(<th> "Suggester")
(<th> "Listened")
(<th> "Listened On"))
(map (lambda (c)
(<tr>
(<td> (htmlize (list-ref c 1)))
(<td> (htmlize (list-ref c 2)))
(<td> (htmlize (list-ref c 3)))
(<td> (if (list-ref c 4)
"Yes"
"No"))
(<td> (list-ref c 5))))
&))))))
(define-page "/suggestion/new"
(lambda ()
(let ((form-obj
(autoform "suggestions"
(db-connection)
list-layout: '(piece composer suggester)
form-action: "/suggestion/submit")))
(++ (<p> "Please be sure to include the Catalog number in the name of the piece if you can.")
(<a> href: "/" "Return to the suggestions list")
(form-obj 'javascript)
(form-obj 'html)))))
(define-page "/suggestion/submit"
(lambda ()
(cond ((= (affected-rows
(query (db-connection)
"insert into suggestions (piece, composer, suggester) values ($1, $2, $3)"
($ 'piece)
($ 'composer)
($ 'suggester))) 1)
(++ (<p> "Thanks for the suggestion!")
(<a> href: "/" "Return to the suggestions list")))
(else (++ (<p> "Ruh-oh! Something went wrong!")
(<a> href: "/" "Return to the suggestions list"))))))
This paste has no annotations.