aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2015-01-10 20:14:14 +0200
committerSergey Poznyakoff <gray@gnu.org>2015-01-10 20:14:14 +0200
commit1c22a86e073d57c4b35ac5b7ffea07aa541141c4 (patch)
treec90f3fc758b5dfc2f8e8fd64f2ef0a87343b3e50
parent2b99881a880d101ae32a94b3d1e0a792224cb74c (diff)
downloadellinika-1c22a86e073d57c4b35ac5b7ffea07aa541141c4.tar.gz
ellinika-1c22a86e073d57c4b35ac5b7ffea07aa541141c4.tar.bz2
Make it possible to use apache rewrite rules to create nice cgi urls
Example: configure with options: --without-script-suffix --without-script-dir, and add the following to the Apache virtual host configuration: RewriteEngine on RewriteRule ^/dict(.*) /cgi-bin/dict.cgi$1 [H=cgi-script] RewriteRule ^/nea(.*) /cgi-bin/nea.cgi$1 [H=cgi-script] RewriteRule ^/conj(.*) /cgi-bin/conj.cgi$1 [H=cgi-script] All cgi's will then be referred to directly, as in: http://ellinika/dict?lang=pl. * configure.ac (REAL_SCRIPT_SUFFIX): New subst var New options --with-script-suffix, --with-script-dir * src/cgi-bin/.gitignore: Remove cgi * src/cgi-bin/Makefile.am: Rename installed scm's in place * src/ellinika/cgi.scm4 (cgi-program-name): Suffix can be empty. * xml/lingua.conf.in: =SCRIPT_SUFFIX= always begins with dot
-rw-r--r--configure.ac33
-rw-r--r--src/cgi-bin/.gitignore2
-rw-r--r--src/cgi-bin/Makefile.am27
-rw-r--r--src/ellinika/cgi.scm42
-rw-r--r--xml/lingua.conf.in6
5 files changed, 48 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac
index 302f2df..7cdcc32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@
17 17
18AC_PREREQ(2.61) 18AC_PREREQ(2.61)
19 19
20AC_REVISION(2015-01-07 14:56:15 gray) 20AC_REVISION(2015-01-10 19:52:52 gray)
21AC_INIT(ellinika, 1.99.99, [gray+ellinika@gnu.org.ua]) 21AC_INIT(ellinika, 1.99.99, [gray+ellinika@gnu.org.ua])
22AC_CONFIG_SRCDIR(src/cgi-bin/dict.scm4) 22AC_CONFIG_SRCDIR(src/cgi-bin/dict.scm4)
23AC_CONFIG_AUX_DIR([build-aux]) 23AC_CONFIG_AUX_DIR([build-aux])
@@ -107,12 +107,13 @@ AC_ARG_VAR([EXP_URL],
107AC_ARG_VAR([STATE], 107AC_ARG_VAR([STATE],
108 [EXP for experimental, PROD for production]) 108 [EXP for experimental, PROD for production])
109 109
110AC_SUBST(REAL_SCRIPT_SUFFIX)
110AC_SUBST(SCRIPT_SUFFIX) 111AC_SUBST(SCRIPT_SUFFIX)
111AC_SUBST(SCRIPT_DIR) 112AC_SUBST(SCRIPT_DIR)
112AC_SUBST(CGIDIR) 113AC_SUBST(CGIDIR)
113 114
114if test $APACHE_IFACE = "CGI"; then 115if test $APACHE_IFACE = "CGI"; then
115 SCRIPT_SUFFIX=cgi 116 REAL_SCRIPT_SUFFIX=.cgi
116 if test -n "$TARGET_DIR"; then 117 if test -n "$TARGET_DIR"; then
117 SCRIPT_DIR=cgi-bin 118 SCRIPT_DIR=cgi-bin
118 else 119 else
@@ -120,11 +121,33 @@ if test $APACHE_IFACE = "CGI"; then
120 fi 121 fi
121 CGIDIR='$(prefix)/cgi-bin' 122 CGIDIR='$(prefix)/cgi-bin'
122else 123else
123 SCRIPT_SUFFIX=scm 124 REAL_SCRIPT_SUFFIX=.scm
124 SCRIPT_DIR=scm 125 SCRIPT_DIR=scm
125 CGIDIR='$(prefix)/scm' 126 CGIDIR='$(prefix)/scm'
126fi 127fi
127 128
129AC_ARG_WITH(script-suffix,
130 AC_HELP_STRING([--with-script-suffix=.STRING],
131 [CGI script suffix]),
132 [if test -z "$withval"; then
133 SCRIPT_SUFFIX=
134 else
135 case $withval in
136 no) SCRIPT_SUFFIX=;;
137 .*) SCRIPT_SUFFIX=$withval;;
138 *) AC_MSG_ERROR([script suffix must begin with dot])
139 esac
140 fi],
141 [SCRIPT_SUFFIX=$REAL_SCRIPT_SUFFIX])
142
143AC_ARG_WITH(script-dir,
144 AC_HELP_STRING([--with-script-dir=DIR],
145 [script directory prefix]),
146 [case $withval in
147 no) SCRIPT_DIR=;;
148 *) SCRIPT_DIR=$withval;;
149 esac])
150
128AC_ARG_WITH(cgi-bin, 151AC_ARG_WITH(cgi-bin,
129 AC_HELP_STRING([--with-cgi-bin=DIR], 152 AC_HELP_STRING([--with-cgi-bin=DIR],
130 [install CGI programs in DIR [[PREFIX/cgi-bin]]]), 153 [install CGI programs in DIR [[PREFIX/cgi-bin]]]),
diff --git a/src/cgi-bin/.gitignore b/src/cgi-bin/.gitignore
index a2d76a3..21128b6 100644
--- a/src/cgi-bin/.gitignore
+++ b/src/cgi-bin/.gitignore
@@ -1,7 +1,5 @@
1dict.cgi
2dict.m4 1dict.m4
3dict.scm 2dict.scm
4dict.sed 3dict.sed
5nea.cgi
6nea.scm 4nea.scm
7conj.scm 5conj.scm
diff --git a/src/cgi-bin/Makefile.am b/src/cgi-bin/Makefile.am
index f085e57..aca9137 100644
--- a/src/cgi-bin/Makefile.am
+++ b/src/cgi-bin/Makefile.am
@@ -14,10 +14,11 @@
14# You should have received a copy of the GNU General Public License 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/>. 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16
17cgidir=@CGIDIR@ 17cgidir = @CGIDIR@
18cgi_SCRIPTS=$(EXTRA_DIST:.scm4=.@SCRIPT_SUFFIX@) 18CGI_SOURCES = dict.scm4 nea.scm4 conj.scm4
19EXTRA_DIST=dict.scm4 nea.scm4 conj.scm4 19EXTRA_DIST = $(CGI_SOURCES)
20CLEANFILES=dict.m4 dict.scm nea.scm dict.cgi nea.cgi conj.cgi 20cgi_SCRIPTS = $(CGI_SOURCES:.scm4=.scm)
21CLEANFILES = dict.m4 $(cgi_SCRIPTS)
21 22
22dict.m4: Makefile 23dict.m4: Makefile
23 $(AM_V_GEN){ \ 24 $(AM_V_GEN){ \
@@ -43,18 +44,22 @@ dict.m4: Makefile
43 echo ')dnl'; \ 44 echo ')dnl'; \
44 } > dict.m4 45 } > dict.m4
45 46
46SUFFIXES = .scm4 .scm .cgi 47SUFFIXES = .scm4 .scm
47 48
48.scm4.scm: 49.scm4.scm:
49 $(AM_V_GEN)m4 dict.m4 $< > $@ 50 $(AM_V_GEN)m4 dict.m4 $< > $@
50 51
51.scm.cgi:
52 $(AM_V_GEN)cp $< $@
53
54dict.scm: dict.scm4 dict.m4 52dict.scm: dict.scm4 dict.m4
55nea.scm: nea.scm4 dict.m4 53nea.scm: nea.scm4 dict.m4
56conj.scm: conj.scm4 dict.m4 54conj.scm: conj.scm4 dict.m4
57 55
58dict.cgi: dict.scm 56install-data-hook:
59nea.cgi: nea.scm 57 $(AM_V_GEN)if test @REAL_SCRIPT_SUFFIX@ != .scm; then\
60conj.cgi: conj.scm 58 here=`pwd`; \
59 cd $(DESTDIR)$(cgidir); \
60 for file in $(cgi_SCRIPTS); do\
61 mv $$file $${file%%.scm}@REAL_SCRIPT_SUFFIX@;\
62 done;\
63 cd $$here;\
64 fi
65
diff --git a/src/ellinika/cgi.scm4 b/src/ellinika/cgi.scm4
index 51f9570..28adea1 100644
--- a/src/ellinika/cgi.scm4
+++ b/src/ellinika/cgi.scm4
@@ -127,7 +127,7 @@ ifelse(IFACE,[CGI],[
127(define-public (cgi-program-name prog) 127(define-public (cgi-program-name prog)
128 (string-append 128 (string-append
129 (substring cgi-script-name 0 (string-rindex cgi-script-name #\/)) "/" 129 (substring cgi-script-name 0 (string-rindex cgi-script-name #\/)) "/"
130 prog ".SCRIPT_SUFFIX")) 130 prog ifelse(SCRIPT_SUFFIX,,,"SCRIPT_SUFFIX")))
131 131
132(define-public (expand-template explist template) 132(define-public (expand-template explist template)
133 "(expand-template EXPLIST TEMPLATE) 133 "(expand-template EXPLIST TEMPLATE)
diff --git a/xml/lingua.conf.in b/xml/lingua.conf.in
index d736bcb..87f40e3 100644
--- a/xml/lingua.conf.in
+++ b/xml/lingua.conf.in
@@ -9,7 +9,7 @@
9 9
10 <AUTHOR EMAIL="=PACKAGE_BUGREPORT=" HOMEPAGE="http://gray.gnu.org.ua" /> 10 <AUTHOR EMAIL="=PACKAGE_BUGREPORT=" HOMEPAGE="http://gray.gnu.org.ua" />
11 11
12 <DICT PROG="dict.=SCRIPT_SUFFIX=" /> 12 <DICT PROG="dict=SCRIPT_SUFFIX=" />
13 <BASE HREF="=BASE_HREF=" /> 13 <BASE HREF="=BASE_HREF=" />
14 <SEARCH ARGS="(list (lingua:gettext &quot;Search&quot;) (lingua:attr &quot;LINGUA&quot; &quot;LANG&quot;))"> 14 <SEARCH ARGS="(list (lingua:gettext &quot;Search&quot;) (lingua:attr &quot;LINGUA&quot; &quot;LANG&quot;))">
15 <![CDATA[ 15 <![CDATA[
@@ -36,7 +36,7 @@
36 (letrec ((nea (lambda (. args) 36 (letrec ((nea (lambda (. args)
37 (string-append 37 (string-append
38 (lingua:get-cgi-bin) 38 (lingua:get-cgi-bin)
39 "/nea.=SCRIPT_SUFFIX=?lang=" 39 "/nea=SCRIPT_SUFFIX=?lang="
40 (lingua:LANG args))))) 40 (lingua:LANG args)))))
41 (xmltrans:set-attr "LINGUA" "NEA" nea))) 41 (xmltrans:set-attr "LINGUA" "NEA" nea)))
42 42
@@ -46,7 +46,7 @@
46 (letrec ((conj (lambda (. args) 46 (letrec ((conj (lambda (. args)
47 (string-append 47 (string-append
48 (lingua:get-cgi-bin) 48 (lingua:get-cgi-bin)
49 "/conj.=SCRIPT_SUFFIX=?lang=" 49 "/conj=SCRIPT_SUFFIX=?lang="
50 (lingua:LANG args))))) 50 (lingua:LANG args)))))
51 (xmltrans:set-attr "LINGUA" "CONJ" conj))) 51 (xmltrans:set-attr "LINGUA" "CONJ" conj)))
52 52

Return to:

Send suggestions and report system problems to the System administrator.