Support HTML links in MAX poster wrappers

This commit is contained in:
Your Name
2026-08-04 20:16:19 +05:00
parent 347d1dfe2f
commit d66be9f7a6
5 changed files with 15 additions and 3 deletions
+2
View File
@@ -60,6 +60,8 @@ Database settings:
- `vk_poster_header_text` / `vk_poster_footer_text` - `vk_poster_header_text` / `vk_poster_footer_text`
- `max_poster_header_text` / `max_poster_footer_text` - `max_poster_header_text` / `max_poster_footer_text`
Empty header/footer settings add nothing. Empty header/footer settings add nothing.
MAX sends wrapper text as HTML. For clickable text use:
`<a href="https://example.com">Link text</a>`.
## Workers ## Workers
+2
View File
@@ -92,6 +92,8 @@ canonical git repository as FN-8. Code work for both projects must happen in
`tg_poster_header_text`, `tg_poster_footer_text`, `tg_poster_header_text`, `tg_poster_footer_text`,
`vk_poster_header_text`, `vk_poster_footer_text`, `vk_poster_header_text`, `vk_poster_footer_text`,
`max_poster_header_text`, `max_poster_footer_text`. `max_poster_header_text`, `max_poster_footer_text`.
- MAX header/footer text is sent as HTML. For clickable text use:
`<a href="https://example.com">Link text</a>`.
- The editor textarea must show only clean editable text. - The editor textarea must show only clean editable text.
- The list preview in `/editor` should show the publication preview, including composed hashtags. - The list preview in `/editor` should show the publication preview, including composed hashtags.
- `build_publication_text()` in `src/vk_parser_app/text_utils.py` is display/composition helper only. Do not use it before writing `final_text` to DB. - `build_publication_text()` in `src/vk_parser_app/text_utils.py` is display/composition helper only. Do not use it before writing `final_text` to DB.
@@ -21,7 +21,7 @@ VALUES
'""'::jsonb, '""'::jsonb,
'text', 'text',
'MAX текст в начале поста', 'MAX текст в начале поста',
'Текст, который добавляется перед постом только для MAX. Если пусто, ничего не добавляется.', 'Текст, который добавляется перед постом только для MAX. Если пусто, ничего не добавляется. Поддерживается HTML-разметка ссылок: <a href="https://example.com">Текст</a>.',
'MAX Poster' 'MAX Poster'
), ),
( (
@@ -29,7 +29,7 @@ VALUES
'""'::jsonb, '""'::jsonb,
'text', 'text',
'MAX текст перед хэштегами', 'MAX текст перед хэштегами',
'Текст, который добавляется после поста и перед хэштегами только для MAX.', 'Текст, который добавляется после поста и перед хэштегами только для MAX. Поддерживается HTML-разметка ссылок: <a href="https://example.com">Текст</a>.',
'MAX Poster' 'MAX Poster'
) )
ON CONFLICT (key) DO NOTHING; ON CONFLICT (key) DO NOTHING;
@@ -0,0 +1,7 @@
UPDATE app_settings
SET description = 'Текст, который добавляется перед постом только для MAX. Если пусто, ничего не добавляется. Поддерживается HTML-разметка ссылок: <a href="https://example.com">Текст</a>.'
WHERE key = 'max_poster_header_text';
UPDATE app_settings
SET description = 'Текст, который добавляется после поста и перед хэштегами только для MAX. Поддерживается HTML-разметка ссылок: <a href="https://example.com">Текст</a>.'
WHERE key = 'max_poster_footer_text';
+2 -1
View File
@@ -156,7 +156,7 @@ class MAXAPIClient:
raise RuntimeError(last_error or "MAX API request failed") raise RuntimeError(last_error or "MAX API request failed")
async def send_message(self, chat_id: int, text: str, attachments: list[dict[str, Any]] | None = None) -> dict[str, Any]: async def send_message(self, chat_id: int, text: str, attachments: list[dict[str, Any]] | None = None) -> dict[str, Any]:
payload: dict[str, Any] = {"text": text, "notify": True} payload: dict[str, Any] = {"text": text, "notify": True, "format": "html"}
if attachments: if attachments:
payload["attachments"] = attachments payload["attachments"] = attachments
return await self.request("POST", f"/messages?chat_id={chat_id}", json=payload) return await self.request("POST", f"/messages?chat_id={chat_id}", json=payload)
@@ -384,6 +384,7 @@ class MAXPoster:
self.common_tags, self.common_tags,
self.footer_text, self.footer_text,
self.header_text, self.header_text,
parse_mode="html",
) )
async def download_media_to_temp(self, session: aiohttp.ClientSession, item: dict[str, Any]) -> Path | None: async def download_media_to_temp(self, session: aiohttp.ClientSession, item: dict[str, Any]) -> Path | None: