Smarter generation of OGP/Schema.org/etc. metadata, with HTML tags stripped out so the result looks nice and clean

This commit is contained in:
Danielle McLean 2017-12-11 13:30:46 +11:00
parent b8a74443c9
commit ea241577f1
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
3 changed files with 17 additions and 4 deletions

View file

@ -1,14 +1,18 @@
import html
import json
from accept_types import get_best_match
from django.conf import settings
from django.http import HttpResponse, JsonResponse
from django.http import HttpResponseForbidden, HttpResponseBadRequest
from django.utils.html import strip_tags
from os.path import join
from shorturls import default_converter as converter
from shorturls.templatetags.shorturl import ShortURL
from types import SimpleNamespace
from urllib.parse import urlencode, urljoin
from .templatetags.markdown import markdown
cache = SimpleNamespace(package_json=None)
@ -63,3 +67,7 @@ def bad_req(message):
def forbid(message):
return HttpResponseForbidden(message, content_type='text/plain')
def to_plain(md):
return html.unescape(strip_tags(markdown(md)))