diff --git a/templates/Edit.mediawiki b/templates/Edit.mediawiki index 6e99d15..d8c6a60 100644 --- a/templates/Edit.mediawiki +++ b/templates/Edit.mediawiki @@ -98,7 +98,7 @@ }} - + {{namespace_edit}} diff --git a/truewiki/views/edit.py b/truewiki/views/edit.py index 930102f..a993346 100644 --- a/truewiki/views/edit.py +++ b/truewiki/views/edit.py @@ -14,7 +14,7 @@ from ..wiki_page import WikiPage -def save(user, old_page: str, new_page: str, content: str, payload) -> web.Response: +def save(user, old_page: str, new_page: str, content: str, payload, summary: str = None) -> web.Response: wiki_page = WikiPage(old_page) page_error = wiki_page.page_is_valid(old_page, is_new_page=True) if page_error: @@ -44,6 +44,9 @@ def save(user, old_page: str, new_page: str, content: str, payload) -> web.Respo create_new = False commit_message = f"modified: {old_page}" + if summary: + commit_message += f"\n\nUser Summary: {summary}" + old_filename = wiki_page.page_ondisk_name(old_page) # If we are not renaming to the same page (in lower-case), ensure we are diff --git a/truewiki/web_routes.py b/truewiki/web_routes.py index 6a09fcc..2a556ee 100644 --- a/truewiki/web_routes.py +++ b/truewiki/web_routes.py @@ -192,6 +192,14 @@ async def edit_page_post(request): if "content" not in payload: raise web.HTTPNotFound() content = payload["content"].replace("\r", "") + summary = payload["summary"].replace("\r", "") + + # Make sure summary is not more than 500 chars. This is normally limited + # by the HTML form itself, so if this is somehow longer, people have + # been messing with the HTML. We should probably just reject the request + # at this point. + if len(summary) > 500: + raise web.HTTPBadRequest(reason="Summary exceeds maximum length of 500 characters.") # Make sure that page names don't contain /../ or anything silly. new_page = payload.get("page", page) @@ -200,7 +208,7 @@ async def edit_page_post(request): new_page = f"{path}/{filename}" if "save" in payload: - return edit.save(user, page, new_page, content, payload) + return edit.save(user, page, new_page, content, payload, summary) if "preview" in payload: return preview.view(user, page, new_page, content)