diff --git a/contrib/css-build/README.md b/contrib/css-build/README.md index b8cc4e9fb..726824fe5 100644 --- a/contrib/css-build/README.md +++ b/contrib/css-build/README.md @@ -15,4 +15,4 @@ To build `theme.css` from `src/moin/themes/basic/scss/theme.scss` using the SASS Bootstrap 5.3 makes use of the deprecated `@import` directive and other deprecated SASS features, which causes many warnings to be output when compiling the Basic theme SCSS file. This is a know issue and is currently being worked on (see [dart-sass 1.80.0+ throwing a lot of deprecations](https://github.com/twbs/bootstrap/issues/40962) for details). -The build command in `package.json` uses options to suppress warnings resulting from the use of `@import` and any included dependencies. +The build command in `package.json` uses options to suppress warnings resulting from the use of `@import` and any included dependencies. diff --git a/contrib/wsgi/moin2.wsgi b/contrib/wsgi/moin2.wsgi index d7a690169..a5ab3cf03 100644 --- a/contrib/wsgi/moin2.wsgi +++ b/contrib/wsgi/moin2.wsgi @@ -24,28 +24,29 @@ import site moin_dir = os.path.dirname(os.path.abspath(__file__)) -if sys.platform == 'win32': - site.addsitedir(moin_dir + '-venv-python/Lib/site-packages') +if sys.platform == "win32": + site.addsitedir(moin_dir + "-venv-python/Lib/site-packages") else: - site.addsitedir(moin_dir + '-venv-{0}/lib/{0}/site-packages'.format(sys.executable)) + site.addsitedir(moin_dir + "-venv-{0}/lib/{0}/site-packages".format(sys.executable)) # make sure this directory is in sys.path (.lower() avoids duplicate entries on Windows) if not (moin_dir in sys.path or moin_dir.lower() in sys.path): sys.path.insert(0, moin_dir) # for debugging sys.path issues, comment out after things are working -print('== moin2.wsgi sys.path ==') +print("== moin2.wsgi sys.path ==") for p in sys.path: print(p) -print('== end moin2.wsgi sys.path ==') +print("== end moin2.wsgi sys.path ==") -wiki_config = moin_dir + '/wikiconfig_local.py' +wiki_config = moin_dir + "/wikiconfig_local.py" if not os.path.exists(wiki_config): - wiki_config = moin_dir + '/wikiconfig.py' -print('== wiki_config path =', wiki_config, '==') + wiki_config = moin_dir + "/wikiconfig.py" +print("== wiki_config path =", wiki_config, "==") # create the Moin (Flask) WSGI application from moin.app import create_app + application = create_app(wiki_config) # please note: if you want to do some wsgi app wrapping, do it like shown below: diff --git a/requirements.d/development.txt b/requirements.d/development.txt index 9fae55dd1..ba20487b6 100644 --- a/requirements.d/development.txt +++ b/requirements.d/development.txt @@ -7,4 +7,4 @@ lxml scrapy>=2.10.1 pre-commit # additional type hints -types-docutils \ No newline at end of file +types-docutils diff --git a/src/moin/apps/frontend/views.py b/src/moin/apps/frontend/views.py index 7d11331da..052599b27 100644 --- a/src/moin/apps/frontend/views.py +++ b/src/moin/apps/frontend/views.py @@ -2875,35 +2875,53 @@ def _diff(item, revid1, revid2, fqname, rev_ids): revid1, revid2 = revid2, revid1 common_ct = _common_type(oldrev.meta[CONTENTTYPE], newrev.meta[CONTENTTYPE]) - try: - item = Item.create(fqname.fullname, contenttype=common_ct, rev_id=newrev.revid) - except AccessDenied: - abort(403) + if common_ct: + try: + item = Item.create(fqname.fullname, contenttype=common_ct, rev_id=newrev.revid) + except AccessDenied: + abort(403) - # if there are many revisions, create rev_links dict with links to older and newer revisions on diff display - rev_links = {} - if len(rev_ids) > 2: - rev1_idx = rev_ids.index(revid1) - rev2_idx = rev_ids.index(revid2) - if rev1_idx > 0: - rev_links["r1_oldest"] = rev_ids[0] - rev_links["r1_older"] = rev_ids[rev1_idx - 1] - if rev2_idx > rev1_idx + 1: - rev_links["r1_newer"] = rev_ids[rev1_idx + 1] - end = len(rev_ids) - 1 - if rev2_idx < end: - rev_links["r2_newer"] = rev_ids[rev2_idx + 1] - rev_links["r2_newest"] = rev_ids[-1] - if rev2_idx > rev1_idx + 1: - rev_links["r2_older"] = rev_ids[rev2_idx - 1] - if rev_links: - rev_links["revid1"] = revid1 - rev_links["revid2"] = revid2 + # if there are many revisions, create rev_links dict with links to older and newer revisions on diff display + rev_links = {} + if len(rev_ids) > 2: + rev1_idx = rev_ids.index(revid1) + rev2_idx = rev_ids.index(revid2) + if rev1_idx > 0: + rev_links["r1_oldest"] = rev_ids[0] + rev_links["r1_older"] = rev_ids[rev1_idx - 1] + if rev2_idx > rev1_idx + 1: + rev_links["r1_newer"] = rev_ids[rev1_idx + 1] + end = len(rev_ids) - 1 + if rev2_idx < end: + rev_links["r2_newer"] = rev_ids[rev2_idx + 1] + rev_links["r2_newest"] = rev_ids[-1] + if rev2_idx > rev1_idx + 1: + rev_links["r2_older"] = rev_ids[rev2_idx - 1] + if rev_links: + rev_links["revid1"] = revid1 + rev_links["revid2"] = revid2 - try: - diff_html = Markup(item.content._render_data_diff(oldrev, newrev, rev_links=rev_links, fqname=fqname)) - except Exception: - return _crash(item, oldrev, newrev) + try: + diff_html = Markup(item.content._render_data_diff(oldrev, newrev, rev_links=rev_links, fqname=fqname)) + except Exception: + return _crash(item, oldrev, newrev) + else: + # no common content type (e.g. text/x-moin-wiki vs image/png) + # we can't render a diff, so we just show a message. + # we use the new revision's item to render the page structure around the message. + try: + item = Item.create(fqname.fullname, rev_id=newrev.revid) + except AccessDenied: + abort(403) + diff_html = ( + Markup('