Browse Source

You can change translations of a displayed chapter text.

master
Silas Vedder 2 years ago
parent
commit
1495b41247
  1. 57
      chapter.lisp
  2. 1
      cl-bible.asd
  3. 4
      cl-bible.lisp
  4. 52
      clog.lisp
  5. 11
      data.lisp
  6. 12
      package.lisp
  7. 3
      verse.lisp

57
chapter.lisp

@ -0,0 +1,57 @@
(in-package #:cl-bible.chapter)
(defun book/chapter-window (canvas title)
(let* ((win (window-content
(create-gui-window canvas
:title title
:height 400
:width 650)))
(mbar (create-gui-menu-bar win))
(drop-down (create-gui-menu-drop-down mbar :content "Translations")))
(values (create-div win)
drop-down)))
(defmacro translations-drop-down ()
`(progn
,@(mapcar
(lambda (translation)
`(labels ((verse-to-clog (verse)
(v:verse-to-clog verse
div
:translation ,(second translation)))
(hide-verse (verse) (setf (hiddenp verse) t))
(callback (obj)
(declare (ignore obj))
(mapc #'hide-verse display)
(setf display (mapcar #'verse-to-clog verses))))
(create-gui-menu-item drop-down
:content ,(first translation)
:on-click #'callback)))
d:*translations*)))
(defun display-chapter-or-book (canvas title verses)
(multiple-value-bind (div drop-down)
(book/chapter-window canvas title)
(flet ((verse-to-clog (verse)
(v:verse-to-clog verse
div
:translation d:*translation*)))
(let ((display (mapcar #'verse-to-clog verses)))
(translations-drop-down)))))
(defun load-chapter (canvas book chapter)
(display-chapter-or-book canvas
(format nil "~A: ~A ~A"
d:*translation*
book
chapter)
(s:find-chapter
(s:find-book d:*bible* book)
chapter)))
(defun load-book (canvas book)
(display-chapter-or-book canvas
(format nil "~A: ~A"
d:*translation*
book)
(s:find-book d:*bible* book)))

1
cl-bible.asd

@ -8,6 +8,7 @@
:serial t :serial t
:depends-on (#:str #:clog) :depends-on (#:str #:clog)
:components ((:file "package") :components ((:file "package")
(:file "chapter")
(:file "verse") (:file "verse")
(:file "search") (:file "search")
(:file "lift-search") (:file "lift-search")

4
cl-bible.lisp

@ -3,7 +3,9 @@
(in-package #:cl-bible) (in-package #:cl-bible)
(defun start () (defun start ()
(initialize #'c:on-new-window) (initialize (lambda (body)
(setf cl-bible.clog::body body)
(c:on-new-window body)))
(open-browser)) (open-browser))
(defun main () (defun main ()

52
clog.lisp

@ -2,6 +2,8 @@
(in-package #:cl-bible.clog) (in-package #:cl-bible.clog)
(defvar *body*)
(defun lift-search-window (body search) (defun lift-search-window (body search)
(let ((result (mapcar #'car (l:lift-search search))) (let ((result (mapcar #'car (l:lift-search search)))
(win (create-gui-window body))) (win (create-gui-window body)))
@ -13,6 +15,24 @@
(defun ergebnis/se (n) (defun ergebnis/se (n)
(format nil "~A Ergebnis~A" n (if (= n 1) "" "se"))) (format nil "~A Ergebnis~A" n (if (= n 1) "" "se")))
(defun test (canvas)
(create-gui-window canvas :title "Test"
:height 400
:width 300))
(defun test (canvas)
(let* ((win (window-content
(create-gui-window canvas :title "Test"
:height 300
:width 400)))
(button (create-button win :content "click me!"))
(div (create-div win)))
(create-p div :content "foo")
(set-on-click button (lambda (obj)
(declare (ignore obj))
(format t "Clicked button!")))
div))
(defun search-in-bible (phrase bible canvas) (defun search-in-bible (phrase bible canvas)
(let* ((win (window-content (let* ((win (window-content
(create-gui-window canvas (create-gui-window canvas
@ -83,35 +103,8 @@
(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=))))
(if (string= chapter "") (if (string= chapter "")
(load-book canvas book) (ch:load-book canvas book)
(load-chapter canvas book chapter))))) (ch:load-chapter canvas book chapter)))))
(defun book/chapter-window (canvas title)
(create-div
(window-content
(create-gui-window canvas
:title title
:height 400
:width 650))))
(defun load-book (canvas book)
(let ((div (book/chapter-window canvas
(format nil "~A: ~A"
d:*translation*
book))))
(mapc (lambda (verse)
(v:verse-to-clog verse div :translation d:*translation*))
(s:find-book d:*bible* book))))
(defun load-chapter (canvas book chapter)
(let ((div (book/chapter-window canvas
(format nil "~A: ~A ~A"
d:*translation*
book
chapter))))
(mapc (lambda (verse)
(v:verse-to-clog verse div :translation d:*translation*))
(s:find-chapter (s:find-book d:*bible* book) chapter))))
(defun get-chapter (window body) (defun get-chapter (window body)
(lambda (obj) (lambda (obj)
@ -162,6 +155,7 @@
(d:load-bibles))))) (d:load-bibles)))))
(defun on-new-window (body) (defun on-new-window (body)
(setf *body* body)
(setf (title (html-document body)) "Bible") (setf (title (html-document body)) "Bible")
(clog-gui-initialize body) (clog-gui-initialize body)
(setup-menu-bar body (setup-window body))) (setup-menu-bar body (setup-window body)))

11
data.lisp

@ -2,6 +2,17 @@
(in-package #:cl-bible.data) (in-package #:cl-bible.data)
(defvar *translations* '(("Menge" :mng)
("King James Version" :kjv)
("Vulgata" :vul)
("Greek Bible" :grb)
("Elberfelder Übersetzung 1871" :elb1871)
("NEÜ" :neue)
("Luther 1545" :luth1545)
("Luther 1912" :luth1912)
("Schlachter 1951" :sch1951)
("Ukrainische Version" :ukr)))
(defun load-bible (filename) (defun load-bible (filename)
(v:from-sexp (v:from-sexp
(read-from-string (read-from-string

12
package.lisp

@ -29,6 +29,7 @@
(:export update-bible (:export update-bible
*bible* *bible*
*translation* *translation*
*translations*
persist persist
load-bibles)) load-bibles))
@ -39,12 +40,21 @@
(#:d #:cl-bible.data)) (#:d #:cl-bible.data))
(:export lift-search)) (:export lift-search))
(defpackage #:cl-bible.chapter
(:use #:cl #:clog #:clog-gui)
(:local-nicknames (#:d #:cl-bible.data)
(#:s #:cl-bible.search)
(#:v #:cl-bible.verse))
(:export load-chapter
load-book))
(defpackage #:cl-bible.clog (defpackage #:cl-bible.clog
(:use #:cl #:clog #:clog-gui) (:use #:cl #:clog #:clog-gui)
(:local-nicknames (#:l #:cl-bible.lift-search) (:local-nicknames (#:l #:cl-bible.lift-search)
(#:d #:cl-bible.data) (#:d #:cl-bible.data)
(#:s #:cl-bible.search) (#:s #:cl-bible.search)
(#:v #:cl-bible.verse)) (#:v #:cl-bible.verse)
(#:ch #:cl-bible.chapter))
(:export on-new-window)) (:export on-new-window))
(defpackage #:cl-bible (defpackage #:cl-bible

3
verse.lisp

@ -118,7 +118,8 @@
(clog:set-on-click display (clog:set-on-click display
(lambda (obj) (lambda (obj)
(declare (ignore obj)) (declare (ignore obj))
(show-notes verse parent))))) (show-notes verse parent)))
display))
(defgeneric to-sexp (verse)) (defgeneric to-sexp (verse))
(defmethod to-sexp ((verse verse)) (defmethod to-sexp ((verse verse))

Loading…
Cancel
Save