Initial commit

This commit is contained in:
Tom Willemsen 2013-03-20 21:58:10 +01:00
commit 94f56cd473
6 changed files with 75 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
clark
*.db

2
Makefile Normal file
View file

@ -0,0 +1,2 @@
clark: clark.lisp
sbcl --load make-image.lisp

14
clark.asd Normal file
View file

@ -0,0 +1,14 @@
(defpackage :clark-system
(:use :cl :asdf))
(in-package :clark-system)
(defsystem :clark
:name "CLark"
:author "Tom Willemsen <tom@ryuslash.org>"
:version "0.0.1"
:maintainer "Tom Willemsen <tom@ryuslash.org>"
:description "Keep bookmarks, in lisp."
:serial t
:depends-on (:mcclim)
:components ((:file "package")
(:file "clark")))

39
clark.lisp Normal file
View file

@ -0,0 +1,39 @@
(in-package :org.ryuslash.clark)
(export '(clark))
(defvar *db* nil
"The database connection.")
(defun db-connect (name)
"Connect to the database, possibly creating it."
(let ((db-exists (probe-file name)))
(connect (list name) :database-type :sqlite3)
(unless db-exists
(create-view-from-class 'bookmark)
(create-view-from-class 'tag)
(create-view-from-class 'bookmark-tag))))
(defun print-bookmark (bm)
"Print information about bookmark BM.
BM should be a list containing the url and name of the bookmark."
(destructuring-bind (url name) bm
(format t "~A~%~A~%~%" url name)))
(defun get-bookmarks ()
"Get a list of all bookmarks.
The result contains the url and the name of the bookmark."
(loop
with statement = (prepare-statement
*db* "select url, name from bookmark")
while (step-statement statement)
collect (list (statement-column-value statement 0)
(statement-column-value statement 1))
finally (finalize-statement statement)))
(defun clark ()
(setf *db* (connect "test.db"))
(map nil #'print-bookmark (get-bookmarks))
(disconnect *db*))

16
make-image.lisp Normal file
View file

@ -0,0 +1,16 @@
#-sbcl
(error "This lisp implementation iss not supported.")
(require 'asdf)
(require 'sqlite)
(require 'mcclim)
(asdf:oos 'asdf:load-op 'clark)
(save-lisp-and-die
"clark" :toplevel
(lambda ()
(sb-posix:putenv (format nil "SBCL_HOME=~A" #.(sb-ext:posix-getenv "SBCL_HOME")))
(org.ryuslash.clark:clark)
0)
:executable t)

2
package.lisp Normal file
View file

@ -0,0 +1,2 @@
(defpackage :org.ryuslash.clark
(:use :clim :clim-lisp :sqlite))