2016-06-19 23:00:08 +00:00
|
|
|
from django.contrib.sites.shortcuts import get_current_site
|
2016-06-25 11:39:28 +00:00
|
|
|
from django.db import models
|
2016-06-27 23:04:45 +00:00
|
|
|
from django.utils.html import mark_safe
|
2016-06-19 23:00:08 +00:00
|
|
|
|
2017-05-30 19:50:40 +00:00
|
|
|
from markdown import markdown
|
|
|
|
import bleach
|
|
|
|
|
2016-06-19 23:00:08 +00:00
|
|
|
|
2016-06-25 11:39:28 +00:00
|
|
|
class PonyConfModel(models.Model):
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
updated = models.DateTimeField(auto_now=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2017-05-30 19:50:40 +00:00
|
|
|
|
|
|
|
def markdown_to_html(md):
|
|
|
|
html = markdown(md)
|
2023-01-24 21:35:23 +00:00
|
|
|
allowed_tags = bleach.ALLOWED_TAGS + ['p', 'pre', 'span', 'img'] + ['h%d' % i for i in range(1, 7) ]
|
|
|
|
allowed_attributes = bleach.ALLOWED_ATTRIBUTES['img'] = ['src', 'alt']
|
|
|
|
html = bleach.clean(html, tags=allowed_tags, attributes=allowed_attributes)
|
2017-05-30 19:50:40 +00:00
|
|
|
return mark_safe(html)
|