pages: fixes for wiki

This commit is contained in:
E. S. 2024-11-05 05:39:04 +03:00
parent a0c527078c
commit da854a0f16
7 changed files with 12 additions and 6 deletions

View File

@ -29,6 +29,7 @@ sitemap_dir: /home/user/sitemap
uploads_dir: /home/user/files.example.org uploads_dir: /home/user/files.example.org
uploads_path: /uploads uploads_path: /uploads
files_domain: files.example.org files_domain: files.example.org
wiki_root: wiki
# deploy config # deploy config
git_repo: git@github.com:example/example_org.git git_repo: git@github.com:example/example_org.git

View File

@ -1,6 +1,6 @@
<?php <?php
const ROUTER_VERSION = 9; const ROUTER_VERSION = 10;
const ROUTER_MC_KEY = '4in1/routes'; const ROUTER_MC_KEY = '4in1/routes';
$RouterInput = []; $RouterInput = [];

View File

@ -428,7 +428,7 @@ class AdminHandler extends request_handler {
add_skin_strings_re('/^(err_)?pages_/'); add_skin_strings_re('/^(err_)?pages_/');
add_skin_strings_re('/^(err_)?blog_/'); add_skin_strings_re('/^(err_)?blog_/');
set_title(lang('pages_page_edit_title', $page->shortName.'.html')); set_title(lang('pages_page_edit_title', $page->shortName));
static::make_wide(); static::make_wide();
$js_text = [ $js_text = [
'text' => $page->md, 'text' => $page->md,

View File

@ -50,7 +50,7 @@ class MainHandler extends request_handler {
if ($page->shortName == 'info') if ($page->shortName == 'info')
set_skin_opts(['head_section' => 'about']); 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]); set_skin_opts(['head_section' => $page->shortName]);
$bc = null; $bc = null;

View File

@ -17,7 +17,7 @@ class Page extends model {
function edit(array $fields) { function edit(array $fields) {
$fields['update_ts'] = time(); $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']; $md = $fields['md'];
if ($fields['render_title']) if ($fields['render_title'])
$md = '# '.$fields['title']."\n\n".$md; $md = '# '.$fields['title']."\n\n".$md;

View File

@ -1,13 +1,15 @@
<?php <?php
return (function() { return (function() {
global $config;
require_once 'lib/files.php'; require_once 'lib/files.php';
$files_collections = array_map(fn(FilesCollection $fn) => $fn->value, FilesCollection::cases()); $files_collections = array_map(fn(FilesCollection $fn) => $fn->value, FilesCollection::cases());
$coll_with_folder_support = [FilesCollection::WilliamFriedman->value, FilesCollection::Baconiana->value]; $coll_with_folder_support = [FilesCollection::WilliamFriedman->value, FilesCollection::Baconiana->value];
$pagename_regex = '[a-zA-Z0-9-]+'; $pagename_regex = '[a-zA-Z0-9-]+';
$wiki_root = 'notes'; $wiki_root = $config['wiki_root'];
$routes = [ $routes = [
'Main' => [ 'Main' => [
@ -37,6 +39,8 @@ return (function() {
'('.$pagename_regex.')/create/' => 'page_add short_name=$(1)', '('.$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.')/{delete,edit}/' => 'page_${1} short_name='.$wiki_root.'/$(1)',
$wiki_root.'/('.$pagename_regex.')/create/' => 'page_add 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/write/' => 'post_add',
'articles/('.$pagename_regex.')/{delete,edit}/' => 'post_${1} short_name=$(1)', 'articles/('.$pagename_regex.')/{delete,edit}/' => 'post_${1} short_name=$(1)',
'admin/markdown-preview.ajax' => 'ajax_md_preview', 'admin/markdown-preview.ajax' => 'ajax_md_preview',

View File

@ -220,12 +220,13 @@ function renderHeader(SkinContext $ctx,
?string $section, ?string $section,
?string $articles_lang, ?string $articles_lang,
bool $show_subtitle): string { bool $show_subtitle): string {
global $config;
$icons = svg(); $icons = svg();
$items = []; $items = [];
$items[] = ['url' => '/articles/'.($articles_lang && $articles_lang != 'en' ? '?lang='.$articles_lang : ''), 'label' => 'articles', 'selected' => $section === 'articles']; $items[] = ['url' => '/articles/'.($articles_lang && $articles_lang != 'en' ? '?lang='.$articles_lang : ''), 'label' => 'articles', 'selected' => $section === 'articles'];
$items[] = ['url' => '/files/', 'label' => 'files', 'selected' => $section === 'files']; $items[] = ['url' => '/files/', 'label' => 'files', 'selected' => $section === 'files'];
if (is_admin()) 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']; $items[] = ['url' => '/info/', 'label' => 'about', 'selected' => $section === 'about'];
if (is_admin()) if (is_admin())
$items[] = ['url' => '/admin/', 'label' => $icons->settings_28(in_place: true), 'type' => 'settings', 'selected' => $section === 'admin']; $items[] = ['url' => '/admin/', 'label' => $icons->settings_28(in_place: true), 'type' => 'settings', 'selected' => $section === 'admin'];