2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00:00

edit this page working

This commit is contained in:
Philip Sargent 2020-06-18 15:54:40 +01:00
parent 640e1e3b5e
commit bd6490631f
2 changed files with 18 additions and 27 deletions

View File

@ -89,10 +89,10 @@ def flatpage(request, path):
menumatch = re.match(rb'(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE) menumatch = re.match(rb'(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
if menumatch: if menumatch:
has_menu = True has_menu = True
#body, = menumatch.groups() body, = menumatch.groups()
if re.search(rb"iso-8859-1", html): # if re.search(rb"iso-8859-1", html):
body = str(body, "iso-8859-1") # body = str(body, "iso-8859-1")
body.strip # body.strip
return render(request, 'flatpage.html', {'editable': editable, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu}) return render(request, 'flatpage.html', {'editable': editable, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu})
else: else:
return HttpResponse(o.read(), content_type=getmimetype(path)) return HttpResponse(o.read(), content_type=getmimetype(path))
@ -137,8 +137,8 @@ def editflatpage(request, path):
linksmatch = re.match(r'(.*)(<ul\s+id="links">.*)', body, re.DOTALL + re.IGNORECASE) linksmatch = re.match(r'(.*)(<ul\s+id="links">.*)', body, re.DOTALL + re.IGNORECASE)
if linksmatch: if linksmatch:
body, links = linksmatch.groups() body, links = linksmatch.groups()
if re.search(r"iso-8859-1", html): # if re.search(r"iso-8859-1", html):
body = str(body, "iso-8859-1") # body = str(body, "iso-8859-1")
else: else:
return HttpResponse("Page could not be split into header and body") return HttpResponse("Page could not be split into header and body")
except IOError: except IOError:

23
urls.py
View File

@ -15,15 +15,12 @@ from flatpages import views as flatviews
admin.autodiscover() admin.autodiscover()
# type url probably means it's used.
# HOW DOES THIS WORK: # HOW DOES THIS WORK:
# This is a "url dispatcher" - something needed by every web framework.
# url( <regular expression that matches the thing in the web browser>, # url( <regular expression that matches the thing in the web browser>,
# <reference to python function in 'core' folder>, # <reference to python function in 'core' folder>, <optional name>)
# <name optional argument for URL reversing (doesn't do much)>)
actualurlpatterns = [ actualurlpatterns = [
url(r'^troggle$', views_other.frontpage, name="frontpage"), url(r'^troggle$', views_other.frontpage, name="frontpage"),
url(r'^caves$', views_caves.caveindex, name="caveindex"), url(r'^caves$', views_caves.caveindex, name="caveindex"),
url(r'^indxal.htm$', views_caves.caveindex, name="caveindex"), url(r'^indxal.htm$', views_caves.caveindex, name="caveindex"),
@ -31,9 +28,10 @@ actualurlpatterns = [
url(r'^newqmnumber/?$', views_other.ajax_QM_number, ), url(r'^newqmnumber/?$', views_other.ajax_QM_number, ),
url(r'^lbo_suggestions/?$', logbook_entry_suggestions), #broken url(r'^lbo_suggestions/?$', logbook_entry_suggestions), #broken
#(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person), # url(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person),
url(r'^person/(?P<first_name>[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P<last_name>[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-&;]*)/?', views_logbooks.person, name="person"), url(r'^person/(?P<first_name>[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P<last_name>[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-&;]*)/?', views_logbooks.person, name="person"),
# url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"), # url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
# url(r'^personform/(.*)$', personForm),
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"), url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
url(r'^expeditions/?$', views_logbooks.ExpeditionListView.as_view(), name="expeditions"), url(r'^expeditions/?$', views_logbooks.ExpeditionListView.as_view(), name="expeditions"),
@ -71,7 +69,6 @@ actualurlpatterns = [
#url(r'^cavesearch', caveSearch), #url(r'^cavesearch', caveSearch),
url(r'^prospecting_guide/$', views_caves.prospecting), url(r'^prospecting_guide/$', views_caves.prospecting),
url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch), url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch),
url(r'^statistics/?$', views_statistics.stats, name="stats"), url(r'^statistics/?$', views_statistics.stats, name="stats"),
@ -88,9 +85,6 @@ actualurlpatterns = [
url(r'^accounts/', include('registration.backends.default.urls')), url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^profiles/', include('profiles.urls')), # not used ? Delete this entire app then. url(r'^profiles/', include('profiles.urls')), # not used ? Delete this entire app then.
# (r'^personform/(.*)$', personForm),
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
url(r'^survexfile/(?P<survex_file>.*?)\.svx$', views_survex.svx, name="svx"), url(r'^survexfile/(?P<survex_file>.*?)\.svx$', views_survex.svx, name="svx"),
url(r'^survexfile/(?P<survex_file>.*?)\.3d$', views_survex.threed, name="threed"), url(r'^survexfile/(?P<survex_file>.*?)\.3d$', views_survex.threed, name="threed"),
@ -111,11 +105,10 @@ actualurlpatterns = [
view_surveys.surveyscansingle, name="surveyscansingle"), view_surveys.surveyscansingle, name="surveyscansingle"),
url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"), url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"),
# url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"),
url(r'^tunneldataraw/(?P<path>.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"), url(r'^tunneldataraw/(?P<path>.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"),
url(r'^tunneldataraw/(?P<path>.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"), url(r'^tunneldataraw/(?P<path>.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"),
# url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"),
url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"), url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),
url(r'^expofiles/(?P<path>.*)$', staticviews.serve, url(r'^expofiles/(?P<path>.*)$', staticviews.serve,
@ -124,19 +117,17 @@ actualurlpatterns = [
{'document_root': settings.STATIC_ROOT, 'show_indexes': True}), {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
url(r'^site_media/(?P<path>.*)$', staticviews.serve, url(r'^site_media/(?P<path>.*)$', staticviews.serve,
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
# url(r'^troggle/media-admin/(?P<path>.*)$', staticviews.serve,
# {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}),
#url(r'^tinymce_media/(?P<path>.*)$', staticviews.serve, #url(r'^tinymce_media/(?P<path>.*)$', staticviews.serve,
# {'document_root': settings.TINY_MCE_MEDIA_ROOT, 'show_indexes': True}), # {'document_root': settings.TINY_MCE_MEDIA_ROOT, 'show_indexes': True}),
#url(r'^photos/(?P<path>.*)$', staticviews.serve, #url(r'^photos/(?P<path>.*)$', staticviews.serve,
# {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), # {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
# url(r'^gallery/(?P<path>.*)$', staticviews.serve, # url(r'^gallery/(?P<path>.*)$', staticviews.serve,
# {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), # {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
# don't know why this needs troggle/ in here. nice to get it out
url(r'^troggle/media-admin/(?P<path>.*)$', staticviews.serve,
{'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}),
url(r'^(.*)_edit$', flatviews.editflatpage, name="editflatpage"), url(r'^(.*)_edit$', flatviews.editflatpage, name="editflatpage"),
url(r'^(.*)$', flatviews.flatpage, name="flatpage"), url(r'^(.*)$', flatviews.flatpage, name="flatpage"),
] ]
#Allow prefix to all urls #Allow prefix to all urls