From b80c38756fe01c794b5570ae6b088b3680e98cd8 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Thu, 7 Jan 2016 18:14:10 +0000 Subject: [PATCH] Add basic markdown support site wide --- RIGS/templates/RIGS/event_detail.html | 5 +++-- RIGS/templates/RIGS/event_table.html | 6 ++++-- RIGS/templates/RIGS/item_row.html | 3 ++- RIGS/templates/RIGS/organisation_detail.html | 5 +++-- RIGS/templates/RIGS/person_detail.html | 5 +++-- RIGS/templates/RIGS/venue_detail.html | 5 +++-- RIGS/templatetags/markdown_tags.py | 11 +++++++++++ db.sqlite3 | Bin 82944 -> 82944 bytes requirements.txt | 1 + 9 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 RIGS/templatetags/markdown_tags.py diff --git a/RIGS/templates/RIGS/event_detail.html b/RIGS/templates/RIGS/event_detail.html index 358eaf10..e819a117 100644 --- a/RIGS/templates/RIGS/event_detail.html +++ b/RIGS/templates/RIGS/event_detail.html @@ -1,4 +1,5 @@ {% extends request.is_ajax|yesno:"base_ajax.html,base.html" %} +{% load markdown_tags %} {% block title %}{% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %} | {{object.name}}{% endblock %} {% block content %} @@ -141,7 +142,7 @@
 
Event Description
-
{{ event.description|linebreaksbr }}
+
{{ event.description|markdown }}
 
@@ -205,7 +206,7 @@

Notes

- {{ event.notes|linebreaksbr }} + {{ event.notes|markdown }}
{% include 'RIGS/item_table.html' %}
diff --git a/RIGS/templates/RIGS/event_table.html b/RIGS/templates/RIGS/event_table.html index 1868f2dd..a22ea449 100644 --- a/RIGS/templates/RIGS/event_table.html +++ b/RIGS/templates/RIGS/event_table.html @@ -1,3 +1,5 @@ +{% load markdown_tags %} +
@@ -51,7 +53,7 @@ {% endif %} {% if not event.cancelled and event.description %}
- {{ event.description|linebreaksbr }} + {{ event.description|markdown }}
{% endif %} @@ -99,4 +101,4 @@ {% endfor %}
-
\ No newline at end of file + diff --git a/RIGS/templates/RIGS/item_row.html b/RIGS/templates/RIGS/item_row.html index 656d9812..c30ca026 100644 --- a/RIGS/templates/RIGS/item_row.html +++ b/RIGS/templates/RIGS/item_row.html @@ -1,9 +1,10 @@ +{% load markdown_tags %} {{ item.name }}
- {{item.description|linebreaksbr}} + {{item.description|markdown}}
£ {{item.cost|floatformat:2}} diff --git a/RIGS/templates/RIGS/organisation_detail.html b/RIGS/templates/RIGS/organisation_detail.html index 7743086c..451e9331 100644 --- a/RIGS/templates/RIGS/organisation_detail.html +++ b/RIGS/templates/RIGS/organisation_detail.html @@ -1,5 +1,6 @@ {% extends request.is_ajax|yesno:"base_ajax.html,base.html" %} {% load widget_tweaks %} +{% load markdown_tags %} {% block title %}Organisation | {{ object.name }}{% endblock %} @@ -35,7 +36,7 @@
{{ object.address|linebreaksbr }}
Notes
-
{{ object.notes|linebreaksbr }}
+
{{ object.notes|markdown }}
Union Account
{{ object.union_account|yesno|capfirst }}
@@ -108,4 +109,4 @@ {% endblock %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/RIGS/templates/RIGS/person_detail.html b/RIGS/templates/RIGS/person_detail.html index 10c995ae..bb11e742 100644 --- a/RIGS/templates/RIGS/person_detail.html +++ b/RIGS/templates/RIGS/person_detail.html @@ -1,5 +1,6 @@ {% extends request.is_ajax|yesno:"base_ajax.html,base.html" %} {% load widget_tweaks %} +{% load markdown_tags %} {% block title %}Person | {{ object.name }}{% endblock %} @@ -35,7 +36,7 @@
{{ object.address|linebreaksbr }}
Notes
-
{{ object.notes|linebreaksbr }}
+
{{ object.notes|markdown }}
@@ -105,4 +106,4 @@ {% endblock %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/RIGS/templates/RIGS/venue_detail.html b/RIGS/templates/RIGS/venue_detail.html index ede9d4ec..382e4c8d 100644 --- a/RIGS/templates/RIGS/venue_detail.html +++ b/RIGS/templates/RIGS/venue_detail.html @@ -1,5 +1,6 @@ {% extends request.is_ajax|yesno:"base_ajax.html,base.html" %} {% load widget_tweaks %} +{% load markdown_tags %} {% block title %}Venue | {{ object.name }}{% endblock %} @@ -35,7 +36,7 @@
{{ object.address|linebreaksbr }}
Notes
-
{{ object.notes|linebreaksbr }}
+
{{ object.notes|markdown }}
Three Phase Available
{{ object.three_phase_available|yesno|capfirst }}
@@ -95,4 +96,4 @@ {% endblock %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/RIGS/templatetags/markdown_tags.py b/RIGS/templatetags/markdown_tags.py new file mode 100644 index 00000000..d40eb895 --- /dev/null +++ b/RIGS/templatetags/markdown_tags.py @@ -0,0 +1,11 @@ +from django import template +from django.utils.safestring import mark_safe +import markdown + +__author__ = 'ghost' + +register = template.Library() + +@register.filter(name="markdown") +def markdown_filter(text): + return mark_safe(markdown.markdown(text)) diff --git a/db.sqlite3 b/db.sqlite3 index d0e8fed8d67a99e4d84aaca79726634d5103571e..5142bf96fab1d44b5c169ee35bd8c201bd6397bf 100644 GIT binary patch delta 1937 zcma)6O>EOv9JljQsM7{kX#+MsWJ0D+8nm|a;ieOZ(9)2sCTkZ$oPmO4zr;@bRez*O z7z#`rD(%A5op#_bO}p&E$^_E1!^UoCJM02GZ~^Tw?L$bD5C=HyIZa3yjLov;_x_*1 z|L_0a|NPp>`L&TtyK(8GJ#)D9<(W^nhOS`Se78oxPoN13AO$`IpMdYcG}s3e-!0#L z;0M25o!GVETfY@xCJ75Rpk*tDUP3FyTYxLr_7HfTSWc(jEt!^4QB=4-J$42s)-R2b zehkAV*1sBy?|AtQFg@hn3$roqSGVAxih(N1avF3l?7&~bE=(qgU@%A!N#wrMEZ3z9 zQ?g}&iN(VVg`TidIFVSXR->+Ltc2yaGe9}#=v6)^*-2&umOM(8*BbOeR<%szrZ$67(mJ)+lij-{}Vrn9QOPBk)O)=jei`; zFJs^`Lh>;vpTS?n_KLyLQDQ%~AEiQ1u=nHU$)gRZJ2_dgN%RUjiCU;Tcnqi_|2;q#=pfo7bAE8+fKZ)cK85J&^6o8 z-#Z(sC{UH`&@6d2WC|?})lkx)BO4MD>8`3CBtxR1s!((c3yDG@Pas3F4yBT!m&&by zou-I`jp}y=3;TA;I;DHxpm$z;s7u3{dmZ#N zo2VQ`^HB9T(}nIX)ITW5t`m~1R!LSY&#WS-wue$T9O!}U@`_H7I~2o2GocH&7t=%V zbe1wASSk(M7*P+Vd1d5!&;1=?RzTP-@MPpz5XeX3SLg_TABv2XFaCxQio6 zCX$dTQEXS~Ri|QB8cl^pUqo=LDl3{bldsjA#ay+`G3hp6OSX>BbM0)7Z*gs&%I210 z#af!-nPNSgD%Ohg=@_z!@@ z#!<`Kl9E+2bwOKji_DD6GYMBZmN9uH)&;Pr_3f71i*>qDOy%t*EwfM)n7mt@OWV&N zJ?RBZH`6-xWRx=WV3f{KbR-dZVHX}@;1QzvK0rg!4{+k&dge_q9NfmhZDjo;h)v>K zuw;h yuf}VzEXG|U(r60oW@UFVa2I@!V0{f{pGyN9i^UU>eISYV(LPI(@AHHBuD=0ilpA6I delta 282 zcmWlPze@sP7=XX;-uLtFysIk=6l@SPN(hXQrf7+1ZDFD+r~Dqgf3e=7MOV9<2w3yuMt)_lJF+U2t&r$E=6B{0ngIeY>-Ej@MH?D z8>)ow0!i3xpXJ`F_XD c@K=!CdQ6TAmK;6cV|Sjf1UmvdVuO$4|3lYWHUIzs diff --git a/requirements.txt b/requirements.txt index 1f32e3dc..00d423e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,7 @@ django-widget-tweaks==1.3 gunicorn==19.3.0 icalendar==3.9.0 lxml==3.4.4 +Markdown==2.6.5 Pillow==2.8.1 psycopg2==2.6 Pygments==2.0.2