diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2021-04-05 15:48:48 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2021-04-05 15:48:48 +0100 |
commit | 6d6bec35f271b5ff072a884fbfc31f5b9cb36642 (patch) | |
tree | 37ce6421b4959f52e33255cff3b2d928a5646754 /core/views/expo.py | |
parent | 9db1a8490c1eabbdf06d29fa3e1655bed89caf5c (diff) | |
download | troggle-6d6bec35f271b5ff072a884fbfc31f5b9cb36642.tar.gz troggle-6d6bec35f271b5ff072a884fbfc31f5b9cb36642.tar.bz2 troggle-6d6bec35f271b5ff072a884fbfc31f5b9cb36642.zip |
fix incorrect folder when showing index.html
Diffstat (limited to 'core/views/expo.py')
-rw-r--r-- | core/views/expo.py | 17 |
1 files 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 = '''<head> <li><form name=P method=get action="/search" target="_top"> <input id="omega-autofocus" type=search name=P value="testing" size=8 autofocus> <input type=submit value="Search"></li> -<li><a href="/years/1983/index.html_edit" class="editlink"><strong>Edit this page</strong></a></li> - </ul>''' 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() + '<h3>HTML Parsing failure:<br>Page could not be parsed into header and body:<br>failure detected in expowebpage in views.expo.py</h3> Please edit this <var>:expoweb:</var> page to be in the expected full HTML format by clicking on \'Edit this Page\' in the left hand menu.</body' ) + return HttpResponse(default_head + html.decode() + '<h3>HTML Parsing failure:<br>Page could not be parsed into header and body:<br>failure detected in expowebpage in views.expo.py</h3> Please edit this <var>:expoweb:</var> page to be in the expected full HTML format </body' ) m = re.search(rb"<title>(.*)</title>", 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() + '<h3>HTML Parsing failure:<br>Page could not be parsed into header and body:<br>failure detected in expowebpage in views.expo.py</h3> Please edit this <var>:expoweb:</var> page to be in the expected full HTML format by clicking on \'Edit this Page\' in the left hand menu.</body' ) + return HttpResponse(default_head + html + '<h3>HTML Parsing failure:<br>Page could not be parsed into header and body:<br>failure detected in expowebpage in views.expo.py</h3> Please edit this <var>:expoweb:</var> page to be in the expected full HTML format .</body' ) except IOError: print("### File not found ### ", filepath) filefound = False |