aboutsummaryrefslogtreecommitdiff
path: root/skin
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-03-04 01:46:45 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-03-04 01:46:45 +0300
commiteeb84c5be16ecca239adae9c851bc0f7db0875a1 (patch)
tree9aa1056e643212e4c6133d90f38a1966f0fa35ca /skin
parent917d2622aa5fe748c1cda914eae94c12be743c42 (diff)
blog: support ToC
Diffstat (limited to 'skin')
-rw-r--r--skin/admin.skin.php2
-rw-r--r--skin/base.skin.php8
-rw-r--r--skin/main.skin.php44
3 files changed, 41 insertions, 13 deletions
diff --git a/skin/admin.skin.php b/skin/admin.skin.php
index 5619dd0..b2d9bb4 100644
--- a/skin/admin.skin.php
+++ b/skin/admin.skin.php
@@ -129,6 +129,7 @@ function postForm($ctx,
$error_code = null,
?bool $saved = null,
?bool $visible = null,
+ ?bool $toc = null,
string|Stringable|null $post_url = null,
?int $post_id = null): array {
$form_url = !$is_edit ? '/write/' : $post_url.'edit/';
@@ -173,6 +174,7 @@ $html = <<<HTML
<div class="form-field-label">{$ctx->lang('blog_write_form_options')}</div>
<div class="form-field">
<label for="visible_cb"><input type="checkbox" id="visible_cb" name="visible"{$ctx->if_true($visible, ' checked="checked"')}> {$ctx->lang('blog_write_form_visible')}</label>
+ <label for="toc_cb"><input type="checkbox" id="toc_cb" name="toc"{$ctx->if_true($toc, ' checked="checked"')}> {$ctx->lang('blog_write_form_toc')}</label>
</div>
</div>
</td>
diff --git a/skin/base.skin.php b/skin/base.skin.php
index 3374555..d39a0a8 100644
--- a/skin/base.skin.php
+++ b/skin/base.skin.php
@@ -13,6 +13,12 @@ $app_config = json_encode([
'cookieHost' => $config['cookie_host'],
]);
+$body_class = [];
+if ($opts['full_width'])
+ $body_class = 'full-width';
+else if ($opts['wide'])
+ $body_class = 'wide';
+
return <<<HTML
<!doctype html>
<html lang="en">
@@ -26,7 +32,7 @@ return <<<HTML
{$ctx->renderMeta($meta)}
{$ctx->renderStatic($static, $theme)}
</head>
- <body{$ctx->if_true($opts['full_width'], ' class="full-width"')}>
+ <body{$ctx->if_true($body_class, ' class="'.$body_class.'"')}>
{$ctx->renderHeader($theme, renderLogo($ctx, $opts['logo_path_map'], $opts['logo_link_map']))}
<div class="page-content base-width">
<div class="page-content-inner">{$unsafe_body}</div>
diff --git a/skin/main.skin.php b/skin/main.skin.php
index a1a4910..c0ab40a 100644
--- a/skin/main.skin.php
+++ b/skin/main.skin.php
@@ -144,22 +144,28 @@ HTML;
// post page
// ---------
-function post($ctx, $id, $title, $unsafe_html, $date, $visible, $url, $tags, $email, $urlencoded_reply_subject) {
+function post($ctx, $id, $title, $unsafe_html, $unsafe_toc_html, $date, $visible, $url, $tags, $email, $urlencoded_reply_subject) {
$html = <<<HTML
-<div class="blog-post">
- <div class="blog-post-title">
- <h1>{$title}</h1>
- <div class="blog-post-date">
- {$ctx->if_not($visible, '<b>'.$ctx->lang('blog_post_hidden').'</b> |')}
- {$date}
- {$ctx->if_admin($ctx->postAdminLinks, $url, $id)}
- </div>
- <div class="blog-post-tags clearfix">
- {$ctx->for_each($tags, fn($tag) => $ctx->postTag($tag->getUrl(), $tag->tag))}
+<div class="blog-post-wrap2">
+ <div class="blog-post-wrap1">
+ <div class="blog-post">
+ <div class="blog-post-title">
+ <h1>{$title}</h1>
+ <div class="blog-post-date">
+ {$ctx->if_not($visible, '<b>'.$ctx->lang('blog_post_hidden').'</b> |')}
+ {$date}
+ {$ctx->if_admin($ctx->postAdminLinks, $url, $id)}
+ </div>
+ <div class="blog-post-tags clearfix">
+ {$ctx->for_each($tags, fn($tag) => $ctx->postTag($tag->getUrl(), $tag->tag))}
+ </div>
+ </div>
+ <div class="blog-post-text">{$unsafe_html}</div>
</div>
+ {$ctx->if_true($unsafe_toc_html, $ctx->postToc, $unsafe_toc_html)}
</div>
- <div class="blog-post-text">{$unsafe_html}</div>
</div>
+
<div class="blog-post-comments">
{$ctx->langRaw('blog_comments_text', $email, $urlencoded_reply_subject)}
</div>
@@ -168,6 +174,20 @@ HTML;
return [$html, markdownThemeChangeListener()];
}
+function postToc($ctx, $unsafe_toc_html) {
+return <<<HTML
+<div class="blog-post-toc">
+ <div class="blog-post-toc-wrap">
+ <div class="blog-post-toc-inner-wrap">
+ <div class="blog-post-toc-title">{$ctx->lang('toc')}</div>
+ {$unsafe_toc_html}
+ </div>
+ </div>
+</div>
+HTML;
+
+}
+
function postAdminLinks($ctx, $url, $id) {
return <<<HTML
<a href="{$url}edit/">{$ctx->lang('edit')}</a>