Skip to content

Commit

Permalink
Merge pull request #1741 from UlrichB22/dump_html_pdf
Browse files Browse the repository at this point in the history
dump-html: dump raw data for pdf, tar and others
  • Loading branch information
RogerHaase authored Aug 25, 2024
2 parents 739477b + f8a8cad commit 0b4b6e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/moin/cli/maint/dump_html.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright: 2015-2017 MoinMoin:RogerHaase
# Copyright: 2023 MoinMoin project
# Copyright: 2023-2024 MoinMoin project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -54,7 +54,12 @@
from moin.app import create_app, before_wiki, setup_user_anon
from moin.apps.frontend.views import show_item
from moin.constants.keys import CURRENT, NAME_EXACT, WIKINAME, THEME_NAME, LATEST_REVS
from moin.constants.contenttypes import CONTENTTYPE_MEDIA, CONTENTTYPE_MEDIA_SUFFIX
from moin.constants.contenttypes import (
CONTENTTYPE_MEDIA,
CONTENTTYPE_MEDIA_SUFFIX,
CONTENTTYPE_OTHER,
CONTENTTYPE_OTHER_SUFFIX,
)
from moin.items import Item

from moin import log
Expand Down Expand Up @@ -221,7 +226,9 @@ def Dump(directory="HTML", theme="topside_cms", exclude_ns="userprofiles", user=
# save rendered items or raw data to dump directory root
contenttype = item.meta["contenttype"].split(";")[0]
os.makedirs(os.path.dirname(filename), exist_ok=True)
if contenttype in CONTENTTYPE_MEDIA and filename.endswith(CONTENTTYPE_MEDIA_SUFFIX):
if contenttype in (CONTENTTYPE_MEDIA + CONTENTTYPE_OTHER) and filename.endswith(
CONTENTTYPE_MEDIA_SUFFIX + CONTENTTYPE_OTHER_SUFFIX
):
# do not put a rendered html-formatted file with a name like video.mp4 into root;
# browsers want raw data
with open(filename, "wb") as f:
Expand Down
4 changes: 3 additions & 1 deletion src/moin/constants/contenttypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright: 2011 MoinMoin:ThomasWaldmann
# Copyright: 2023 MoinMoin project
# Copyright: 2023-2024 MoinMoin project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -109,6 +109,8 @@
"application/pdf",
]

CONTENTTYPE_OTHER_SUFFIX = tuple(".tar .tgz .zip .pdf ".split())

CONTENTTYPES_MAP = {
"text/x.moin.wiki;charset=utf-8": "Moinmoin",
"text/x.moin.wiki;format=1.9;charset=utf-8": "Moinmoin 1.9",
Expand Down

0 comments on commit 0b4b6e3

Please sign in to comment.