From da854a0f16e5d4c5658db9a1f530465c3ca2baac Mon Sep 17 00:00:00 2001 From: "E. S." Date: Tue, 5 Nov 2024 05:39:04 +0300 Subject: [PATCH] pages: fixes for wiki --- config.yaml.example | 1 + engine/router.php | 2 +- handler/AdminHandler.php | 2 +- handler/MainHandler.php | 2 +- lib/pages.php | 2 +- routes.php | 6 +++++- skin/base.phps | 3 ++- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config.yaml.example b/config.yaml.example index 47ec7aa..cd441a4 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -29,6 +29,7 @@ sitemap_dir: /home/user/sitemap uploads_dir: /home/user/files.example.org uploads_path: /uploads files_domain: files.example.org +wiki_root: wiki # deploy config git_repo: git@github.com:example/example_org.git diff --git a/engine/router.php b/engine/router.php index ca4a06d..5845356 100644 --- a/engine/router.php +++ b/engine/router.php @@ -1,6 +1,6 @@ shortName.'.html')); + set_title(lang('pages_page_edit_title', $page->shortName)); static::make_wide(); $js_text = [ 'text' => $page->md, diff --git a/handler/MainHandler.php b/handler/MainHandler.php index 1bc4641..db40b08 100644 --- a/handler/MainHandler.php +++ b/handler/MainHandler.php @@ -50,7 +50,7 @@ class MainHandler extends request_handler { if ($page->shortName == 'info') set_skin_opts(['head_section' => 'about']); - else if ($page->shortName == 'notes') + else if ($page->shortName == $config['wiki_root']) set_skin_opts(['head_section' => $page->shortName]); $bc = null; diff --git a/lib/pages.php b/lib/pages.php index 1f67482..ad24cb4 100644 --- a/lib/pages.php +++ b/lib/pages.php @@ -17,7 +17,7 @@ class Page extends model { function edit(array $fields) { $fields['update_ts'] = time(); - if ($fields['md'] != $this->md || $fields['render_title'] != $this->renderTitle) { + if ($fields['md'] != $this->md || $fields['render_title'] != $this->renderTitle || $fields['title'] != $this->title) { $md = $fields['md']; if ($fields['render_title']) $md = '# '.$fields['title']."\n\n".$md; diff --git a/routes.php b/routes.php index a6fccd5..c4ae38c 100644 --- a/routes.php +++ b/routes.php @@ -1,13 +1,15 @@ $fn->value, FilesCollection::cases()); $coll_with_folder_support = [FilesCollection::WilliamFriedman->value, FilesCollection::Baconiana->value]; $pagename_regex = '[a-zA-Z0-9-]+'; - $wiki_root = 'notes'; + $wiki_root = $config['wiki_root']; $routes = [ 'Main' => [ @@ -37,6 +39,8 @@ return (function() { '('.$pagename_regex.')/create/' => 'page_add short_name=$(1)', $wiki_root.'/('.$pagename_regex.')/{delete,edit}/' => 'page_${1} short_name='.$wiki_root.'/$(1)', $wiki_root.'/('.$pagename_regex.')/create/' => 'page_add short_name='.$wiki_root.'/$(1)', + $wiki_root.'/{delete,edit}/' => 'page_${1} short_name='.$wiki_root, + $wiki_root.'/create/' => 'page_add short_name='.$wiki_root, 'articles/write/' => 'post_add', 'articles/('.$pagename_regex.')/{delete,edit}/' => 'post_${1} short_name=$(1)', 'admin/markdown-preview.ajax' => 'ajax_md_preview', diff --git a/skin/base.phps b/skin/base.phps index f15c30e..48dfba0 100644 --- a/skin/base.phps +++ b/skin/base.phps @@ -220,12 +220,13 @@ function renderHeader(SkinContext $ctx, ?string $section, ?string $articles_lang, bool $show_subtitle): string { +global $config; $icons = svg(); $items = []; $items[] = ['url' => '/articles/'.($articles_lang && $articles_lang != 'en' ? '?lang='.$articles_lang : ''), 'label' => 'articles', 'selected' => $section === 'articles']; $items[] = ['url' => '/files/', 'label' => 'files', 'selected' => $section === 'files']; if (is_admin()) - $items[] = ['url' => '/notes/', 'label' => 'notes', 'selected' => $section === 'notes']; + $items[] = ['url' => '/'.$config['wiki_root'].'/', 'label' => 'wiki', 'selected' => $section === $config['wiki_root']]; $items[] = ['url' => '/info/', 'label' => 'about', 'selected' => $section === 'about']; if (is_admin()) $items[] = ['url' => '/admin/', 'label' => $icons->settings_28(in_place: true), 'type' => 'settings', 'selected' => $section === 'admin'];