From d639a53f2043fe0b17d961a398090852f9deb09c Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 7 Nov 2008 00:24:20 +0100 Subject: [PATCH] [svn r8061] Wiki_markup imporved to include paragraphs wiki_to_html should be used when the field will include paragraphs wiki_to_html_short should be used when the field will not include paragraphs --- troggle/expo/templatetags/wiki_markup.py | 15 ++++++++++++++- troggle/templates/cave.html | 14 +++++++------- troggle/templates/caveindex.html | 2 +- troggle/templates/logbookentry.html | 1 - troggle/templates/person.html | 8 +++++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/troggle/expo/templatetags/wiki_markup.py b/troggle/expo/templatetags/wiki_markup.py index 763448594..e2a9d7e62 100644 --- a/troggle/expo/templatetags/wiki_markup.py +++ b/troggle/expo/templatetags/wiki_markup.py @@ -34,6 +34,17 @@ def wiki_list(line, listdepth): @register.filter() @stringfilter def wiki_to_html(value, autoescape=None): + #find paragraphs + outValue = "" + for paragraph in re.split("\n\s*?\n", value, re.DOTALL): + outValue += "

" + outValue += wiki_to_html_short(paragraph, autoescape) + outValue += "

\n" + return mark_safe(outValue) + +@register.filter() +@stringfilter +def wiki_to_html_short(value, autoescape=None): if autoescape: value = conditional_escape(value) #deescape doubly escaped characters @@ -42,9 +53,11 @@ def wiki_to_html(value, autoescape=None): value = re.sub("''''([^']+)''''", r"\1", value, re.DOTALL) value = re.sub("'''([^']+)'''", r"\1", value, re.DOTALL) value = re.sub("''([^']+)''", r"\1", value, re.DOTALL) + #make cave links + value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'\1', value, re.DOTALL) #Make lists from lines starting with lists of [stars and hashes] - listdepth = [] outValue = "" + listdepth = [] for line in value.split("\n"): t, listdepth = wiki_list(line, listdepth) outValue += t diff --git a/troggle/templates/cave.html b/troggle/templates/cave.html index a043e7f1a..e8c597e2b 100644 --- a/troggle/templates/cave.html +++ b/troggle/templates/cave.html @@ -8,20 +8,20 @@ {% if cave.kataster_number %} - {{ cave.kataster_number|wiki_to_html }} + {{ cave.kataster_number|wiki_to_html_short }} {% if cave.entrancelist %} - - {{ cave.entrancelist|wiki_to_html }} + - {{ cave.entrancelist|wiki_to_html_short }} {% endif %} {% if cave.unofficial_number %} -
({{ cave.unofficial_number|wiki_to_html }}) +
({{ cave.unofficial_number|wiki_to_html_short }}) {% endif %} {% endif %} - {{ cave.official_name|wiki_to_html }} + {{ cave.official_name|wiki_to_html_short }} - {{ cave.kataster_code|wiki_to_html }} + {{ cave.kataster_code|wiki_to_html_short }} @@ -29,9 +29,9 @@ {% if cave.entrances %}

Entrances

{% for ent in cave.entrances %} - {{ ent.entrance_letter|wiki_to_html }} + {{ ent.entrance_letter|wiki_to_html_short }} {% if ent.entrance.marking %} - Marking: {{ ent.entrance.marking_val|wiki_to_html }} + Marking: {{ ent.entrance.marking_val|wiki_to_html_short }} {% endif %}
{% endfor %} diff --git a/troggle/templates/caveindex.html b/troggle/templates/caveindex.html index a19752faf..445eddffc 100644 --- a/troggle/templates/caveindex.html +++ b/troggle/templates/caveindex.html @@ -5,6 +5,6 @@ {% block content %} {% for cave in caves %} -

{{ cave }} {{ cave.official_name|wiki_to_html }}

+

{{ cave }} {{ cave.official_name|wiki_to_html_short }}

{% endfor %} {% endblock %} \ No newline at end of file diff --git a/troggle/templates/logbookentry.html b/troggle/templates/logbookentry.html index f1a18871d..b76d9ab6a 100644 --- a/troggle/templates/logbookentry.html +++ b/troggle/templates/logbookentry.html @@ -20,7 +20,6 @@ {% endfor %} - [wiki_to_html doesn't do paragraphs. don't know where it is located]
{{logbookentry.text|wiki_to_html}}
{% endblock %} diff --git a/troggle/templates/person.html b/troggle/templates/person.html index 9d79141af..ff1fe62d1 100644 --- a/troggle/templates/person.html +++ b/troggle/templates/person.html @@ -1,10 +1,10 @@ {% extends "base.html" %} {% load wiki_markup %} -{% block title %}Person {{person.id}}{% endblock %} +{% block title %}Person {{person|wiki_to_html_short}}{% endblock %} {% block content %} -
{{person}} +
{{person|wiki_to_html_short}}
    {% for personexpedition in person.personexpedition_set.all %}
  • @@ -14,7 +14,9 @@
      {% for persontrip in personexpedition.persontrip_set.all %} -
    • {{persontrip.date}} ({{persontrip.logbookentry.place}}) - {{persontrip.logbookentry.title}}
    • +
    • {{persontrip.date}} + ({{persontrip.logbookentry.place|wiki_to_html_short}}) - + {{persontrip.logbookentry.title|wiki_to_html_short}}
    • {% endfor %}