From 6d6bec35f271b5ff072a884fbfc31f5b9cb36642 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 5 Apr 2021 15:48:48 +0100 Subject: [PATCH] fix incorrect folder when showing index.html --- core/views/expo.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/core/views/expo.py b/core/views/expo.py index f0b74db..1be813d 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -46,8 +46,6 @@ default_head = '''
  • -
  • Edit this page
  • - ''' def expofiles_redirect(request, path): @@ -96,7 +94,7 @@ def expowebpage(request, expowebpath, path): if m: preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups() else: - return HttpResponse(default_head + html.decode() + '

    HTML Parsing failure:
    Page could not be parsed into header and body:
    failure detected in expowebpage in views.expo.py

    Please edit this :expoweb: page to be in the expected full HTML format by clicking on \'Edit this Page\' in the left hand menu.HTML Parsing failure:
    Page could not be parsed into header and body:
    failure detected in expowebpage in views.expo.py Please edit this :expoweb: page to be in the expected full HTML format (.*)", head, re.DOTALL + re.IGNORECASE) if m: title, = m.groups() @@ -158,13 +156,10 @@ def expopage(request, path): return expowebpage(request, expowebpath, path) if Path(expowebpath / path ).is_dir(): - for p in ["index.html", "index.htm", "default.html"]: - try: - o = open(os.path.normpath(expowebpath / path / p), "rb") - except IOError: - pass - else: # no exception, so file was found - return expowebpage(request, expowebpath, Path(path) / p) + for p in ["index.html", "index.htm"]: + if (expowebpath / path / p).is_file(): + # This needs to reset the path to the new subdirectory + return HttpResponseRedirect('/'+str(Path(path) / p)) return render(request, 'pagenotfound.html', {'path': Path(path) / "index.html"}) if path.endswith("/"): @@ -240,7 +235,7 @@ def editexpopage(request, path): # body = str(body, "iso-8859-1") else: #return HttpResponse("Page could not be split into header and body") - return HttpResponse(default_head + html.decode() + '

    HTML Parsing failure:
    Page could not be parsed into header and body:
    failure detected in expowebpage in views.expo.py

    Please edit this :expoweb: page to be in the expected full HTML format by clicking on \'Edit this Page\' in the left hand menu.HTML Parsing failure:
    Page could not be parsed into header and body:
    failure detected in expowebpage in views.expo.py Please edit this :expoweb: page to be in the expected full HTML format .