comments on urls resolution re apache & bugfix

This commit is contained in:
Philip Sargent 2021-03-21 01:37:52 +00:00
parent b4b343b578
commit a0c3ef8ea1
3 changed files with 48 additions and 29 deletions

View File

@ -38,6 +38,8 @@ ADMINS = (
) )
MANAGERS = ADMINS MANAGERS = ADMINS
#LOGIN_URL = '/accounts/login/' # this is the default value so does not need to be set
# Local time zone for this installation. Choices can be found here: # Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems. # although not all choices may be available on all operating systems.
@ -62,6 +64,7 @@ FIX_PERMISSIONS = []
# top-level survex file basename (without .svx) # top-level survex file basename (without .svx)
SURVEX_TOPNAME = "1623" SURVEX_TOPNAME = "1623"
MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200
DEFAULT_LOGBOOK_PARSER = "Parseloghtmltxt" DEFAULT_LOGBOOK_PARSER = "Parseloghtmltxt"
DEFAULT_LOGBOOK_FILE = "logbook.html" DEFAULT_LOGBOOK_FILE = "logbook.html"
# All years since 2010 use the default value for Logbook parser # All years since 2010 use the default value for Logbook parser
@ -117,11 +120,11 @@ INSTALLED_APPS = (
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.admindocs', 'django.contrib.admindocs',
# 'django.contrib.staticfiles', # apparently not working. Using workarounds with flatpages # 'django.contrib.staticfiles', # Using workarounds with flatpages
'registration', # only for expo user. REPLACE with another non-admin, contrib.auth user ? 'registration', # only for expo user. REPLACE using django.contrib.auth
'troggle.profiles', # Probably don't need this at all
'troggle.core', 'troggle.core',
'troggle.flatpages', # NOT django.contrib.flatpages.models.FlatPage Merge in with troggle ? 'troggle.flatpages', # Written by Martin Green 2011. This is NOT django.contrib.flatpages which stores HTML in the database
# 'troggle.profiles', # Commented out, but keep until user/login system fully bedded down.
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
@ -146,7 +149,7 @@ AUTH_PROFILE_MODULE = 'core.person'
QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]"
# Re-enable TinyMCE when Dj upgraded to v3. Also templates/editflatpage.html
# TINYMCE_DEFAULT_CONFIG = { # TINYMCE_DEFAULT_CONFIG = {
# 'plugins': "table,spellchecker,paste,searchreplace", # 'plugins': "table,spellchecker,paste,searchreplace",
# 'theme': "advanced", # 'theme': "advanced",
@ -154,8 +157,6 @@ QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]"
# TINYMCE_SPELLCHECKER = False # TINYMCE_SPELLCHECKER = False
# TINYMCE_COMPRESSOR = True # TINYMCE_COMPRESSOR = True
MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200
TEST_RUNNER = 'django.test.runner.DiscoverRunner' TEST_RUNNER = 'django.test.runner.DiscoverRunner'
from localsettings import * from localsettings import *

View File

@ -4,9 +4,9 @@
{% block title %}{{ title }}{% endblock %} {% block title %}{{ title }}{% endblock %}
{% block head %} {% block head %}
<script src="{{ settings.MEDIA_URL }}js/base.js" type="text/javascript"></script> <script type="text/javascript" src="{{settings.MEDIA_URL }}js/base.js"></script>
<script type="text/javascript" src="{{settings.JSLIB_URL}}jquery-form/jquery.form.min.js"></script> <script type="text/javascript" src="{{settings.JSLIB_URL}}jquery-form/jquery.form.min.js"></script> <!-- INVALID-->
<script type="text/javascript" src="{{settings.JSLIB_URL}}codemirror/codemirror.min.js"></script> <script type="text/javascript" src="{{settings.JSLIB_URL}}codemirror/codemirror.min.js"></script> <!-- INVALID-->
<script type="text/javascript"> <script type="text/javascript">
var codeeditor; var codeeditor;
@ -15,8 +15,8 @@ $(document).ready(function()
codeeditor = CodeMirror.fromTextArea("id_code", codeeditor = CodeMirror.fromTextArea("id_code",
{ {
parserfile: ["parsesurvex.js"], parserfile: ["parsesurvex.js"],
stylesheet: "{{settings.MEDIA_URL}}CodeMirror-0.62/css/survexcolors.css", stylesheet: "{{settings.MEDIA_URL}}CodeMirror-0.62/css/survexcolors.css", # INVALID
path: "{{settings.MEDIA_URL}}CodeMirror-0.62/js/", path: "{{settings.MEDIA_URL}}CodeMirror-0.62/js/", # INVALID
textWrapping: false, textWrapping: false,
lineNumbers: false, lineNumbers: false,
indentUnit: 4, indentUnit: 4,

50
urls.py
View File

@ -1,5 +1,6 @@
from django.conf import settings from django.conf import settings
from django.conf.urls import url, include from django.conf.urls import url, include
from django.views.generic.base import RedirectView
from django.views.generic.edit import UpdateView from django.views.generic.edit import UpdateView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.contrib import admin from django.contrib import admin
@ -11,10 +12,7 @@ from troggle.core.views_caves import ent, prospecting_image
from troggle.core.views_statistics import pathsreport, stats from troggle.core.views_statistics import pathsreport, stats
from flatpages import views as flatviews from flatpages import views as flatviews
"""This sets the actualurlpatterns[] and urlpatterns[] lists which django uses """This sets the actualurlpatterns[] and urlpatterns[] lists which django uses
to resolve urls - in both directions as these are declarative. It runs to resolve urls - in both directions as these are declarative.
django autodiscover() first:
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#discovery-of-admin-files
which may no longer be necessary in Django 1.11.29
HOW THIS WORKS HOW THIS WORKS
This is a "url dispatcher" - something needed by every web framework. This is a "url dispatcher" - something needed by every web framework.
@ -26,7 +24,7 @@ which is vital to writing code for the webapp. So the URL dispatch is declarativ
The API urls return TSV or JSON and are new in July 2020. The API urls return TSV or JSON and are new in July 2020.
""" """
#admin.autodiscover()
# Many of these patterns do not work because troggle spent many years broken and we have # Many of these patterns do not work because troggle spent many years broken and we have
# not yet restored all the functions. Some may have never been fully implemented in # not yet restored all the functions. Some may have never been fully implemented in
@ -93,7 +91,7 @@ actualurlpatterns = [
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/). url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/).
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'^accounts/', include('registration.backends.default.urls')), #LOGIN_URL = '/accounts/login/' # default url(r'^accounts/', include('registration.backends.default.urls')), #LOGIN_URL = '/accounts/login/' # default
# 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.
# url(r'^map/', .........), # Intercepted by Apache. Yields OpenStreetMap. Redirects to expoweb/map # url(r'^map/', .........), # Intercepted by Apache. Yields OpenStreetMap. Redirects to expoweb/map
@ -104,21 +102,21 @@ actualurlpatterns = [
url(r'^survexfile/(?P<survex_file>.*?)\.log$', views_survex.svxraw), url(r'^survexfile/(?P<survex_file>.*?)\.log$', views_survex.svxraw),
url(r'^survexfile/(?P<survex_file>.*?)\.err$', views_survex.err), url(r'^survexfile/(?P<survex_file>.*?)\.err$', views_survex.err),
url(r'^survexfile/caves/$', views_survex.survexcaveslist, name="survexcaveslist"), url(r'^survexfile/caves', views_survex.survexcaveslist, name="survexcaveslist"),
url(r'^survexfile/(?P<survex_cave>.*)$', views_survex.survexcavesingle, name="survexcavessingle"), url(r'^survexfile/(?P<survex_cave>.*)$', views_survex.survexcavesingle, name="survexcavessingle"),
url(r'^survexfileraw/(?P<survex_file>.*?)\.svx$', views_survex.svxraw, name="svxraw"), url(r'^survexfileraw/(?P<survex_file>.*?)\.svx$', views_survex.svxraw, name="svxraw"),
# url(r'^survey_files/download/(?P<path>.*)$', view_surveys.download), # needs rewriting # url(r'^survey_files/download/(?P<path>.*)$', view_surveys.download), # needs rewriting
url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"), url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"),
url(r'^survey_scans/(?P<path>[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"), url(r'^survey_scans/(?P<path>[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"),
url(r'^survey_scans/(?P<path>[^/]+)/(?P<file>[^/]+)$', url(r'^survey_scans/(?P<path>[^/]+)/(?P<file>[^/]+)$',
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'^tunneldataraw/(?P<path>.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"), url(r'^tunneldataraw/(?P<path>.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"),
# url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"), # url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"),
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'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"), url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),
@ -126,7 +124,7 @@ actualurlpatterns = [
url(r'^expofiles/(?P<path>.*)$', flatviews.expofiles_redirect, name="expofiles_redirect"), # to expo.survex.com/expofiles url(r'^expofiles/(?P<path>.*)$', flatviews.expofiles_redirect, name="expofiles_redirect"), # to expo.survex.com/expofiles
url(r'^expofiles/(?P<filepath>.*)$',view_surveys.expofilessingle, name="single"), # local copy of EXPOFILES url(r'^expofiles/(?P<filepath>.*)$',view_surveys.expofilessingle, name="single"), # local copy of EXPOFILES
# url(r'^javascript/(?P<filepath>.*)$', view_surveys.cssfilessingle, name="single"), # JSLIB_URL - unused # url(r'^javascript/(?P<filepath>.*)$', view_surveys.cssfilessingle, name="single"), # JSLIB_URL - Apache: Alias /javascript /usr/share/javascript
# static views not working, removed as a plugin. Use apache instead to serve these: # static views not working, removed as a plugin. Use apache instead to serve these:
# url(r'^photos/(?P<path>.*)$', staticviews.serve, # url(r'^photos/(?P<path>.*)$', staticviews.serve,
@ -148,3 +146,23 @@ actualurlpatterns = [
urlpatterns = [ urlpatterns = [
url('^%s' % settings.DIR_ROOT, include(actualurlpatterns)) url('^%s' % settings.DIR_ROOT, include(actualurlpatterns))
] ]
# When apache is running these prempt Django so Django never sees them.
# NEW apache configurations suggested as of 20 March 2021:
# Alias /site-media/ /home/expo/troggle/media/
# Alias /robots.txt /home/expo/troggle/media/robots.txt
# Alias /favicon.ico /home/expo/troggle/media/favicon.ico # comes from /expoweb/* when running runserver
# Alias /javascript /home/expo/troggle/media/javascript
# Copy of old standard apache configurations:
# Alias /expofiles /home/expo/expofiles
# Alias /photos /home/expo/webphotos
# Alias /map /home/expo/expoweb/map
# Alias /javascript /usr/share/javascript # to be changed
# Alias /robots.txt /home/expo/static/robots.txt # to be changed
# Alias /favicon.ico /home/expo/static/favicon.ico # to be changed
# Alias /static/ /home/expo/static/
# ScriptAlias /repositories /home/expo/config/apache/services/hgweb/hgweb.cgi
# ScriptAlias /boe /home/expo/boe/boc/boc.pl
# ScriptAlias /boe-lastyear /home/expo/boe/boc-previous/boc.pl