diff --git a/config.yaml.example b/config.yaml.example index 0352dbd..47ec7aa 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -34,4 +34,8 @@ files_domain: files.example.org git_repo: git@github.com:example/example_org.git # runtime variables -is_dev: false \ No newline at end of file +is_dev: false + +book_versions: + en: 1 + ru: 1 \ No newline at end of file diff --git a/engine/router.php b/engine/router.php index 12ac2f8..388ee58 100644 --- a/engine/router.php +++ b/engine/router.php @@ -1,6 +1,6 @@ true]); - render('main/index'); + render('main/index', + versions: $config['book_versions']); } function GET_about() { redirect('/info/'); } diff --git a/handler/ServicesHandler.php b/handler/ServicesHandler.php index 70269b6..1b8d26b 100644 --- a/handler/ServicesHandler.php +++ b/handler/ServicesHandler.php @@ -13,4 +13,13 @@ TXT; 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); + } + } \ No newline at end of file diff --git a/routes.php b/routes.php index 1b50916..115eed4 100644 --- a/routes.php +++ b/routes.php @@ -22,7 +22,8 @@ return (function() { 'files/{'.implode(',', $coll_with_folder_support).'}/(\d+)/' => 'collection collection=${1} folder_id=$(1)', ], 'Services' => [ - 'robots.txt' => 'robots_txt', + 'robots.txt' => 'robots_txt', + 'latest-{en,ru}.pdf' => 'latest lang=${1}' ], 'Admin' => [ 'admin/' => 'index', diff --git a/skin/main.phps b/skin/main.phps index 354a6f1..666b7fb 100644 --- a/skin/main.phps +++ b/skin/main.phps @@ -9,7 +9,7 @@ use Post; use PostLanguage; use function is_admin; -function index($ctx) { +function index($ctx, array $versions) { return <<
@@ -17,13 +17,13 @@ function index($ctx) {
- + Download in English
PDF 379 pp. 25 MiB
- + Скачать на русском
PDF 453 стр. 26 MiB