annotate libervia/web/pages/blog/edit/page_meta.py @ 1584:eab815e48795

browser (chat): message edition + extra menu: - handle extra menu - implement `quote` action - last message correction - show popup with last editions history when "editer" pencil icon is hovered - up arrow let quickly edit last message - implement input modes, `normal` being the default, `edit` or `quote` are new ones. - [ESC] erase input and returns to `normal` mode - fix size and set focus on message input when page is loaded - fix identity retrieval on new messages
author Goffi <goffi@goffi.org>
date Tue, 28 Nov 2023 17:59:11 +0100
parents eb00d593801d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1416
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
1518
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
3 from libervia.web.server.constants import Const as C
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
4 from libervia.backend.core.log import getLogger
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
5 from libervia.backend.tools.common import data_format
1416
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 log = getLogger(__name__)
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
8
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 name = "blog_edit"
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 access = C.PAGES_ACCESS_PROFILE
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 template = "blog/publish.html"
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
12
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
13
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 async def on_data_post(self, request):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
15 profile = self.get_profile(request)
1416
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 if profile is None:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
17 self.page_error(request, C.HTTP_FORBIDDEN)
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
18 request_data = self.get_r_data(request)
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
19 title, tags, body = self.get_posted_data(request, ('title', 'tags', 'body'))
1495
081b4f8a63d8 pages (blog/edit): allow comments when editing a post
Goffi <goffi@goffi.org>
parents: 1420
diff changeset
20 mb_data = {"content_rich": body, "allow_comments": True}
1416
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 title = title.strip()
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 if title:
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 mb_data["title_rich"] = title
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 tags = [t.strip() for t in tags.split(',') if t.strip()]
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 if tags:
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 mb_data["tags"] = tags
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
28 await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
29 'mb_send',
1416
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 "",
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 "",
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 data_format.serialise(mb_data),
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 profile
0554103ec700 pages (blog): new `edit` page:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 )
1420
925a7c498cda pages (blog/edit): move preview code to new `BlogEditor` class in `editor` module
Goffi <goffi@goffi.org>
parents: 1416
diff changeset
35
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1495
diff changeset
36 request_data["post_redirect_page"] = self.get_page_by_name("blog")