add /latest-{ru,en}.pdf endpoints; store versions in config.yaml
This commit is contained in:
parent
fcb1460859
commit
5dc63760a8
@ -35,3 +35,7 @@ git_repo: git@github.com:example/example_org.git
|
|||||||
|
|
||||||
# runtime variables
|
# runtime variables
|
||||||
is_dev: false
|
is_dev: false
|
||||||
|
|
||||||
|
book_versions:
|
||||||
|
en: 1
|
||||||
|
ru: 1
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
const ROUTER_VERSION = 7;
|
const ROUTER_VERSION = 8;
|
||||||
const ROUTER_MC_KEY = '4in1/routes';
|
const ROUTER_MC_KEY = '4in1/routes';
|
||||||
|
|
||||||
$RouterInput = [];
|
$RouterInput = [];
|
||||||
|
@ -14,7 +14,8 @@ class MainHandler extends request_handler {
|
|||||||
|
|
||||||
set_title('$site_title');
|
set_title('$site_title');
|
||||||
set_skin_opts(['is_index' => true]);
|
set_skin_opts(['is_index' => true]);
|
||||||
render('main/index');
|
render('main/index',
|
||||||
|
versions: $config['book_versions']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GET_about() { redirect('/info/'); }
|
function GET_about() { redirect('/info/'); }
|
||||||
|
@ -13,4 +13,13 @@ TXT;
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GET_latest() {
|
||||||
|
global $config;
|
||||||
|
list($lang) = input('lang');
|
||||||
|
if (!isset($config['book_versions'][$lang]))
|
||||||
|
not_found();
|
||||||
|
redirect("https://files.4in1.ws/4in1-{$lang}.pdf?{$config['book_versions'][$lang]}",
|
||||||
|
code: HTTPCode::Found);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -22,7 +22,8 @@ return (function() {
|
|||||||
'files/{'.implode(',', $coll_with_folder_support).'}/(\d+)/' => 'collection collection=${1} folder_id=$(1)',
|
'files/{'.implode(',', $coll_with_folder_support).'}/(\d+)/' => 'collection collection=${1} folder_id=$(1)',
|
||||||
],
|
],
|
||||||
'Services' => [
|
'Services' => [
|
||||||
'robots.txt' => 'robots_txt',
|
'robots.txt' => 'robots_txt',
|
||||||
|
'latest-{en,ru}.pdf' => 'latest lang=${1}'
|
||||||
],
|
],
|
||||||
'Admin' => [
|
'Admin' => [
|
||||||
'admin/' => 'index',
|
'admin/' => 'index',
|
||||||
|
@ -9,7 +9,7 @@ use Post;
|
|||||||
use PostLanguage;
|
use PostLanguage;
|
||||||
use function is_admin;
|
use function is_admin;
|
||||||
|
|
||||||
function index($ctx) {
|
function index($ctx, array $versions) {
|
||||||
return <<<HTML
|
return <<<HTML
|
||||||
<div class="page"><div class="blog-post-text">
|
<div class="page"><div class="blog-post-text">
|
||||||
<div class="clearfix index-book">
|
<div class="clearfix index-book">
|
||||||
@ -17,13 +17,13 @@ function index($ctx) {
|
|||||||
<a class="index-book-image" id="index-book-image" href="https://files.4in1.ws/Images/4in1-cover-en.png" target="_blank" data-link-template="https://files.4in1.ws/Images/4in1-cover-{lang}.png"></a>
|
<a class="index-book-image" id="index-book-image" href="https://files.4in1.ws/Images/4in1-cover-en.png" target="_blank" data-link-template="https://files.4in1.ws/Images/4in1-cover-{lang}.png"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="index-dl-line" href="https://files.4in1.ws/4in1-en.pdf?7" onmouseenter="IndexPage.setCoverLang('en')">
|
<a class="index-dl-line" href="https://files.4in1.ws/4in1-en.pdf?{$versions['en']}" onmouseenter="IndexPage.setCoverLang('en')">
|
||||||
<b>Download in English</b><br>
|
<b>Download in English</b><br>
|
||||||
<div class="index-dl-line-info">
|
<div class="index-dl-line-info">
|
||||||
PDF <span class="bullet">•</span> 379 pp. <span class="bullet">•</span> 25 MiB
|
PDF <span class="bullet">•</span> 379 pp. <span class="bullet">•</span> 25 MiB
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a class="index-dl-line" href="https://files.4in1.ws/4in1-ru.pdf?5" onmouseenter="IndexPage.setCoverLang('ru')">
|
<a class="index-dl-line" href="https://files.4in1.ws/4in1-ru.pdf?{$versions['ru']}" onmouseenter="IndexPage.setCoverLang('ru')">
|
||||||
<b>Скачать на русском</b>
|
<b>Скачать на русском</b>
|
||||||
<div class="index-dl-line-info">
|
<div class="index-dl-line-info">
|
||||||
PDF <span class="bullet">•</span> 453 стр. <span class="bullet">•</span> 26 MiB
|
PDF <span class="bullet">•</span> 453 стр. <span class="bullet">•</span> 26 MiB
|
||||||
|
Loading…
x
Reference in New Issue
Block a user