summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Gordon <assafgordon@gmail.com>2014-10-23 15:08:56 (GMT)
committerA. Gordon <assafgordon@gmail.com>2014-10-23 15:08:56 (GMT)
commit161838ff5f29c23ef25af3c8b6a8ff11268f662e (patch)
tree4706b7ebebe695496f7f5a452ff540917739fd3e
parentdfbdadd4a8d5bec21137215aa5d75362682403e2 (diff)
downloadgnu-sv-gitweb-dev/www-lang-en.zip
gnu-sv-gitweb-dev/www-lang-en.tar.gz
gnu-sv-gitweb-dev/www-lang-en.tar.bz2
Multiviews: ugly hack removed, with solution by ineiev@gnu.org .dev/www-lang-en
-rw-r--r--webserver/README-webserver.md8
-rw-r--r--webserver/apache-conf.d/lang.conf104
-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
5 files changed, 107 insertions, 138 deletions
diff --git a/webserver/README-webserver.md b/webserver/README-webserver.md
index 36f0733..3f59fe8 100644
--- a/webserver/README-webserver.md
+++ b/webserver/README-webserver.md
@@ -43,6 +43,9 @@ The update scripts on this server can simply create new project when they see on
sudo a2ensite 025-www.nongnu.org
sudo a2ensite 030-star.nongnu.org
+ # Custom Language/Multiviews configuration
+ sudo cp ./apache-conf.d/* /etc/apache2/cond.d/
+
# Copy and setup symlink-update scripts
sudo mkdir /etc/apache2/symlinks
sudo chown wwwcvs:wwwcvs /etc/apache2/symlinks
@@ -79,8 +82,3 @@ The update scripts on this server can simply create new project when they see on
# /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/apache-conf.d/lang.conf b/webserver/apache-conf.d/lang.conf
new file mode 100644
index 0000000..1ac108e
--- /dev/null
+++ b/webserver/apache-conf.d/lang.conf
@@ -0,0 +1,104 @@
+ # (lang.conf)
+ # Set up the languages with translations and their suffixes.
+ # This file should be updated whenever a new language has translations
+ # first added.
+ #
+ # This file should be copied to:
+ # /etc/apache2/conf.d/lang.conf
+<IfModule mod_mime.c>
+ AddLanguage af .af
+ AddLanguage ar .ar
+ AddLanguage az .az
+ AddLanguage bg .bg
+ AddLanguage bn .bn
+ AddLanguage bs .bs
+ AddLanguage ca .ca
+ AddLanguage cs .cs
+ AddLanguage da .da
+ AddLanguage de .de
+ AddLanguage el .el
+ AddLanguage en .en
+ AddLanguage eo .eo
+ # es is ecmascript in /etc/mime.types
+ RemoveType es
+ AddLanguage es .es
+ AddLanguage fa .fa
+ AddLanguage fi .fi
+ AddLanguage fr .fr
+ # gl is video/gl in /etc/mime.types
+ RemoveType gl
+ AddLanguage gl .gl
+ AddLanguage he .he
+ AddLanguage hr .hr
+ AddLanguage hu .hu
+ AddLanguage id .id
+ AddLanguage it .it
+ AddLanguage ja .ja
+ AddLanguage kn .kn
+ AddLanguage ko .ko
+ AddLanguage lt .lt
+ AddLanguage mk .mk
+ AddLanguage ml .ml
+ # nb is application/mathematica in /etc/mime.types
+ RemoveType nb
+ AddLanguage nb .nb
+ AddLanguage nl .nl
+ AddLanguage nn .nn
+ # pl is text/x-perl in /etc/mime.types
+ RemoveType pl
+ AddLanguage pl .pl
+ AddLanguage pt .pt
+ AddLanguage pt-BR .pt-br
+ AddLanguage ro .ro
+ AddLanguage ru .ru
+# sh is application/x-sh in /etc/mime.types
+ RemoveType sh
+# non-standard: Serbo-Croatian
+ AddLanguage sh .sh
+ AddLanguage sk .sk
+ AddLanguage sl .sl
+ AddLanguage sq .sq
+ AddLanguage sr .sr
+ AddLanguage sv .sv
+ AddLanguage ta .ta
+ AddLanguage th .th
+ AddLanguage tl .tl
+ # tr is troff in /etc/mime.types
+ RemoveType tr
+ AddLanguage tr .tr
+ AddLanguage uk .uk
+ AddLanguage uz .uz
+ AddLanguage vi .vi
+ AddLanguage zh .zh
+ AddLanguage zh-CA .zh-ca
+ AddLanguage zh-CN .zh-cn
+ AddLanguage zh-TW .zh-tw
+
+ # This artificial language prevents selection of non-HTML files
+ # when .html is explicitly requested. For instance, without this,
+ # wget -nv http://testvhost.org/prep/maintain/maintain.html
+ # returns maintain.txt, because the MultiViews negotiation results in
+ # the shortest file when no preferences are specified. To avoid this,
+ # tell MultiViews that these non-language extensions are lowest priority.
+ #
+ AddLanguage non-html \
+ .0206 .asc .au .big.png .css .dbk .dvi .gif \
+ .html_node.tar .html.old .hup \
+ .include .info.tar .jpg .jpg.copy .ly .msg \
+ .odt .ogg .pdf .png .pnm .ps \
+ .rdf .sgml .small.png .svg .sxd \
+ .t .tar .tex .texi .texi.tar .text .tiff .tiny.png .txt \
+ .xcf .xml .xslt
+</IfModule>
+
+<IfModule mod_negotiation.c>
+ LanguagePriority en \
+ af ar az bg bn bs ca cs da de el eo es \
+ fa fi fr gl he hr hu id it ja kn ko mk ml nb nl nn \
+ pl pt pt_BR ro ru sh sk sl sq sr sv ta th tl tr uk \
+ uz vi zh zh_CA zh_CN zh_TW \
+ non-html
+
+ ForceLanguagePriority Prefer Fallback
+ DefaultLanguage en
+</IfModule>
diff --git a/webserver/multiviews.txt b/webserver/multiviews.txt
deleted file mode 100644
index a8e281a..0000000
--- a/webserver/multiviews.txt
+++ /dev/null
@@ -1,69 +0,0 @@
-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
deleted file mode 100755
index 7a0af83..0000000
--- a/webserver/update-scripts/create-lang-en-symlinks.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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
deleted file mode 100755
index 0e671e7..0000000
--- a/webserver/update-scripts/delete-lang-en-symlinks.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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