cleaned & removed defunct wiki_to_html

This commit is contained in:
Philip Sargent 2021-04-30 22:44:03 +01:00
parent be0148d146
commit b545f8ed40
13 changed files with 53 additions and 61 deletions

@ -5,14 +5,18 @@ from django.utils.safestring import mark_safe
import re import re
register = template.Library() register = template.Library()
'''Now entirely defunct.
Simple use in svxfile.html produced a textarea, double-spacing and no colouring.
so this would take some work, and we are better off not using it but getting
syntax colouring to work with CodeMirror instead. PPhilip S. 28 March 2021.
The only template which used it, survexblock.html, has been removed as unnecessary.
'''
# seems to add extra lines between the commented lines, which isn't so great. # seems to add extra lines between the commented lines, which isn't so great.
# Simple use in svxfile.html produces a textarea, double-spacing and no colouring.
# so this is going to take some work, and we are better off not using it but getting
# syntax colouring to work with CodeMirror instead. PPhilip S. 28 March 2021.
# The only template which used it, survexblock.html, has been removed as unnecessary.
regexes = [] regexes = []
regexes.append((re.compile(r"(;.*)$", re.IGNORECASE|re.MULTILINE), regexes.append((re.compile(r"(;.*)$", re.IGNORECASE|re.MULTILINE),

@ -6,16 +6,11 @@ from django.conf import settings
from troggle.core.models.caves import LogbookEntry, QM, Cave from troggle.core.models.caves import LogbookEntry, QM, Cave
import re, urllib.parse import re, urllib.parse
'''Several templates are still (2021) using these filters extensively to process data '''Originally for the wiki format entries, later re-used simply to clean up HTML escape chars.
extracted from the database, and to restructure values into valid URLs to go elsewhere in the Now entirely defunct.
system, even where these are not actually 'wiki'. See the regexes at the end of this file.
''' '''
todo = '''The data in the database and all input files todo = '''Checked. Not used anywhere anymore. Replaced by standard Django template filters.
needs to be checked that there is no wiki-format content before all the functions in this
file are deleted, and the filter functions of these regexes and functions, particularly
wiki_to_html() which is used dozens of times in the templates, needs to be explored in
practice before being renamed more appropriately.
''' '''
register = template.Library() register = template.Library()
@ -75,6 +70,10 @@ def wiki_to_html(value, autoescape=None):
@stringfilter @stringfilter
def wiki_to_html_short(value, autoescape=None): def wiki_to_html_short(value, autoescape=None):
""" """
I suspect this is only used for HTML escapes. And we should be using the standard Django
filter |safe https://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
This is the tag which turns wiki syntax into html. It is intended for short pieces of wiki. This is the tag which turns wiki syntax into html. It is intended for short pieces of wiki.
Hence it is not split the wiki into paragraphs using where it finds double line feeds. Hence it is not split the wiki into paragraphs using where it finds double line feeds.

@ -46,7 +46,6 @@ def todos(request, module):
from troggle.parsers.survex import todo as parserssurvex from troggle.parsers.survex import todo as parserssurvex
from troggle.core.models.caves import todo as modelcaves from troggle.core.models.caves import todo as modelcaves
from troggle.core.forms import todo as forms from troggle.core.forms import todo as forms
from troggle.core.templatetags.wiki_markup import todo as wiki
tododict = {'views/other': todo, tododict = {'views/other': todo,
'tests': tests, 'tests': tests,
'views/logbooks': viewlogbooks, 'views/logbooks': viewlogbooks,
@ -54,8 +53,7 @@ def todos(request, module):
'parsers/logbooks': parserslogbooks, 'parsers/logbooks': parserslogbooks,
'parsers/survex': parserssurvex, 'parsers/survex': parserssurvex,
'core/models/caves': modelcaves, 'core/models/caves': modelcaves,
'core/forms': forms, 'core/forms': forms}
'core/templatetags/wiki_markup': wiki}
return render(request,'core/todos.html', {'tododict': tododict}) return render(request,'core/todos.html', {'tododict': tododict})
def troggle404(request): # cannot get this to work. Handler404 in urls.py not right syntax def troggle404(request): # cannot get this to work. Handler404 in urls.py not right syntax

@ -36,7 +36,7 @@
<a href="{% url "dwgdata" %}">Drawings</a> | <a href="{% url "dwgdata" %}">Drawings</a> |
<a href="/1623/290/290.html">290 (FGH)</a> | <a href="/1623/290/290.html">290 (FGH)</a> |
<a href="/1623/291/291">291 (GSH)</a> | <a href="/1623/291/291">291 (GSH)</a> |
<a href="/1623/204/204.html">204 (Steinbrucken)</a> | <a href="/1623/204/204.html">204 (Steinbr&uuml;cken)</a> |
<br> <br>
<a href="{% url "dataissues" %}">Data Issues</a> | <a href="{% url "dataissues" %}">Data Issues</a> |

@ -1,79 +1,77 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %} {% block title %}{{ cave.official_name|safe }} - {{ entrance_letter|safe }}{% endblock %}
{% block title %}{{ cave.official_name|wiki_to_html }} - {{ entrance_letter|wiki_to_html }}{% endblock %}
{% block content %} {% block content %}
<table id="cavepage"> <table id="cavepage">
<tr> <tr>
<th id="kat_no"> <th id="kat_no">
{% if cave.kataster_number %} {% if cave.kataster_number %}
{{ cave.kataster_number|wiki_to_html }}{{ letter|wiki_to_html }} {{ cave.kataster_number|safe }}{{ letter|safe }}
{% if cave.unofficial_number %} {% if cave.unofficial_number %}
<br />({{ cave.unofficial_number|wiki_to_html }}) <br />({{ cave.unofficial_number|safe }})
{% endif %} {% endif %}
{% endif %} {% endif %}
</th> </th>
<th id="name"> <th id="name">
{% if entrance.name %} {% if entrance.name %}
{{ entrance.name|wiki_to_html }} {{ entrance.name|safe }}
{% else %} {% else %}
Unnamed Unnamed
{% endif %} - {{ cave.official_name|wiki_to_html }} {% endif %} - {{ cave.official_name|safe }}
</th> </th>
<th id="status"> <th id="status">
{{ cave.kataster_code|wiki_to_html }} {{ cave.kataster_code|safe }}
</th> </th>
</tr> </tr>
</table> </table>
{% if entrance.entrance_description %} {% if entrance.entrance_description %}
<h2>Entrance Description</h2> <h2>Entrance Description</h2>
{{ entrance.entrance_description|wiki_to_html }} {{ entrance.entrance_description|safe }}
{% endif %} {% endif %}
{% if entrance.explorers %} {% if entrance.explorers %}
<h2>Explorers</h2> <h2>Explorers</h2>
{{ entrance.explorers|wiki_to_html }} {{ entrance.explorers|safe }}
{% endif %} {% endif %}
{% if entrance.map_description %} {% if entrance.map_description %}
<h2>Map</h2> <h2>Map</h2>
{{ entrance.map_description|wiki_to_html }} {{ entrance.map_description|safe }}
{% endif %} {% endif %}
{% if entrance.explorers %} {% if entrance.explorers %}
<h2>Entrance Description</h2> <h2>Entrance Description</h2>
{{ entrance.entrance_description|wiki_to_html }} {{ entrance.entrance_description|safe }}
{% endif %} {% endif %}
{% if entrance.location_description %} {% if entrance.location_description %}
<h2>Location Description</h2> <h2>Location Description</h2>
{{ entrance.location_description|wiki_to_html }} {{ entrance.location_description|safe }}
{% endif %} {% endif %}
{% if entrance.approach %} {% if entrance.approach %}
<h2>Approach</h2> <h2>Approach</h2>
{{ entrance.approach|wiki_to_html }} {{ entrance.approach|safe }}
{% endif %} {% endif %}
{% if entrance.underground_description %} {% if entrance.underground_description %}
<h2>Underground Description</h2> <h2>Underground Description</h2>
{{ entrance.underground_description|wiki_to_html }} {{ entrance.underground_description|safe }}
{% endif %} {% endif %}
{% if entrance.photo %} {% if entrance.photo %}
<h2>Photo</h2> <h2>Photo</h2>
{{ entrance.photo|wiki_to_html }} {{ entrance.photo|safe }}
{% endif %} {% endif %}
{% if entrance.marking %} {% if entrance.marking %}
<h2>Marking - {{ entrance.marking_val|wiki_to_html }}</h2> <h2>Marking - {{ entrance.marking_val|safe }}</h2>
{% if entrance.marking_comment %} {% if entrance.marking_comment %}
{{ entrance.marking_comment|wiki_to_html }} {{ entrance.marking_comment|safe }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if entrance.findability %} {% if entrance.findability %}
<h2>Findability - {{ entrance.findability_val|wiki_to_html }}</h2> <h2>Findability - {{ entrance.findability_val|safe }}</h2>
{% if entrance.findability_description %} {% if entrance.findability_description %}
{{ entrance.findability_description|wiki_to_html }} {{ entrance.findability_description|safe }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if entrance.bearings %} {% if entrance.bearings %}
<h2>Bearings</h2> <h2>Bearings</h2>
{{ entrance.bearings|wiki_to_html }} {{ entrance.bearings|safe }}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

@ -1,7 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %}
{% block title %}Expedition {{expedition.name}}{% endblock %} {% block title %}Expedition {{expedition.name}}{% endblock %}
{% block editLink %}<a href={{expedition.get_admin_url}}>Edit expedition {{expedition|wiki_to_html_short}}</a>{% endblock %} {% block editLink %}<a href={{expedition.get_admin_url}}>Edit expedition {{expedition}}</a>{% endblock %}
{% block related %} {% block related %}
{% endblock %} {% endblock %}

@ -1,9 +1,9 @@
{% extends "base.html" %} {% extends "base.html" %}
<!-- logbookentry.html - this text visible because this template has been included --> <!-- logbookentry.html - this text visible because this template has been included -->
{% load wiki_markup %}
{% block title %}Logbook {{logbookentry.id}}{% endblock %} {% block title %}Logbook {{logbookentry.id}}{% endblock %}
{% block editLink %}<a href={{logbookentry.get_admin_url}}/>Edit logbook entry {{logbookentry|wiki_to_html_short}}</a>{% endblock %}
{% block editLink %}<a href={{logbookentry.get_admin_url}}/>Edit logbook entry {{logbookentry|safe}}</a>{% endblock %}
{% block content %} {% block content %}
{% block related %}{% endblock %} {% block related %}{% endblock %}

@ -1,5 +1,4 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %}
{% block title %}Person Index{% endblock %} {% block title %}Person Index{% endblock %}
{% block content %} {% block content %}
@ -9,7 +8,7 @@
<tr><th>Person</th><th>First</th><th>Last</th><th>Recency</th></tr> <tr><th>Person</th><th>First</th><th>Last</th><th>Recency</th></tr>
{% for person in notablepersons|dictsortreversed:"notability" %} {% for person in notablepersons|dictsortreversed:"notability" %}
<tr> <tr>
<td><a href="{{ person.get_absolute_url }}">{{person|wiki_to_html_short}}</a></td> <td><a href="{{ person.get_absolute_url }}">{{person|safe}}</a></td>
<td><a href="{{ person.first.get_absolute_url }}">{{ person.first.expedition.year }}</a></td> <td><a href="{{ person.first.get_absolute_url }}">{{ person.first.expedition.year }}</a></td>
<td><a href="{{ person.last.get_absolute_url }}">{{ person.last.expedition.year }}</a></td> <td><a href="{{ person.last.get_absolute_url }}">{{ person.last.expedition.year }}</a></td>
<td style="text-align:right">{{person.notability|floatformat:2}}</td> <td style="text-align:right">{{person.notability|floatformat:2}}</td>
@ -29,7 +28,7 @@
<tr><th>Person</th><th>First</th><th>Last</th><th>Surveyed length</th></tr> <tr><th>Person</th><th>First</th><th>Last</th><th>Surveyed length</th></tr>
{% for person in persons %} {% for person in persons %}
<tr> <tr>
<td><a href="{{ person.get_absolute_url }}">{{person|wiki_to_html_short}}</a></td> <td><a href="{{ person.get_absolute_url }}">{{person|safe}}</a></td>
<td><a href="{{ person.first.get_absolute_url }}">{{person.first.expedition.year}}</a></td> <td><a href="{{ person.first.get_absolute_url }}">{{person.first.expedition.year}}</a></td>
<td><a href="{{ person.last.get_absolute_url }}">{{person.last.expedition.year}}</a></td> <td><a href="{{ person.last.get_absolute_url }}">{{person.last.expedition.year}}</a></td>
<td style="text-align:right">{{person.surveyedleglength|stringformat:".0f"}} m </td> <td style="text-align:right">{{person.surveyedleglength|stringformat:".0f"}} m </td>

@ -1,11 +1,10 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %} {% block title %}Person {{person}}{% endblock %}
{% block title %}Person {{person|wiki_to_html_short}}{% endblock %}
{% block editLink %}| <a href={{person.get_admin_url}}>Edit person {{person|wiki_to_html_short}}</a>{% endblock %} {% block editLink %}| <a href={{person.get_admin_url}}>Edit person {{person}}</a>{% endblock %}
{% block contentheader %} {% block contentheader %}
<h2> {{person|wiki_to_html_short}} </h2> <h2> {{person|safe}} </h2>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -19,7 +18,7 @@
{% endif %} {% endif %}
<br class="clearfloat" /> <br class="clearfloat" />
<h3>{{person|wiki_to_html_short}} has been on expo in the following years:</h3> <h3>{{person|safe}} has been on expo in the following years:</h3>
<p> <p>
<ul> <ul>
{% for personexpedition in person.personexpedition_set.all %} {% for personexpedition in person.personexpedition_set.all %}

@ -1,6 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %} {% block title %}Person {{personexpedition.person}} for {{personexpedition.expedition}}{% endblock %}
{% block title %}Person {{personexpedition.person|wiki_to_html_short}} for {{personexpedition.expedition}}{% endblock %}
<!-- I am removing 'role' as a thing that troggle cares about. <!-- I am removing 'role' as a thing that troggle cares about.
This will remove the Class Role (but keep PersonRole) This will remove the Class Role (but keep PersonRole)
and 1 foreign key role and 1 foreign key role

@ -1,9 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %}
{% load link %} {% load link %}
{% block title %} QM: {{qm|wiki_to_html_short}} {% endblock %} {% block title %} QM: {{qm|safe}} {% endblock %}
{% block editLink %}| <a href={{qm.get_admin_url}}>Edit QM {{qm|wiki_to_html_short}}</a>{% endblock %} {% block editLink %}| <a href={{qm.get_admin_url}}>Edit QM {{qm|safe}}</a>{% endblock %}
@ -11,7 +10,7 @@
<table id="cavepage"> <table id="cavepage">
<tr> <tr>
<th id="kat_no"><a href="{{qm.get_previous_by_id.get_absolute_url}}">Previous</a></th> <th id="kat_no"><a href="{{qm.get_previous_by_id.get_absolute_url}}">Previous</a></th>
<th id="name">{{qm|wiki_to_html_short}}</th> <th id="name">{{qm|safe}}</th>
<th id="status"><a href="{{qm.get_next_by_id.get_absolute_url}}">Next</a></th> <th id="status"><a href="{{qm.get_next_by_id.get_absolute_url}}">Next</a></th>
</tr> </tr>
</table> </table>

@ -1,7 +1,6 @@
<!-- svxcaveseveral.html - this text visible because this template has been included --> <!-- svxcaveseveral.html - this text visible because this template has been included -->
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}List of survex files{% endblock %} {% block title %}List of survex files{% endblock %}
{% load wiki_markup %}
{% block content %} {% block content %}
<!-- the only thing passed into this template is a list of object identifiers for caves. <!-- the only thing passed into this template is a list of object identifiers for caves.
All the processing to extract the survex subdriectories and survex files is done in this template --> All the processing to extract the survex subdriectories and survex files is done in this template -->
@ -45,9 +44,9 @@
{% for survexfile in survexdirectory.survexfile_set.all %} {% for survexfile in survexdirectory.survexfile_set.all %}
<tr> <tr>
{% if survexfile.exists %} {% if survexfile.exists %}
<td rowspan="{{survexfile.survexblock_set.all|length|plusone}}"> <td rowspan="{{survexfile.survexblock_set.all|length|add:"1"}}">
{% else %} {% else %}
<td class="survexnewfile" rowspan="{{survexfile.survexblock_set.all|length|plusone}}"> <td class="survexnewfile" rowspan="{{survexfile.survexblock_set.all|length|add:"1"}}">
{% endif %} {% endif %}
{% if survexfile == survexdirectory.primarysurvexfile %} {% if survexfile == survexdirectory.primarysurvexfile %}

@ -1,7 +1,6 @@
<!-- svxcavesingle.html - this text visible because this template has been included --> <!-- svxcavesingle.html - this text visible because this template has been included -->
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}List of survex files{% endblock %} {% block title %}List of survex files{% endblock %}
{% load wiki_markup %}
{% block content %} {% block content %}
{% autoescape off %} {% autoescape off %}
@ -45,9 +44,9 @@ to go to a form to correct the online data.
{% for survexfile in survexdirectory.survexfile_set.all %} {% for survexfile in survexdirectory.survexfile_set.all %}
<tr> <tr>
{% if survexfile.exists %} {% if survexfile.exists %}
<td rowspan="{{survexfile.survexblock_set.all|length|plusone}}"> <td rowspan="{{survexfile.survexblock_set.all|length|add:"1"}}">
{% else %} {% else %}
<td class="survexnewfile" rowspan="{{survexfile.survexblock_set.all|length|plusone}}"> <td class="survexnewfile" rowspan="{{survexfile.survexblock_set.all|length|add:"1"}}">
{% endif %} {% endif %}
{% if survexfile == survexdirectory.primarysurvexfile %} {% if survexfile == survexdirectory.primarysurvexfile %}