#! =GUILE_BINDIR=/guile -s
=AUTOGENERATED=
!#
;;;; Greek Dictionary Web Engine
;;;; Copyright (C) 2004, 2005 Sergey Poznyakoff
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;;;
;;; Tailor this statement to your needs if necessary.
;=GUILE_COMMENT=;(set! %load-path (cons "=GUILE_SITE=" %load-path))
(use-modules (www cgi)
(gamma sql)
(gamma gettext)
(xmltools dict)
(ellinika xlat)
(ellinika cgi))
(cgi:init)
(ellinika-cgi-init dict-template-file-name)
;; Τα μέρη του λογου
(define part-of-speech '())
(define (load-pos)
(let ((conn (sql-connect
sql-iface sql-host sql-port sql-database
sql-username sql-password)))
(cond
(conn
(let ((plist (sql-query
conn
"SELECT name,id FROM pos WHERE canonical='Y' order by id")))
(set! part-of-speech
(cons
(cons "κανένα μέρος του λόγου" #f)
(map
(lambda (x)
(cons (car x) (cadr x)))
plist))))
(sql-connect-close conn)))))
;; Protect occurences of " in a string.
;; Usual backslash escapes do not work in INPUT widgets, so I
;; change all quotation marks to "
;; Possibly not the better solution, though...
(define (protect string)
(list->string
(apply append
(map
(lambda (x)
(if (eq? x #\")
(list #\& #\# #\3 #\4 #\;)
(list x)))
(string->list string)))))
(define (get-topic-list)
(let ((categories #f))
(letrec ((getcat
(lambda ()
(let ((conn (sql-connect sql-iface sql-host sql-port sql-database
sql-username sql-password)))
(cond
(conn
(let ((categories (sql-query
conn
"SELECT category, title, description FROM category ORDER BY category")))
(let ((result (if (null? categories)
'()
(map
(lambda (category)
(let ((topics (sql-query
conn
(string-append
"SELECT ident,title FROM topic WHERE category="
(car category)
" ORDER BY title"))))
(append category (if (null? topics)
'()
(list topics)))))
categories))))
(sql-connect-close conn)
result)))
(else
'()))))))
(if (not categories)
(set! categories (getcat)))
categories)))
(define (join-widget widget-id tabindex)
(let* ((name (string-append "join" widget-id))
(selected-choice (or (let ((s (cgi:value name)))
(if s
(string->number s)
#f))
0)))
(display (string-append "")))
(define (main-form)
(load-pos)
(display "