use markdown all the way

This commit is contained in:
j 2025-01-30 17:28:29 +05:30
parent ba1f4ec835
commit 3656a6f34c
8 changed files with 44 additions and 10 deletions

View File

@ -144,6 +144,7 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MARKDOWNX_MEDIA_PATH = 'images/markdown' MARKDOWNX_MEDIA_PATH = 'images/markdown'
MARKDOWNX_EDITOR_RESIZABLE = True MARKDOWNX_EDITOR_RESIZABLE = True
MARKDOWNX_MARKDOWNIFY_FUNCTION = 'content.utils.markdownify'
MEDIA_URL = '/static/images/' MEDIA_URL = '/static/images/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'data/images') MEDIA_ROOT = os.path.join(BASE_DIR, 'data/images')

View File

@ -138,6 +138,14 @@ class Content(models.Model):
def formatted_schedule(self): def formatted_schedule(self):
return mark_safe(markdownify(self.schedule)) return mark_safe(markdownify(self.schedule))
@property
def formatted_opttext2(self):
return mark_safe(markdownify(self.opttext2))
@property
def formatted_opttext3(self):
return mark_safe(markdownify(self.opttext3))
@property @property
def typefilter(self): def typefilter(self):
return self.type return self.type

View File

@ -19,8 +19,12 @@
{% if content.place %}<br/>{{content.place}}{% endif%} {% if content.place %}<br/>{{content.place}}{% endif%}
</h6> </h6>
{% endif %} {% endif %}
<p> {{content.formatted_header|safe}} </p> <p>
<p> {{content.formatted_body|safe}} </p> {{content.formatted_header}}
</p>
<p>
{{content.formatted_body}}
</p>
{% include "opt.html" %} {% include "opt.html" %}
{% include "links.html" %} {% include "links.html" %}
{% include "gallery.html" with gallery=content.gallery %} {% include "gallery.html" with gallery=content.gallery %}

View File

@ -8,8 +8,12 @@
{% endif %} {% endif %}
<div class="index-text"> <div class="index-text">
<h4><a href="{{ events.get_absolute_url }}/" class="big-title">{{events.title}} </a></h4> <h4><a href="{{ events.get_absolute_url }}/" class="big-title">{{events.title}} </a></h4>
<p> {{events.formatted_header|safe}} </p> <p>
<p> {{events.formatted_body|safe}} </p> {{events.formatted_header}}
</p>
<p>
{{events.formatted_body}}
</p>
{% include "opt.html" with content=events %} {% include "opt.html" with content=events %}
{% include "links.html" with content=events %} {% include "links.html" with content=events %}
{% include "gallery.html" with gallery=gallery %} {% include "gallery.html" with gallery=gallery %}

View File

@ -7,8 +7,12 @@
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<div class="index-text"> <div class="index-text">
<h4 class="big-title">{{content.title}} </a></h4> <h4 class="big-title">{{content.title}} </a></h4>
<p> {{content.formatted_header}} </p> <p>
<p> {{content.formatted_body}} </p> {{content.formatted_header}}
</p>
<p>
{{content.formatted_body}}
</p>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -3,7 +3,9 @@
{% if content.optbtn2 %} {% if content.optbtn2 %}
<h4>{{ content.optbtn2|safe }} </h4> <h4>{{ content.optbtn2|safe }} </h4>
{% endif %} {% endif %}
<p>{{ content.opttext2|safe|linebreaks }}</p> <p>
{{ content.formatted_opttext2 }}
</p>
</div> </div>
{% endif %} {% endif %}
{% if content.opttext3 %} {% if content.opttext3 %}
@ -11,7 +13,9 @@
{% if content.optbtn3 %} {% if content.optbtn3 %}
<h4>{{ content.optbtn3|safe }} </h4> <h4>{{ content.optbtn3|safe }} </h4>
{% endif %} {% endif %}
<p>{{ content.opttext3|safe|linebreaks }}</p> <p>
{{ content.formatted_opttext3 }}
</p>
</div> </div>
{% endif %} {% endif %}
{% if content.schedule %} {% if content.schedule %}

View File

@ -8,8 +8,12 @@
{% endif %} {% endif %}
<div class="index-text"> <div class="index-text">
<h4><a href="{{ works.get_absolute_url }}" class="big-title">{{works.title}} </a></h4> <h4><a href="{{ works.get_absolute_url }}" class="big-title">{{works.title}} </a></h4>
<p> {{works.formatted_header|safe}} </p> <p>
<p> {{works.formatted_body|safe}} </p> {{works.formatted_header}}
</p>
<p>
{{works.formatted_body}}
</p>
{% include "opt.html" with content=works %} {% include "opt.html" with content=works %}
{% include "links.html" with content=projects %} {% include "links.html" with content=projects %}
{% include "gallery.html" with gallery=gallery %} {% include "gallery.html" with gallery=gallery %}

5
content/utils.py Normal file
View File

@ -0,0 +1,5 @@
import markdownx.utils
def markdownify(string):
string = markdownx.utils.markdownify(string)
return string