aboutsummaryrefslogtreecommitdiff
path: root/src/ellinika
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-06-22 07:33:31 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-06-22 07:33:31 +0000
commit4eb48d2f187bc9bb3266cee025da2ea61270e4c4 (patch)
treea99c057485f72d9074d22ea518804a4c8d2eb5bb /src/ellinika
parent64af4748a2cae68c7ff4aa48d3dc7c93a2d469f6 (diff)
downloadellinika-4eb48d2f187bc9bb3266cee025da2ea61270e4c4.tar.gz
ellinika-4eb48d2f187bc9bb3266cee025da2ea61270e4c4.tar.bz2
Move cgi-bin and ellinika to src.
* src: New dir * src/Makefile.am: New file. * cgi-bin, ellinika: Move to src. * configure.ac: Reflect the above changes. git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@525 941c8c0f-9102-463b-b60b-cd22ce0e6858
Diffstat (limited to 'src/ellinika')
-rw-r--r--src/ellinika/Makefile.am43
-rw-r--r--src/ellinika/cgi.scm4169
-rw-r--r--src/ellinika/config.scm442
-rw-r--r--src/ellinika/dico.scm306
-rw-r--r--src/ellinika/i18n.scm308
-rw-r--r--src/ellinika/xlat.scm309
6 files changed, 1177 insertions, 0 deletions
diff --git a/src/ellinika/Makefile.am b/src/ellinika/Makefile.am
new file mode 100644
index 0000000..136b44f
--- /dev/null
+++ b/src/ellinika/Makefile.am
@@ -0,0 +1,43 @@
1# This file is part of Ellinika project.
2# Copyright (C) 2004,2006,2007,2008 Sergey Poznyakoff
3#
4# Ellinika is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# Ellinika is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17guiledir=$(GUILE_SITE)/$(PACKAGE)
18guile_DATA=xlat.scm cgi.scm i18n.scm config.scm dico.scm
19
20cgi.m4: Makefile
21 echo 'divert(-1)' > $@
22 echo 'changequote([,])' >> $@
23 echo 'changecom([;],[' >> $@
24 echo '])' >> $@
25 echo 'undefine([format])' >> $@
26 echo 'define([IFACE],$(APACHE_IFACE))' >> $@
27 echo 'define([GUILE_BINDIR],$(GUILE_BINDIR))' >> $@
28 echo 'define([GUILE_SITE],@GUILE_SITE@)' >> $@
29 echo 'define([PACKAGE],$(PACKAGE))'>> $@
30 echo 'define([PREFIX],$(prefix))' >> $@
31 echo 'define([SYSCONFDIR],$(sysconfdir))' >> $@
32 echo 'define([LOCALEDIR],$(datadir)/locale)' >> $@
33 echo 'define([HTMLDIR],$(HTMLDIR))' >> $@
34 echo 'divert(0)dnl' >> $@
35 echo '@AUTOGENERATED@' >> $@
36
37SUFFIXES = .scm4 .scm
38
39.scm4.scm:
40 m4 cgi.m4 $< > $@
41
42cgi.scm: cgi.scm4 cgi.m4
43config.scm: config.scm4 cgi.m4
diff --git a/src/ellinika/cgi.scm4 b/src/ellinika/cgi.scm4
new file mode 100644
index 0000000..38fd3de
--- /dev/null
+++ b/src/ellinika/cgi.scm4
@@ -0,0 +1,169 @@
1;;;; -*- scheme -*-
2;;;; Greek Dictionary Web Engine
3;;;; Copyright (C) 2005, 2007 Sergey Poznyakoff
4;;;;
5;;;; This program is free software; you can redistribute it and/or modify
6;;;; it under the terms of the GNU General Public License as published by
7;;;; the Free Software Foundation; either version 3 of the License, or
8;;;; (at your option) any later version.
9;;;;
10;;;; This program is distributed in the hope that it will be useful,
11;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13;;;; GNU General Public License for more details.
14;;;;
15;;;; You should have received a copy of the GNU General Public License
16;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17;;;;
18(define-module (ellinika cgi)
19 #:use-module (ellinika config)
20 #:use-module (ellinika i18n)
21 #:use-module ifelse(IFACE,[CGI],(www cgi),(guile-user))
22 #:re-export (base-dir html-dir sysconf-dir locale-path
23 sql-iface sql-host sql-port sql-database
24 sql-username sql-password
25 config-file-name ))
26
27
28ifelse(IFACE,[CGI],,dnl
29(define form-data
30 (append
31 (parse-form-data
32 (table:get (request-rec:subprocess-env Request) "QUERY_STRING"))
33 (if (= (request-rec:method-number Request) 2)
34 (parse-form-data (read-post-data Request))
35 '())))
36
37(define-public (cgi:value name)
38 (assoc-ref form-data name))
39
40(define-public (cgi:names)
41 (map car form-data))
42
43(define-public cgi-script-name
44 (table:get (request-rec:subprocess-env Request)
45 "SCRIPT_NAME"))
46
47(define-public cgi-server-hostname
48 (table:get (request-rec:subprocess-env Request)
49 "SERVER_NAME"))
50
51(define-public cgi-server-protocol-name #f)
52(define-public cgi-server-protocol-version #f)
53
54(let* ((server-protocol (table:get (request-rec:subprocess-env Request)
55 "SERVER_PROTOCOL")))
56 (if server-protocol
57 (let ((slash (string-index server-protocol #\/)))
58 (set! cgi-server-protocol-name (substring server-protocol
59 0 slash))
60 (set! cgi-server-protocol-version (substring server-protocol
61 (1+ slash))))))
62
63)
64
65
66;;; User-definable variables
67(define-public dict-template-file-name "dict.html")
68(define-public nea-template-file-name "nea.html")
69(define-public monima-nea-template-file-name "monima.html")
70(define-public target-language "el_GR")
71
72(define-public word-forms-reference '())
73
74(define-public ref-loc #f)
75
76;; Number of colums in fuzzy search output
77(define-public match-list-columns 4)
78;;; End of user-definable variables
79
80(define-public (language-code lang)
81 (cond
82 ((string-index lang #\_) =>
83 (lambda (len)
84 (substring lang 0 len)))
85 (else
86 lang)))
87
88(define-public (template-file lang template-file-name)
89 (string-append html-dir "/" (language-code lang) "/" template-file-name))
90
91(define-public (make-cgi-name cgi-path . rest)
92 (apply
93 string-append
94 (cons
95 cgi-path
96 (let ((arglist (let ((lang (cgi:value "LANG")))
97 (do ((ilist (if lang
98 (cons "LANG" (cons lang rest))
99 rest) (cdr ilist))
100 (i 1 (1+ i))
101 (olist '()))
102 ((null? ilist) (if (null? olist)
103 olist
104 (reverse (cdr olist))))
105 (set! olist (cons (car ilist) olist))
106 (set! olist (cons
107 (if (odd? i) "=" "&amp;")
108 olist))))))
109 (if (null? arglist)
110 arglist
111 (cons "?" arglist))))))
112
113(define-public (expand-template explist template)
114 "(expand-template EXPLIST TEMPLATE)
115
116Expands string TEMPLATE in accordance with EXPLIST. EXPLIST is a list
117of elements:
118
119 (cons WORD THUNK)
120
121Each occurrence of WORD in TEMPLATE is replaced with the return value of
122THUNK.
123"
124 (let loop ((template template))
125 (cond
126 ((string-index template #\@) =>
127 (lambda (w)
128 (display (substring template 0 w))
129 (if (and (< (+ w 2) (string-length template))
130 (char=? (string-ref template (1+ w)) #\@))
131 (let ((end-pos (string-index template #\@ (+ w 2))))
132 (if (and end-pos
133 (< (1+ end-pos) (string-length template))
134 (char=? (string-ref template (1+ end-pos)) #\@))
135 (let* ((name (substring template w (+ end-pos 2)))
136 (entry (assoc name explist)))
137 (cond
138 (entry
139 ((cdr entry))
140 (loop (substring template (+ end-pos 2))))
141 (else
142 (display "@@")
143 (loop (substring template (+ w 2))))))
144 (begin
145 (display "@")
146 (loop (substring template (+ w 1))))))
147 (begin
148 (display "@")
149 (loop (substring template (1+ w)))))))
150 (else
151 (display template)))))
152
153
154(define-public (ellinika-cgi-init template-file-name)
155 ;;; Load the site defaults
156 (ellinika-config-setup)
157
158 ;;; Load the language-specific defaults
159 (cond
160 ((cgi:value "LANG") =>
161 (lambda (x)
162 (if (file-exists? (template-file x template-file-name))
163 (set! target-language x)))))
164 ;;; Initialize i18n
165 (let ((x (locale-setup target-language "PACKAGE" locale-path)))
166 (if x
167 (set! target-language x))))
168
169;;; End of cgi.scmi
diff --git a/src/ellinika/config.scm4 b/src/ellinika/config.scm4
new file mode 100644
index 0000000..8032409
--- /dev/null
+++ b/src/ellinika/config.scm4
@@ -0,0 +1,42 @@
1;;;; -*- scheme -*-
2;;;; Greek Dictionary Web Engine