forked from expo/troggle
add /troggle dir (Martin's changes to get main site back as entry point)
This commit is contained in:
commit
0bfcbdc9cc
@ -15,6 +15,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
def flatpage(request, path):
|
def flatpage(request, path):
|
||||||
|
print "gggggg", path
|
||||||
try:
|
try:
|
||||||
r = Redirect.objects.get(originalURL = path)
|
r = Redirect.objects.get(originalURL = path)
|
||||||
return HttpResponseRedirect(r.newURL) # Redirect after POST
|
return HttpResponseRedirect(r.newURL) # Redirect after POST
|
||||||
@ -36,6 +37,18 @@ def flatpage(request, path):
|
|||||||
|
|
||||||
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
|
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
|
||||||
|
|
||||||
|
if path.endswith("/") or path == "":
|
||||||
|
try:
|
||||||
|
o = open(os.path.normpath(settings.EXPOWEB + path + "index.html"), "rb")
|
||||||
|
path = path + "index.html"
|
||||||
|
except IOError:
|
||||||
|
try:
|
||||||
|
o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb")
|
||||||
|
path = path + "index.html"
|
||||||
|
except IOError:
|
||||||
|
raise Http404
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
o = open(os.path.normpath(settings.EXPOWEB + path), "rb")
|
o = open(os.path.normpath(settings.EXPOWEB + path), "rb")
|
||||||
except IOError:
|
except IOError:
|
||||||
@ -56,14 +69,29 @@ def flatpage(request, path):
|
|||||||
body = unicode(body, "iso-8859-1")
|
body = unicode(body, "iso-8859-1")
|
||||||
return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'head': head, 'body': body, "bodyid": bodyid})
|
return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'head': head, 'body': body, "bodyid": bodyid})
|
||||||
else:
|
else:
|
||||||
return HttpResponse(o.read())
|
return HttpResponse(o.read(), mimetype=getmimetype(path))
|
||||||
|
|
||||||
|
def getmimetype(path):
|
||||||
|
if path.endswith(".png"): return "image/png"
|
||||||
|
if path.endswith(".tif"): return "image/tif"
|
||||||
|
if path.endswith(".gif"): return "image/gif"
|
||||||
|
if path.endswith(".jpeg"): return "image/jpeg"
|
||||||
|
if path.endswith(".jpg"): return "image/jpeg"
|
||||||
|
if path.endswith("svg"): return "image/svg+xml"
|
||||||
|
if path.endswith(".pdf"): return "application/pdf"
|
||||||
|
if path.endswith(".ps"): return "application/postscript"
|
||||||
|
if path.endswith(".svx"): return "application/x-survex-svx"
|
||||||
|
if path.endswith(".3d"): return "application/x-survex-3d"
|
||||||
|
if path.endswith(".pos"): return "application/x-survex-pos"
|
||||||
|
if path.endswith(".err"): return "application/x-survex-err"
|
||||||
|
return ""
|
||||||
|
|
||||||
@login_required_if_public
|
@login_required_if_public
|
||||||
def editflatpage(request, path):
|
def editflatpage(request, path):
|
||||||
try:
|
try:
|
||||||
r = CaveRedirect.objects.get(originalURL = path)
|
r = Cave.objects.get(url = path)
|
||||||
return troggle.core.views_caves.editCave(request, r.cave.slug)
|
return troggle.core.views_caves.editCave(request, r.cave.slug)
|
||||||
except CaveRedirect.DoesNotExist:
|
except Cave.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
<body{% if bodyid %} id="{{ bodyid }}"{% endif %}>
|
<body{% if bodyid %} id="{{ bodyid }}"{% endif %}>
|
||||||
{{ body|safe }}
|
{{ body|safe }}
|
||||||
{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}
|
{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}
|
||||||
|
<a href="/troggle">Troggle</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user