indexEmtpy() : $ctx->indexBlog($posts); } function indexEmtpy($ctx): string { return << {$ctx->lang('blog_no')} {$ctx->if_admin(''.$ctx->lang('write').'')} HTML; } function indexBlog($ctx, array $posts): string { return <<
all posts {$ctx->if_admin( ' new uploads ' )}
{$ctx->indexPostsTable($posts)} HTML; } function indexPostsTable($ctx, array $posts): string { $ctx->year = 3000; return << {$ctx->for_each($posts, fn($post) => $ctx->indexPostRow( $post->getYear(), $post->visible, $post->getDate(), $post->getUrl(), $post->title ))}
HTML; } function indexPostRow($ctx, $year, $is_visible, $date, $url, $title): string { return <<if_true($ctx->year > $year, $ctx->indexYearLine, $year)} {$date} {$title} HTML; } function indexYearLine($ctx, $year): string { $ctx->year = $year; return << {$year} HTML; } // contacts page // ------------- function contacts($ctx, $email) { return <<
Feel free to contact me by any of the following means:
Email: {$email}
Please use PGP.
Telegram: @eacces
Please use Secret Chats.
Libera.Chat: ch1p HTML; } // any page // -------- function page($ctx, $page_url, $short_name, $unsafe_html) { $html = << {$ctx->if_admin($ctx->pageAdminLinks, $page_url, $short_name)}
{$unsafe_html}
HTML; return [$html, markdownThemeChangeListener()]; } function pageAdminLinks($ctx, $url, $short_name) { return << {$ctx->lang('edit')} {$ctx->lang('delete')} HTML; } // post page // --------- function post($ctx, $id, $title, $unsafe_html, $date, $visible, $url, $tags, $email, $urlencoded_reply_subject) { $html = <<

{$title}

{$ctx->if_not($visible, ''.$ctx->lang('blog_post_hidden').' |')} {$date} {$ctx->if_admin($ctx->postAdminLinks, $url, $id)}
{$ctx->for_each($tags, fn($tag) => $ctx->postTag($tag->getUrl(), $tag->tag))}
{$unsafe_html}
{$ctx->langRaw('blog_comments_text', $email, $urlencoded_reply_subject)}
HTML; return [$html, markdownThemeChangeListener()]; } function postAdminLinks($ctx, $url, $id) { return <<{$ctx->lang('edit')} {$ctx->lang('delete')} HTML; } function postTag($ctx, $url, $name) { return <<#{$name} HTML; } function markdownThemeChangeListener() { return << div'); if (!div) { console.warn('could not found a>div on this node:', node); continue; } var style = div.getAttribute('style'); if (isDark) { style = style.replace(/(a[\d]+x[\d]+)\.jpg/, '$1_dark.jpg'); } else { style = style.replace(/(a[\d]+x[\d]+)_dark\.jpg/, '$1.jpg'); } div.setAttribute('style', style); } }); JS; } // tag page // -------- function tag($ctx, $count, $posts, $tag) { if (!$count) return << {$ctx->lang('blog_tag_not_found')} HTML; return <<
#{$tag}
{$ctx->indexPostsTable($posts)} HTML; }