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 untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
3 changed files with 17 additions and 4 deletions

View file

@ -4,6 +4,7 @@ from django.contrib.sites.models import Site as DjangoSite
from django.utils.functional import cached_property
from meta.models import ModelMeta
from urllib.parse import urljoin
from lemoncurry import utils
def avatar_path(instance, name):
@ -45,6 +46,10 @@ class User(ModelMeta, AbstractUser):
def get_absolute_url(self):
return self.url
@property
def description(self):
return utils.to_plain(self.note)
@property
def avatar_url(self):
return self.avatar.url
@ -81,7 +86,7 @@ class User(ModelMeta, AbstractUser):
_metadata = {
'image': 'avatar_url',
'description': 'note',
'description': 'description',
'og_type': 'profile',
'og_profile_id': 'facebook_id',
'twitter_creator': 'twitter_username',