fixing router for production
This commit is contained in:
parent
818022df4a
commit
17ce98d5aa
15
doc/Makefile
15
doc/Makefile
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
all: install_fr.html install_en.html home_fr.html home_en.html
|
|
||||||
|
|
||||||
install_fr.html: install_fr.md
|
|
||||||
github-markup install_fr.md >install_fr.html
|
|
||||||
|
|
||||||
install_en.html: install_en.md
|
|
||||||
github-markup install_en.md >install_en.html
|
|
||||||
|
|
||||||
home_fr.html: home_fr.md
|
|
||||||
github-markup home_fr.md >home_fr.html
|
|
||||||
|
|
||||||
home_en.html: home_en.md
|
|
||||||
github-markup home_en.md >home_en.html
|
|
||||||
|
|
|
@ -3,5 +3,5 @@ Dependencies:
|
||||||
|
|
||||||
- bootstrap (included)
|
- bootstrap (included)
|
||||||
- github-markup https://github.com/github/markup (to be installed)
|
- github-markup https://github.com/github/markup (to be installed)
|
||||||
- make
|
- submodule git@github.com:AlternC/AlternC.wiki.git in pages/
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
// List here the supported languages :
|
// List here the supported languages :
|
||||||
$otherlang=array(
|
$otherlang=array(
|
||||||
"fr" => "Français",
|
"fr" => "Français",
|
||||||
"en" => "English"
|
"en" => "English",
|
||||||
|
);
|
||||||
|
$locales=array("fr" => "fr_FR.UTF-8",
|
||||||
|
"en" => "en_GB.UTF-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
$uri=trim($_SERVER["REQUEST_URI"],"/");
|
$uri=trim($_SERVER["REQUEST_URI"],"/");
|
||||||
|
@ -21,12 +24,10 @@ if (!$uri) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('^(.*)-([^-]*)$',$uri,$mat)) {
|
if (preg_match('#^(.*)-([^-]*)$#',$uri,$mat)) {
|
||||||
$lang=$mat[2];
|
$lang=$mat[2];
|
||||||
$uri=$mat[1];
|
$uri=$mat[1];
|
||||||
}
|
}
|
||||||
//list($lang,$uri)=explode("/",$uri,2);
|
|
||||||
|
|
||||||
|
|
||||||
if (!isset($otherlang[$lang])) {
|
if (!isset($otherlang[$lang])) {
|
||||||
header("HTTP/1.0 404 Not Found");
|
header("HTTP/1.0 404 Not Found");
|
||||||
|
@ -34,6 +35,13 @@ if (!isset($otherlang[$lang])) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set locales:
|
||||||
|
putenv("LC_MESSAGES=".$locales[$lang]);
|
||||||
|
putenv("LANG=".$locales[$lang]);
|
||||||
|
putenv("LANGUAGE=".$locales[$lang]);
|
||||||
|
// this locale MUST be selected in "dpkg-reconfigure locales"
|
||||||
|
setlocale(LC_ALL,$locales[$lang]);
|
||||||
|
|
||||||
unset($otherlang[$lang]);
|
unset($otherlang[$lang]);
|
||||||
|
|
||||||
header("Content-Type: text/html; charset=UTF-8");
|
header("Content-Type: text/html; charset=UTF-8");
|
||||||
|
@ -47,7 +55,7 @@ if (!file_exists("../pages/".$uri."-".$lang.".md")) {
|
||||||
// automatic compilation / caching of HTML pages
|
// automatic compilation / caching of HTML pages
|
||||||
if (!file_exists("../pages/".$uri."-".$lang.".html") ||
|
if (!file_exists("../pages/".$uri."-".$lang.".html") ||
|
||||||
filemtime("../pages/".$uri."-".$lang.".html") < filemtime("../pages/".$uri."-".$lang.".md") ) {
|
filemtime("../pages/".$uri."-".$lang.".html") < filemtime("../pages/".$uri."-".$lang.".md") ) {
|
||||||
exec("github-markup ".escapeshellarg("../pages/".$uri."-".$lang.".md")." >".escapeshellarg("../pages/".$uri."-".$lang.".html"));
|
passthru("github-markup ".escapeshellarg("../pages/".$uri."-".$lang.".md")." >".escapeshellarg("../pages/".$uri."-".$lang.".html")." 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
$f=fopen("../pages/".$uri."-".$lang.".html","rb");
|
$f=fopen("../pages/".$uri."-".$lang.".html","rb");
|
||||||
|
|
Loading…
Reference in New Issue