posts: support editing of source_url and keywords

This commit is contained in:
E. S. 2024-09-12 03:26:21 +03:00
parent a2d9f93ad9
commit 392c3bc809
7 changed files with 131 additions and 88 deletions

View File

@ -126,8 +126,10 @@ function add_meta(array $data) {
break; break;
case '$description': case '$description':
$add_og_twitter(substr($key, 1), $value); case '$keywords':
$real_meta[] = ['name' => 'description', 'content' => $value]; $real_name = substr($key, 1);
$add_og_twitter($real_name, $value);
$real_meta[] = ['name' => $real_name, 'content' => $value];
break; break;
default: default:

View File

@ -502,6 +502,8 @@ class AdminHandler extends request_handler {
text: '', text: '',
langs: PostLanguage::cases(), langs: PostLanguage::cases(),
short_name: '', short_name: '',
source_url: '',
keywords: '',
js_texts: $js_texts, js_texts: $js_texts,
lang: PostLanguage::getDefault()->value); lang: PostLanguage::getDefault()->value);
} }
@ -632,6 +634,8 @@ class AdminHandler extends request_handler {
toc: $text->toc, toc: $text->toc,
saved: $saved, saved: $saved,
short_name: $short_name, short_name: $short_name,
source_url: $post->sourceUrl,
keywords: $post->keywords,
langs: PostLanguage::cases(), langs: PostLanguage::cases(),
lang: $text->lang->value, lang: $text->lang->value,
js_texts: $js_texts js_texts: $js_texts
@ -641,7 +645,7 @@ class AdminHandler extends request_handler {
function POST_post_edit() { function POST_post_edit() {
ensure_xhr(); ensure_xhr();
list($old_short_name, $short_name, $langs, $date) = input('short_name, new_short_name, langs, date'); list($old_short_name, $short_name, $langs, $date, $keywords, $source_url) = input('short_name, new_short_name, langs, date, keywords, source_url');
$post = posts::getByName($old_short_name); $post = posts::getByName($old_short_name);
if (!$post) if (!$post)
@ -685,7 +689,12 @@ class AdminHandler extends request_handler {
} }
} }
$post_data = ['date' => $date, 'visible' => $visible]; $post_data = [
'date' => $date,
'visible' => $visible,
'keywords' => $keywords,
'source_url' => $source_url
];
if ($post->shortName != $short_name) if ($post->shortName != $short_name)
$post_data['short_name'] = $short_name; $post_data['short_name'] = $short_name;
$post->edit($post_data); $post->edit($post_data);

View File

@ -93,11 +93,15 @@ class MainHandler extends request_handler {
$other_langs[] = $pl->value; $other_langs[] = $pl->value;
} }
add_meta([ $meta = [
'$title' => $pt->title, '$title' => $pt->title,
'$url' => $config['domain'].$post->getUrl(), '$url' => $config['domain'].$post->getUrl(),
'$description' => $pt->getDescriptionPreview(155) '$description' => $pt->getDescriptionPreview(155)
]); ];
if ($post->keywords)
$meta['$keywords'] = $post->keywords;
add_meta($meta);
if (($img = $pt->getFirstImage()) !== null) if (($img = $pt->getFirstImage()) !== null)
add_meta(['$image' => $img->getDirectUrl()]); add_meta(['$image' => $img->getDirectUrl()]);

View File

@ -150,6 +150,8 @@ extend(AdminWriteEditForm.prototype, {
var atLeastOneLangIsWritten = false; var atLeastOneLangIsWritten = false;
var writtenLangs = []; var writtenLangs = [];
if (this.isPost()) { if (this.isPost()) {
fd.append('source_url', evt.target.source_url.value)
fd.append('keywords', evt.target.keywords.value)
this.opts.langs.forEach(function(l) { this.opts.langs.forEach(function(l) {
var title = this.draft.getForLang(l, 'title'); var title = this.draft.getForLang(l, 'title');
var text = this.draft.getForLang(l, 'text'); var text = this.draft.getForLang(l, 'text');

View File

@ -19,6 +19,7 @@ class Post extends model {
public bool $visible; public bool $visible;
public string $shortName; public string $shortName;
public string $sourceUrl; public string $sourceUrl;
public string $keywords;
protected array $texts = []; protected array $texts = [];

View File

@ -161,6 +161,8 @@ function postForm(\SkinContext $ctx,
string|Stringable $title, string|Stringable $title,
string|Stringable $text, string|Stringable $text,
string|Stringable $short_name, string|Stringable $short_name,
string|Stringable $source_url,
string|Stringable $keywords,
array $langs, array $langs,
array $js_texts, array $js_texts,
string|Stringable|null $date = null, string|Stringable|null $date = null,
@ -238,6 +240,28 @@ $html = <<<HTML
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="3">
<div class="clearfix">
<table width="100%" cellspacing="0" cellpadding="0" style="table-layout: fixed; width: 100%; border-collapse: collapse">
<tr>
<td width="50%" style="width: 50% !important;">
<div class="form-field-label">{$ctx->lang('blog_write_form_keywords')}</div>
<div class="form-field">
<input class="form-field-input" type="text" name="keywords" value="{$keywords}" />
</div>
</td>
<td width="50%" style="width: 50% !important;">
<div class="form-field-label">{$ctx->lang('blog_write_form_source')}</div>
<div class="form-field">
<input class="form-field-input" type="text" name="source_url" value="{$source_url}" />
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="clearfix"> <div class="clearfix">

View File

@ -1,24 +1,24 @@
# common # common
4in1: '4in1' 4in1: 4in1
site_title: '4in1. Mask of Shakespeare, mysteries of Bacon, book by Cartier, secrets of the NSA' site_title: 4in1. Mask of Shakespeare, mysteries of Bacon, book by Cartier, secrets of the NSA
index: 'Index' index: Index
posts: 'Posts' posts: Posts
all_posts: 'All posts' all_posts: All posts
articles: 'Articles' articles: Articles
unknown_error: 'Unknown error' unknown_error: Unknown error
error: 'Error' error: Error
write: 'Write' write: Write
submit: 'submit' submit: submit
sign_in: "Sign in" sign_in: Sign in
edit: 'edit' edit: edit
delete: 'delete' delete: delete
save: "Save" save: Save
info_saved: 'Information saved.' info_saved: Information saved.
toc: 'Table of Contents' toc: Table of Contents
lang_en: "English" lang_en: English
lang_ru: "Русский" lang_ru: Русский
# meta # meta
meta_index_title: "4in1. Mask of Shakespeare, mysteries of Bacon, book by Cartier, secrets of the NSA" meta_index_title: "4in1. Mask of Shakespeare, mysteries of Bacon, book by Cartier, secrets of the NSA"
@ -40,75 +40,76 @@ meta_files_baconiana_description: "Searchable archive of Baconiana almanac."
blog_expl_en: "Here you can find new episodes of the \"4in1\" investigation that were published after book's initial release in 2022 and throughout the preparation of its 2nd edition and English translation in 2023.\n\nSince the main purpose of this section is publishing English translations of articles from the kiwi arXiv website, they appear here with a slight delay caused by the translation." blog_expl_en: "Here you can find new episodes of the \"4in1\" investigation that were published after book's initial release in 2022 and throughout the preparation of its 2nd edition and English translation in 2023.\n\nSince the main purpose of this section is publishing English translations of articles from the kiwi arXiv website, they appear here with a slight delay caused by the translation."
blog_expl_ru: "Здесь находятся новые эпизоды расследования, опубликованные после первоначального выхода книги «4в1» в 2022-м году и во время и после подготовки её 2-го издания и перевода его на английский язык в 2023-м.\n\nПоскольку основная цель этого раздела публикация английских переводов статей с киви-архива, здесь они появляются с небольшой задержкой, этим переводом вызванной." blog_expl_ru: "Здесь находятся новые эпизоды расследования, опубликованные после первоначального выхода книги «4в1» в 2022-м году и во время и после подготовки её 2-го издания и перевода его на английский язык в 2023-м.\n\nПоскольку основная цель этого раздела публикация английских переводов статей с киви-архива, здесь они появляются с небольшой задержкой, этим переводом вызванной."
blog_new_post: "New post" blog_new_post: New post
blog_view_post: "View post" blog_view_post: View post
view_page: "View page" view_page: View page
#blog_editing: "Editing..." blog_latest: Latest posts
blog_latest: 'Latest posts' blog_no: No posts yet.
blog_no: 'No posts yet.' blog_view_all: View all
blog_view_all: 'View all' blog_write: Write a post
blog_write: 'Write a post'
blog_post_delete_confirmation: 'Are you sure you want to delete this post?' blog_post_delete_confirmation: 'Are you sure you want to delete this post?'
blog_post_edit_title: 'Edit post "%s"' blog_post_edit_title: 'Edit post "%s"'
blog_post_hidden: 'Hidden' blog_post_hidden: Hidden
blog_comments_text: 'If you have any comments, <a href="mailto:%s?subject=%s">contact me by email</a>.' blog_comments_text: 'If you have any comments, <a href="mailto:%s?subject=%s">contact me by email</a>.'
blog_read_in_ru: "Читать на русском" blog_read_in_ru: Читать на русском
blog_read_in_en: "Read in English" blog_read_in_en: Read in English
blog_write_form_preview_btn: 'Preview' blog_write_form_preview_btn: Preview
blog_write_form_submit_btn: 'Submit' blog_write_form_submit_btn: Submit
blog_write_form_title: 'Title' blog_write_form_title: Title
blog_write_form_text: 'Text' blog_write_form_text: Text
blog_write_form_date: 'Date' blog_write_form_date: Date
blog_write_form_preview: 'Preview' blog_write_form_preview: Preview
blog_write_form_enter_text: 'Enter text..' blog_write_form_enter_text: Enter text..
blog_write_form_enter_title: 'Enter title..' blog_write_form_enter_title: Enter title..
blog_write_form_visible: 'Visible' blog_write_form_visible: Visible
blog_write_form_toc: 'ToC' blog_write_form_toc: ToC
blog_write_form_short_name: 'Short name' blog_write_form_short_name: Short name
blog_write_form_toggle_wrap: 'Toggle wrap' blog_write_form_source: Source URL
blog_post_options: "Post options" blog_write_form_keywords: Keywords
blog_text_options: "Text options" blog_write_form_toggle_wrap: Toggle wrap
blog_post_options: Post options
blog_text_options: Text options
blog_uploads: 'Uploads' blog_uploads: Uploads
blog_upload: 'Upload files' blog_upload: Upload files
blog_upload_delete: 'Delete' blog_upload_delete: Delete
blog_upload_delete_confirmation: 'Are you sure you want to delete this upload?' blog_upload_delete_confirmation: Are you sure you want to delete this upload?
blog_upload_show_md: 'Show md' blog_upload_show_md: Show md
blog_upload_form_file: 'File' blog_upload_form_file: File
blog_upload_form_custom_name: 'Custom name' blog_upload_form_custom_name: Custom name
blog_upload_form_note: 'Note' blog_upload_form_note: Note
# blog (errors) # blog (errors)
err_blog_no_text: 'Text or title is not specified' err_blog_no_text: Text or title is not specified
err_blog_no_date: 'Date is not specified' err_blog_no_date: Date is not specified
err_blog_db_err: 'Database error' err_blog_db_err: Database error
err_blog_no_short_name: 'Short name not specified' err_blog_no_short_name: Short name not specified
err_blog_short_name_exists: 'This short name already exists' err_blog_short_name_exists: This short name already exists
# pages # pages
pages_create: 'create new page' pages_create: create new page
pages_edit: 'edit' pages_edit: edit
pages_delete: 'delete' pages_delete: delete
pages_create_title: 'create new page "%s"' pages_create_title: create new page "%s"
pages_page_delete_confirmation: 'Are you sure you want to delete this page?' pages_page_delete_confirmation: Are you sure you want to delete this page?
pages_page_edit_title: 'Edit %s' pages_page_edit_title: Edit %s
pages_write_form_submit_btn: 'Submit' pages_write_form_submit_btn: Submit
pages_write_form_title: 'Title' pages_write_form_title: Title
pages_write_form_text: 'Text' pages_write_form_text: Text
pages_write_form_enter_text: 'Enter text..' pages_write_form_enter_text: Enter text..
pages_write_form_enter_title: 'Enter title..' pages_write_form_enter_title: Enter title..
pages_write_form_visible: 'Visible' pages_write_form_visible: Visible
pages_write_form_short_name: 'Short name' pages_write_form_short_name: Short name
pages_write_form_toggle_wrap: 'Toggle wrap' pages_write_form_toggle_wrap: Toggle wrap
pages_write_form_options: 'Options' pages_write_form_options: Options
# pages (errors) # pages (errors)
err_pages_no_text: 'Text or title is not specified' err_pages_no_text: Text or title is not specified
err_pages_no_id: 'ID not specified' err_pages_no_id: ID not specified
err_pages_no_short_name: 'Short name not specified' err_pages_no_short_name: Short name not specified
err_pages_db_err: 'Database error' err_pages_db_err: Database error
# /admin # /admin
admin_title: Admin admin_title: Admin
@ -153,11 +154,11 @@ files_search_results_count:
- "No results" - "No results"
files_show_more: Show more files_show_more: Show more
pages: 'Страницы' pages: Страницы
pn_show_more: 'Показать ещё' pn_show_more: Показать ещё
pn_prev: 'назад' pn_prev: назад
pn_next: 'вперёд' pn_next: вперёд
pn_first: 'в начало' pn_first: в начало
pn_last: 'в конец' pn_last: в конец
#pn_goto: 'Перейти' #pn_goto: Перейти
#pn_goto_n: '№ стр.' #pn_goto_n: '№ стр.'