aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--cgi-bin/dico-ellinika.scm430
-rw-r--r--ellinika/Makefile.am5
-rw-r--r--ellinika/cgi.scm436
-rw-r--r--ellinika/config.scm442
5 files changed, 81 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index 288636e..bdf1c00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2008-06-17 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ Rewrite dico-ellinika as a module.
+
+ * ellinika/cgi.scm4: Use (ellinika config) and re-export its
+ public symbols.
+ (base-dir, html-dir, sysconf-dir, locale-path, sql-iface)
+ (sql-host, sql-port, sql-database, sql-username, sql-password)
+ (config-file-name): Remove. Symbols defined in config.scm
+ (ellinika-cgi-init): Call ellinika-config-setup.
+ * ellinika/Makefile.am (guile_DATA): Add config.scm.
+ (config.scm): New rule.
+ * ellinika/config.scm4: New file.
+
+ * cgi-bin/dico-ellinika.scm4: Rewrite as a module. Use (ellinika
+ config), instead of cgi.
+
2008-06-16 Sergey Poznyakoff <gray@gnu.org.ua>
* cgi-bin/dico-ellinika.scm4 (dico-ellinika-init): New function.
diff --git a/cgi-bin/dico-ellinika.scm4 b/cgi-bin/dico-ellinika.scm4
index befc7e5..38d7e08 100644
--- a/cgi-bin/dico-ellinika.scm4
+++ b/cgi-bin/dico-ellinika.scm4
@@ -18,34 +18,16 @@
;;; Tailor this statement to your needs if necessary.
(set! %load-path (cons "GUILE_SITE" %load-path))
+(define-module (dico))
+
(use-modules (guile-user)
(ice-9 rdelim)
(gamma sql)
(xmltools dict)
(ellinika xlat)
- (ellinika cgi))
-
-;; FIXME: These belong to a common module, which should be used by cgi.scm
-;; as well.
-(define sql-iface "mysql") ;; SQL interface ("mysql" or "postgres")
-(define sql-host "localhost") ;; SQL server hostname or a path to the UNIX
- ;; socket
-(define sql-port 3306) ;; SQL port number (0 for sockaddr_un
- ;; connection)
-(define sql-database "ellinika") ;; Name of the database
-(define sql-username "gray") ;; Database user name
-(define sql-password "") ;; Password for that user name
-
-(define-public sysconf-dir "SYSCONFDIR")
-(define-public config-file-name "ellinika.conf")
-
-(define (ellinika-config-setup)
- ;;; Load the site defaults
- (let ((rc-file (string-append sysconf-dir "/" config-file-name)))
- (if (file-exists? rc-file)
- (load rc-file))))
-
-;; These are defined in dict.scm4
+ (ellinika config))
+
+;; FIXME: These are defined in dict.scm4
(define (sql-error-handler err descr)
(format #t "cannot connect to the database")
@@ -322,7 +304,7 @@ Invariant Sections, no Front-Cover and Back-Cover Texts"))
(define (result-count res)
(length (cdr res)))
-(define (dico-ellinika-init arg)
+(define-public (dico-ellinika-init arg)
(list (cons "open" open-module)
(cons "close" close-module)
(cons "descr" descr)
diff --git a/ellinika/Makefile.am b/ellinika/Makefile.am
index 85ead0c..248666d 100644
--- a/ellinika/Makefile.am
+++ b/ellinika/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of Ellinika project.
-# Copyright (C) 2004,2006,2007 Sergey Poznyakoff
+# Copyright (C) 2004,2006,2007,2008 Sergey Poznyakoff
#
# Ellinika is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
guiledir=$(GUILE_SITE)/$(PACKAGE)
-guile_DATA=xlat.scm cgi.scm i18n.scm
+guile_DATA=xlat.scm cgi.scm i18n.scm config.scm
cgi.m4: Makefile
echo 'divert(-1)' > $@
@@ -40,3 +40,4 @@ SUFFIXES = .scm4 .scm
m4 cgi.m4 $< > $@
cgi.scm: cgi.scm4 cgi.m4
+config.scm: config.scm4 cgi.m4 \ No newline at end of file
diff --git a/ellinika/cgi.scm4 b/ellinika/cgi.scm4
index 661bd4c..9a7dc11 100644
--- a/ellinika/cgi.scm4
+++ b/ellinika/cgi.scm4
@@ -15,7 +15,12 @@
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;;
-(define-module (ellinika cgi))
+(define-module (ellinika cgi)
+ #:use-module (ellinika config)
+ #:re-export (base-dir html-dir sysconf-dir locale-path
+ sql-iface sql-host sql-port sql-database
+ sql-username sql-password
+ config-file-name ))
(use-modules ifelse(IFACE,[CGI],(www cgi),(guile-user))
(gamma gettext)
@@ -60,13 +65,6 @@ ifelse(IFACE,[CGI],,dnl
;;; User-definable variables
-(define-public base-dir "PREFIX")
-(define-public html-dir "HTMLDIR")
-(define-public sysconf-dir "SYSCONFDIR")
-(define-public locale-path "LOCALEDIR:/usr/share/locale:/usr/local/share/locale")
-(define-public ref-loc #f)
-
-(define-public config-file-name "ellinika.conf")
(define-public dict-template-file-name "dict.html")
(define-public nea-template-file-name "nea.html")
(define-public monima-nea-template-file-name "monima.html")
@@ -74,16 +72,10 @@ ifelse(IFACE,[CGI],,dnl
(define-public word-forms-reference '())
-(define-public sql-iface "mysql") ;; SQL interface ("mysql" or "postgres")
-(define-public sql-host "localhost") ;; SQL server hostname or a path to the UNIX
- ;; socket
-(define-public sql-port 3306) ;; SQL port number (0 for sockaddr_un
- ;; connection)
-(define-public sql-database "ellinika") ;; Name of the database
-(define-public sql-username "gray") ;; Database user name
-(define-public sql-password "") ;; Password for that user name
+(define-public ref-loc #f)
-(define-public match-list-columns 4) ;; Number of colums in fuzzy search output
+;; Number of colums in fuzzy search output
+(define-public match-list-columns 4)
;;; End of user-definable variables
(define-public (language-code lang)
@@ -162,17 +154,15 @@ THUNK.
(define-public (ellinika-cgi-init template-file-name)
;;; Load the site defaults
- (let ((rc-file (string-append sysconf-dir "/" config-file-name)))
- (if (file-exists? rc-file)
- (load rc-file)))
-
-;;; Load the language-specific defaults
+ (ellinika-config-setup)
+
+ ;;; Load the language-specific defaults
(cond
((cgi:value "LANG") =>
(lambda (x)
(if (file-exists? (template-file x template-file-name))
(set! target-language x)))))
-;;; Initialize i18n
+ ;;; Initialize i18n
(let ((x (locale-setup target-language "PACKAGE" locale-path)))
(if x
(set! target-language x))))
diff --git a/ellinika/config.scm4 b/ellinika/config.scm4
new file mode 100644
index 0000000..8032409
--- /dev/null
+++ b/ellinika/config.scm4
@@ -0,0 +1,42 @@
+;;;; -*- scheme -*-
+;;;; Greek Dictionary Web Engine
+;;;; Copyright (C) 2005, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
+;;;;
+
+(define-module (ellinika config))
+
+(define-public base-dir "PREFIX")
+(define-public html-dir "HTMLDIR")
+(define-public sysconf-dir "SYSCONFDIR")
+(define-public locale-path "LOCALEDIR:/usr/share/locale:/usr/local/share/locale")
+(define-public sql-iface "mysql") ;; SQL interface ("mysql" or "postgres")
+;; SQL server hostname or a path to the UNIX socket
+(define-public sql-host "localhost")
+(define-public sql-port 3306) ;; SQL port number (0 for sockaddr_un
+ ;; connection)
+(define-public sql-database "ellinika") ;; Name of the database
+(define-public sql-username "gray") ;; Database user name
+(define-public sql-password "") ;; Password for that user name
+
+(define-public config-file-name "ellinika.conf")
+
+(define-public (ellinika-config-setup)
+ ;;; Load the site defaults
+ (let ((rc-file (string-append sysconf-dir "/" config-file-name)))
+ (if (file-exists? rc-file)
+ (load rc-file))))
+
+

Return to:

Send suggestions and report system problems to the System administrator.