forked from expo/troggle
fix incorrect folder when showing index.html
This commit is contained in:
parent
9db1a8490c
commit
6d6bec35f2
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user