summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Gordon <assafgordon@gmail.com>2014-10-22 20:27:44 (GMT)
committerA. Gordon <assafgordon@gmail.com>2014-10-22 20:27:44 (GMT)
commitdfbdadd4a8d5bec21137215aa5d75362682403e2 (patch)
tree1372555d90b13eb00db8b3544d050cd8cdf38fae
parentee9fdb994a2e9439eab0be95d8da858411a96f8b (diff)
downloadgnu-sv-gitweb-dfbdadd4a8d5bec21137215aa5d75362682403e2.zip
gnu-sv-gitweb-dfbdadd4a8d5bec21137215aa5d75362682403e2.tar.gz
gnu-sv-gitweb-dfbdadd4a8d5bec21137215aa5d75362682403e2.tar.bz2
Add English-Language hackf or Apache MultiViews configuration
Read 'multiviews.txt' for details. The code is in 'update-scripts/create-lang-en-symlinks.sh'.
-rw-r--r--webserver/README-webserver.md13
-rw-r--r--webserver/multiviews.txt69
-rwxr-xr-xwebserver/update-scripts/create-lang-en-symlinks.sh37
-rwxr-xr-xwebserver/update-scripts/delete-lang-en-symlinks.sh27
4 files changed, 146 insertions, 0 deletions
diff --git a/webserver/README-webserver.md b/webserver/README-webserver.md
index 3c30859..36f0733 100644
--- a/webserver/README-webserver.md
+++ b/webserver/README-webserver.md
@@ -71,3 +71,16 @@ The update scripts on this server can simply create new project when they see on
# Or update only recently changed repositories:
update-recent-gnu-sv-www-repo.sh
+
+
+## Scripts to update the server after every update
+
+ # Update the symlinks maps in
+ # /etc/apache2/symlinks
+ # based on the ".symlinks" file in each repository.
+ sudo -u wwwcvs /home/wwwcvs/update-symlinks.sh
+
+ # Update the English language symlinks,
+ # See more information in ./multiviews.txt.
+ # NOTE: This is not part of the production server setup at www.gnu.org.
+ ./create-lang-en-symlinks.sh
diff --git a/webserver/multiviews.txt b/webserver/multiviews.txt
new file mode 100644
index 0000000..a8e281a
--- /dev/null
+++ b/webserver/multiviews.txt
@@ -0,0 +1,69 @@
+Date: Wed, 22 Oct 2014 15:39:34 -0400
+From: Assaf Gordon <assafgordon@gmail.com>
+Subject: "MultiViews" settings on www.gnu.org (language choice)
+
+Hi guys,
+
+I'm writing regarding my struggle with the www.gnu.org "mutliview" option
+(which never selects "English" as default) on my mock-up server.
+
+This is not urgent or critical - but of the slim chance that this might ring
+any bells, I'd love to hear from you.
+
+What I've found so far (simplified scenario):
+
+1. The server has the following files:
+ /var/www/home.html
+ /var/www/home.ca.html
+ /var/www/home.de.html
+ /var/www/home.fr.html
+ /var/www/home.ru.html
+
+2. The user requests "http://server/home.html"
+
+3. The various "rewrite rules" do their magic, and the last two rules in the
+"/etc/apache2/sites-available/www.gnu.org-common" are:
+
+ # Redirect foo.html to foo.
+ # After this redirection, MultiViews should take over.
+ RewriteCond %{REQUEST_FILENAME} !(\...(-..)?\.html)$
+ RewriteRule ^(.*)\.html$ $1
+
+ # Prevent Apache from interpreting the result
+ # as a local filesystem path, e.g., "/home".
+ RewriteRule ^(/.*)$ %{DOCUMENT_ROOT}$1
+
+And so, "/home.html" is first chopped to "/home",
+then prefixed with "/var/www/home" .
+
+4. I see in the RewriteLog the last record is indeed "/var/www/home",
+marked with "[OK]", then the log ends.
+
+5. Now, the problem:
+Given "/var/www/home", my Apache setup does not consider "home.html" as an
+valid option for English.
+It only considers files with language codes, and "home.ca.html" comes first.
+
+If I add a symlink from "home.html" to "home.en.html" - it works fine.
+
+=====
+
+I was able to reproduce this behaviour on a 'clean' apache configuration with
+"MultiView" setup - so this is likely the default Apache behavour, not an
+artifact of the complicated 'multiview' configuration of gnu.org.
+
+So I'm thinking of couple of options:
+1. There are more Apache configurations settings that I'm missing (because
+they did not appear in the published files).
+Perhaps some tweak in "/etc/apache2/mods-available/mime.conf",
+or some other file.
+
+2. Perhaps there's a script to automatically create ".en.html" symlinks ?
+sounds far-fetched. but could be.
+
+3. Another option completely.
+
+Since I do not have access to "gnu.org", I can only guess....
+
+For now, I'm going to implement hack #2 .
+=====
diff --git a/webserver/update-scripts/create-lang-en-symlinks.sh b/webserver/update-scripts/create-lang-en-symlinks.sh
new file mode 100755
index 0000000..7a0af83
--- /dev/null
+++ b/webserver/update-scripts/create-lang-en-symlinks.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Copyright (C) 2014 Assaf Gordon (assafgordon@gmail.com)
+#
+# 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/>.
+
+##
+## This is an ugly hack script, to work-around the MultiView problem,
+## described in multiviews.txt
+##
+## The script scans all the non-language HTML files under /var/www ,
+## and creates an English language symlink to them. Example:
+## /var/www/home.html -> /var/www/home.en.html
+##
+
+## 1. find - list all HTML files
+## 2. grep - filter out html files with language codes
+## 3. xargs+sh - create a symlink for each HTML file.
+##
+cd /var/www
+find . -name "*.html" -type f -print0 \
+ | grep -zZvE '\.([A-Za-z][A-Za-z](-[A-Za-z][A-Za-z])?)\.html$' \
+ | xargs -0 -L1 -I% \
+ sh -c 'B=$(basename % .html) ; D=$(dirname %) ;
+ test -e $D/$B.en.html || ln -s $B.html $D/$B.en.html'
+
diff --git a/webserver/update-scripts/delete-lang-en-symlinks.sh b/webserver/update-scripts/delete-lang-en-symlinks.sh
new file mode 100755
index 0000000..0e671e7
--- /dev/null
+++ b/webserver/update-scripts/delete-lang-en-symlinks.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Copyright (C) 2014 Assaf Gordon (assafgordon@gmail.com)
+#
+# 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/>.
+
+##
+## This script deletes all the English languag HTML symlinks,
+## as created with 'create-lang-en-symlinks.sh' .
+##
+
+## 1. find - list all HTML files
+## 2. grep - filter out html files with language codes
+## 3. xargs+sh - create a symlink for each HTML file.
+##
+find -L /var/www -name "*.en.html" -xtype l -delete