Download in English
PDF 379 pp. 25 MiB
Скачать на русском
PDF 453 стр. 29 MiB
Released by kiwi arXiv & kniganews in 2023
English translation by Eline Cat
HTML; } //function articles($ctx): string { //return << // {$ctx->lang('blog_no')} // {$ctx->if_admin(''.$ctx->lang('write').'')} // //HTML; //} function articles($ctx, array $posts): string { return <<
{$ctx->if_admin( ' new ' )}
{$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; } // 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, $unsafe_toc_html, $date, $visible, $url, $tags, $email, $urlencoded_reply_subject) { $html = <<

{$title}

{$unsafe_html}
{$ctx->if_true($unsafe_toc_html, $ctx->postToc, $unsafe_toc_html)}
HTML; return [$html, markdownThemeChangeListener()]; } function postToc($ctx, $unsafe_toc_html) { return <<
{$ctx->lang('toc')}
{$unsafe_toc_html}
HTML; } 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; }