Browse Source

Load books, init bibles correctly, corrections.

master
Silas Vedder 3 years ago
parent
commit
1cf3e19148
  1. 27
      clog.lisp
  2. 24
      data.lisp
  3. 2
      verse.lisp

27
clog.lisp

@ -46,11 +46,28 @@
(d:update-bible (cadar results)) (d:update-bible (cadar results))
:title "Load a Bible")))) :title "Load a Bible"))))
(defun load-chapter (canvas) (defun load-book-or-chapter (canvas)
(lambda (data) (lambda (data)
(let* ((book (cadr (assoc "book" data :test #'string=))) (let* ((book (cadr (assoc "book" data :test #'string=)))
(chapter (cadr (assoc "chapter" data :test #'string=))) (chapter (cadr (assoc "chapter" data :test #'string=))))
(win (window-content (if (string= chapter "")
(load-book canvas book)
(load-chapter canvas book chapter)))))
(defun load-book (canvas book)
(let* ((win (window-content
(create-gui-window canvas :title (format nil "~A"
book)
:height 400
:width 650)))
(div (create-div win)))
(mapc (lambda (verse)
(v:verse-to-clog verse div))
(s:find-book d:*bible* book))))
(defun load-chapter (canvas book chapter)
(let* ((win (window-content
(create-gui-window canvas :title (format nil "~A ~A" (create-gui-window canvas :title (format nil "~A ~A"
book book
chapter) chapter)
@ -59,7 +76,7 @@
(div (create-div win))) (div (create-div win)))
(mapc (lambda (verse) (mapc (lambda (verse)
(v:verse-to-clog verse div)) (v:verse-to-clog verse div))
(s:find-chapter (s:find-book d:*bible* book) chapter))))) (s:find-chapter (s:find-book d:*bible* book) chapter))))
(defun get-chapter (window body) (defun get-chapter (window body)
(lambda (obj) (lambda (obj)
@ -67,7 +84,7 @@
(form-dialog window "Which chapter do you want?" (form-dialog window "Which chapter do you want?"
'(("Book" "book" :text) '(("Book" "book" :text)
("Chapter" "chapter" :text)) ("Chapter" "chapter" :text))
(load-chapter body) (load-book-or-chapter body)
:title "Load a Chapter"))) :title "Load a Chapter")))
(defun setup-window (body) (defun setup-window (body)

24
data.lisp

@ -3,29 +3,37 @@
(in-package #:cl-bible.data) (in-package #:cl-bible.data)
(defun init-bible (&optional (bible "mng")) (defun init-bible (&optional (bible "mng"))
(setf *bible*
(mapcar #'v:string-to-verse (mapcar #'v:string-to-verse
(uiop:read-file-lines (uiop:read-file-lines
(asdf:system-relative-pathname (asdf:system-relative-pathname
"cl-bible" "cl-bible"
(format nil "resources/~A.tsv" bible)))))) (format nil "resources/~A.tsv" bible)))))
(defun load-bible (filename) (defun load-bible (filename)
(v:from-sexp (v:from-sexp
(read-from-string (read-from-string
(uiop:read-file-string (uiop:native-namestring filename))))) (uiop:read-file-string (uiop:native-namestring filename)))))
(defvar *mng* (load-bible "~/.bible/menge.sexp")) (defvar *mng*)
(defvar *vul* (load-bible "~/.bible/vulgata.sexp")) (defvar *vul*)
(defvar *grb* (load-bible "~/.bible/greek.sexp")) (defvar *grb*)
(defvar *kjv* (load-bible "~/.bible/kjv.sexp")) (defvar *kjv*)
(defvar *bible* *mng*) (defvar *bible*)
(defun load-bibles () (defun load-bibles ()
(if (uiop:file-exists-p (uiop:native-namestring "~/.bible/menge.sexp"))
(progn
(setf *mng* (init-bible "mng"))
(setf *kjv* (init-bible "kjv"))
(setf *vul* (init-bible "vul"))
(setf *grb* (init-bible "grb")))
(progn
(setf *mng* (load-bible "~/.bible/menge.sexp")) (setf *mng* (load-bible "~/.bible/menge.sexp"))
(setf *vul* (load-bible "~/.bible/vulgata.sexp")) (setf *vul* (load-bible "~/.bible/vulgata.sexp"))
(setf *grb* (load-bible "~/.bible/greek.sexp")) (setf *grb* (load-bible "~/.bible/greek.sexp"))
(setf *kjv* (load-bible "~/.bible/kjv.sexp"))) (setf *kjv* (load-bible "~/.bible/kjv.sexp")))))
(load-bibles)
(defun update-bible (str) (defun update-bible (str)
(let ((bibles `(("mng" . ,*mng*) (let ((bibles `(("mng" . ,*mng*)

2
verse.lisp

@ -65,7 +65,9 @@
:title "Add note"))) :title "Add note")))
(form (clog:create-form win)) (form (clog:create-form win))
(text (clog:create-text-area form :rows 4)) (text (clog:create-text-area form :rows 4))
(_ (clog:create-br form))
(button (clog:create-button form :content "submit"))) (button (clog:create-button form :content "submit")))
(declare (ignore _))
(clog:set-on-click button (clog:set-on-click button
(lambda (obj) (lambda (obj)
(declare (ignore obj)) (declare (ignore obj))

Loading…
Cancel
Save