@@ -228,8 +228,8 @@ function pageForm($ctx,
bool $visible = false): array {
$form_url = '/'.$short_name.'/'.($is_edit ? 'edit' : 'create').'/';
$html = <<if_true($error_code, ' '.$ctx->lang('err_pages_'.$error_code).' ')}
-{$ctx->if_true($saved, ''.$ctx->lang('info_saved').' ')}
+{$ctx->if_true($error_code, fn() => ''.$ctx->lang('err_pages_'.$error_code).' ')}
+{$ctx->if_true($saved, fn() => ''.$ctx->lang('info_saved').' ')}
diff --git a/skin/base.skin.php b/skin/base.skin.php
index d39a0a8..d583ffe 100644
--- a/skin/base.skin.php
+++ b/skin/base.skin.php
@@ -2,9 +2,6 @@
namespace skin\base;
-use admin;
-use RequestDispatcher;
-
function layout($ctx, $title, $unsafe_body, $static, $meta, $js, $opts, $exec_time, $unsafe_lang, $theme) {
global $config;
$app_config = json_encode([
@@ -15,9 +12,13 @@ $app_config = json_encode([
$body_class = [];
if ($opts['full_width'])
- $body_class = 'full-width';
+ $body_class[] = 'full-width';
else if ($opts['wide'])
- $body_class = 'wide';
+ $body_class[] = 'wide';
+if (!empty($body_class))
+ $body_class = implode(' ', $body_class);
+else
+ $body_class = '';
return <<
@@ -196,7 +197,7 @@ $items = [
['url' => '/misc/', 'label' => 'misc'],
['url' => '/contacts/', 'label' => 'contacts'],
];
-if (\admin::isAdmin())
+if (\is_admin())
$items[] = ['url' => '/admin/', 'label' => 'admin'];
// here, items are rendered using for_each, so that there are no gaps (whitespaces) between tags
@@ -226,9 +227,9 @@ HTML;
// TODO rewrite this fcking crap
function renderLogo($ctx, array $path_map = [], array $link_map = []): string {
- $uri = RequestDispatcher::path();
+ $uri = request_path();
- if (!admin::isAdmin()) {
+ if (!is_admin()) {
$prompt_sign = '$';
} else {
$prompt_sign = '#';
diff --git a/skin/error.skin.php b/skin/error.skin.php
index 5276bfa..8f7e4c7 100644
--- a/skin/error.skin.php
+++ b/skin/error.skin.php
@@ -4,34 +4,17 @@ namespace skin\error;
use Stringable;
-function forbidden($ctx, $message) {
- return $ctx->common(403, 'Forbidden', $message);
-}
-
-function not_found($ctx, $message) {
- return $ctx->common(404, 'Not Found', $message);
-}
-
-function unauthorized($ctx, $message) {
- return $ctx->common(401, 'Unauthorized', $message);
-}
-
-function not_implemented($ctx, $message) {
- return $ctx->common(501, 'Not Implemented', $message);
-}
-
-function common($ctx,
- int $code,
- string|Stringable $title,
- string|Stringable|null $message = null) {
+function http_error($ctx,
+ int $code,
+ string|Stringable $title,
+ string|Stringable|null $message = null) {
return <<
$code $title
$code $title
-
{$ctx->if_true($message,
- ''.$message.' '
+ '
'.$message.' '
)}
diff --git a/strings/main.yaml b/strings/main.yaml
new file mode 100644
index 0000000..e06e51d
--- /dev/null
+++ b/strings/main.yaml
@@ -0,0 +1,103 @@
+# common
+ch1p: 'ch1p'
+site_title: 'ch1p'
+index_title: 'Home | ch1p'
+
+posts: 'posts'
+all_posts: 'all posts'
+blog: 'blog'
+contacts: 'contacts'
+email: 'email'
+projects: 'projects'
+unknown_error: 'Unknown error'
+error: 'Error'
+write: 'Write'
+submit: 'submit'
+edit: 'edit'
+delete: 'delete'
+info_saved: 'Information saved.'
+toc: 'Table of Contents'
+
+# theme switcher
+theme_auto: 'auto'
+theme_dark: 'dark'
+theme_light: 'light'
+
+# contacts
+contacts_email: 'email'
+contacts_pgp: 'OpenPGP public key'
+contacts_tg: 'telegram'
+contacts_freenode: 'freenode'
+
+# blog
+blog_tags: 'tags'
+blog_latest: 'Latest posts'
+blog_no: 'No posts yet.'
+blog_view_all: 'View all'
+blog_write: 'Write a post'
+blog_post_delete_confirmation: 'Are you sure you want to delete this post?'
+blog_post_edit_title: 'Edit post "%s"'
+blog_post_hidden: 'Hidden'
+blog_tag_title: 'Posts tagged with "%s"'
+blog_tag_not_found: 'No posts found.'
+blog_comments_text: 'If you have any comments, contact me by email.'
+
+blog_write_form_preview_btn: 'Preview'
+blog_write_form_submit_btn: 'Submit'
+blog_write_form_title: 'Title'
+blog_write_form_text: 'Text'
+blog_write_form_preview: 'Preview'
+blog_write_form_enter_text: 'Enter text..'
+blog_write_form_enter_title: 'Enter title..'
+blog_write_form_tags: 'Tags'
+blog_write_form_visible: 'Visible'
+blog_write_form_toc: 'ToC'
+blog_write_form_short_name: 'Short name'
+blog_write_form_toggle_wrap: 'Toggle wrap'
+blog_write_form_options: 'Options'
+
+blog_uploads: 'Uploads'
+blog_upload: 'Upload files'
+blog_upload_delete: 'Delete'
+blog_upload_delete_confirmation: 'Are you sure you want to delete this upload?'
+blog_upload_show_md: 'Show md'
+blog_upload_form_file: 'File'
+blog_upload_form_custom_name: 'Custom name'
+blog_upload_form_note: 'Note'
+
+# blog (errors)
+err_blog_no_title: 'Title not specified'
+err_blog_no_text: 'Text not specified'
+err_blog_no_tags: 'Tags not specified'
+err_blog_db_err: 'Database error'
+err_blog_no_short_name: 'Short name not specified'
+err_blog_short_name_exists: 'This short name already exists'
+
+# pages
+pages_create: 'create new page'
+pages_edit: 'edit'
+pages_delete: 'delete'
+pages_create_title: 'create new page "%s"'
+pages_page_delete_confirmation: 'Are you sure you want to delete this page?'
+pages_page_edit_title: 'Edit %s'
+
+pages_write_form_submit_btn: 'Submit'
+pages_write_form_title: 'Title'
+pages_write_form_text: 'Text'
+pages_write_form_enter_text: 'Enter text..'
+pages_write_form_enter_title: 'Enter title..'
+pages_write_form_visible: 'Visible'
+pages_write_form_short_name: 'Short name'
+pages_write_form_toggle_wrap: 'Toggle wrap'
+pages_write_form_options: 'Options'
+
+# pages (errors)
+err_pages_no_title: 'Title not specified'
+err_pages_no_text: 'Text not specified'
+err_pages_no_id: 'ID not specified'
+err_pages_no_short_name: 'Short name not specified'
+err_pages_db_err: 'Database error'
+
+# admin-switch
+admin_title: "Admin"
+as_form_password: 'Password'
diff --git a/stubs/vkflex.php b/stubs/vkflex.php
new file mode 100644
index 0000000..9a92533
--- /dev/null
+++ b/stubs/vkflex.php
@@ -0,0 +1,11 @@
+ | |