aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-03-20 21:58:10 +0100
committerGravatar Tom Willemsen2013-03-20 21:58:10 +0100
commit94f56cd473dfc950c9263753d3a991b92eff128e (patch)
tree3a57bc39ad91b2f698835823b550ba8baa84527f
downloadclark-94f56cd473dfc950c9263753d3a991b92eff128e.tar.gz
clark-94f56cd473dfc950c9263753d3a991b92eff128e.zip
Initial commit
-rw-r--r--.gitignore2
-rw-r--r--Makefile2
-rw-r--r--clark.asd14
-rw-r--r--clark.lisp39
-rw-r--r--make-image.lisp16
-rw-r--r--package.lisp2
6 files changed, 75 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7788503
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+clark
+*.db
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b2c782b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+clark: clark.lisp
+ sbcl --load make-image.lisp
diff --git a/clark.asd b/clark.asd
new file mode 100644
index 0000000..3b5ef22
--- /dev/null
+++ b/clark.asd
@@ -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")))
diff --git a/clark.lisp b/clark.lisp
new file mode 100644
index 0000000..c233a5a
--- /dev/null
+++ b/clark.lisp
@@ -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*))
diff --git a/make-image.lisp b/make-image.lisp
new file mode 100644
index 0000000..1221037
--- /dev/null
+++ b/make-image.lisp
@@ -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)
diff --git a/package.lisp b/package.lisp
new file mode 100644
index 0000000..9883445
--- /dev/null
+++ b/package.lisp
@@ -0,0 +1,2 @@
+(defpackage :org.ryuslash.clark
+ (:use :clim :clim-lisp :sqlite))