diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2015-01-10 20:14:14 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2015-01-10 20:14:14 +0200 |
commit | 1c22a86e073d57c4b35ac5b7ffea07aa541141c4 (patch) | |
tree | c90f3fc758b5dfc2f8e8fd64f2ef0a87343b3e50 | |
parent | 2b99881a880d101ae32a94b3d1e0a792224cb74c (diff) | |
download | ellinika-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.ac | 33 | ||||
-rw-r--r-- | src/cgi-bin/.gitignore | 2 | ||||
-rw-r--r-- | src/cgi-bin/Makefile.am | 27 | ||||
-rw-r--r-- | src/ellinika/cgi.scm4 | 2 | ||||
-rw-r--r-- | xml/lingua.conf.in | 6 |
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 | |||
@@ -19,3 +19,3 @@ AC_PREREQ(2.61) | |||
19 | 19 | ||
20 | AC_REVISION(2015-01-07 14:56:15 gray) | 20 | AC_REVISION(2015-01-10 19:52:52 gray) |
21 | AC_INIT(ellinika, 1.99.99, [gray+ellinika@gnu.org.ua]) | 21 | AC_INIT(ellinika, 1.99.99, [gray+ellinika@gnu.org.ua]) |
@@ -109,2 +109,3 @@ AC_ARG_VAR([STATE], | |||
109 | 109 | ||
110 | AC_SUBST(REAL_SCRIPT_SUFFIX) | ||
110 | AC_SUBST(SCRIPT_SUFFIX) | 111 | AC_SUBST(SCRIPT_SUFFIX) |
@@ -114,3 +115,3 @@ AC_SUBST(CGIDIR) | |||
114 | if test $APACHE_IFACE = "CGI"; then | 115 | if 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 |
@@ -122,7 +123,29 @@ if test $APACHE_IFACE = "CGI"; then | |||
122 | else | 123 | else |
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' |
126 | fi | 127 | fi |
127 | 128 | ||
129 | AC_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 | |||
143 | AC_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 | |||
128 | AC_ARG_WITH(cgi-bin, | 151 | AC_ARG_WITH(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,2 +1 @@ | |||
1 | dict.cgi | ||
2 | dict.m4 | dict.m4 | |
@@ -4,3 +3,2 @@ dict.scm | |||
4 | dict.sed | 3 | dict.sed |
5 | nea.cgi | ||
6 | nea.scm | 4 | nea.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 | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | cgidir=@CGIDIR@ | 17 | cgidir = @CGIDIR@ |
18 | cgi_SCRIPTS=$(EXTRA_DIST:.scm4=.@SCRIPT_SUFFIX@) | 18 | CGI_SOURCES = dict.scm4 nea.scm4 conj.scm4 |
19 | EXTRA_DIST=dict.scm4 nea.scm4 conj.scm4 | 19 | EXTRA_DIST = $(CGI_SOURCES) |
20 | CLEANFILES=dict.m4 dict.scm nea.scm dict.cgi nea.cgi conj.cgi | 20 | cgi_SCRIPTS = $(CGI_SOURCES:.scm4=.scm) |
21 | CLEANFILES = dict.m4 $(cgi_SCRIPTS) | ||
21 | 22 | ||
@@ -45,3 +46,3 @@ dict.m4: Makefile | |||
45 | 46 | ||
46 | SUFFIXES = .scm4 .scm .cgi | 47 | SUFFIXES = .scm4 .scm |
47 | 48 | ||
@@ -50,5 +51,2 @@ SUFFIXES = .scm4 .scm .cgi | |||
50 | 51 | ||
51 | .scm.cgi: | ||
52 | $(AM_V_GEN)cp $< $@ | ||
53 | |||
54 | dict.scm: dict.scm4 dict.m4 | 52 | dict.scm: dict.scm4 dict.m4 |
@@ -57,4 +55,11 @@ conj.scm: conj.scm4 dict.m4 | |||
57 | 55 | ||
58 | dict.cgi: dict.scm | 56 | install-data-hook: |
59 | nea.cgi: nea.scm | 57 | $(AM_V_GEN)if test @REAL_SCRIPT_SUFFIX@ != .scm; then\ |
60 | conj.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 | |||
@@ -129,3 +129,3 @@ ifelse(IFACE,[CGI],[ | |||
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 | ||
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 | |||
@@ -11,3 +11,3 @@ | |||
11 | 11 | ||
12 | <DICT PROG="dict.=SCRIPT_SUFFIX=" /> | 12 | <DICT PROG="dict=SCRIPT_SUFFIX=" /> |
13 | <BASE HREF="=BASE_HREF=" /> | 13 | <BASE HREF="=BASE_HREF=" /> |
@@ -38,3 +38,3 @@ | |||
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))))) |
@@ -48,3 +48,3 @@ | |||
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))))) |