Some basic support for gross SEO metadata formats with django-meta

pull/1/head
Danielle McLean 5 years ago
parent 1aed52b75f
commit 8ef64d6a87
Signed by: 00dani
GPG Key ID: 5A5D2D1AFF12EEC5
  1. 1
      Pipfile
  2. 9
      Pipfile.lock
  3. 5
      home/views.py
  4. 8
      lemoncurry/settings/base.py
  5. 2
      lemoncurry/settings/dev.py
  6. 2
      lemoncurry/settings/prod.py
  7. 5
      lemoncurry/templates/lemoncurry/layout.html
  8. 13
      users/models.py

@ -14,6 +14,7 @@ gunicorn = "*"
pillow = "*"
python-memcached = "*"
django-favicon-plus = "*"
django-meta = "*"
[dev-packages]

9
Pipfile.lock generated

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "388a82f0237a5312720d62a0aeee6365922fc525d666039e15ba70000430630c"
"sha256": "60ee6c91a6c7b88c2a424a70428f3f380adc142716ebe82ce35f31a10cedeb3c"
},
"host-environment-markers": {
"implementation_name": "cpython",
@ -60,6 +60,13 @@
],
"version": "==0.0.7"
},
"django-meta": {
"hashes": [
"sha256:2a5b8d95099f69fb9736630c4fbf4fcc2972a1fcd9c708a5bb72dde22e84d8dd",
"sha256:4a7dc51c40fd6a097825040af29ee0e049f1fce29b006e39f266f80ba988bac6"
],
"version": "==1.4"
},
"gunicorn": {
"hashes": [
"sha256:75af03c99389535f218cc596c7de74df4763803f7b63eb09d77e92b3956b36c6",

@ -4,4 +4,7 @@ from users.models import User
def index(request):
user = get_object_or_404(User, pk=1)
return render(request, 'home/index.html', {'user': user})
return render(request, 'home/index.html', {
'user': user,
'meta': user.as_meta(request),
})

@ -66,6 +66,7 @@ INSTALLED_APPS = [
'compressor',
'favicon',
'meta',
'lemoncurry',
'home',
@ -182,3 +183,10 @@ MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
# Settings specific to lemoncurry
LEMONCURRY_SITE_NAME = '00dani.me'
# django-meta
# https://django-meta.readthedocs.io/en/latest/settings.html
META_SITE_PROTOCOL = 'https'
META_SITE_NAME = LEMONCURRY_SITE_NAME
META_USE_OG_PROPERTIES = True
META_USE_TWITTER_PROPERTIES = True

@ -3,3 +3,5 @@ from .base import *
ALLOWED_HOSTS = ['*']
STATIC_URL = 'https://static.00dani.dev/'
MEDIA_URL = STATIC_URL + 'media/'
META_SITE_DOMAIN = '00dani.dev'
META_FB_APPID = '142105433189339'

@ -16,3 +16,5 @@ DATABASES['default'] = {
STATIC_URL = 'https://cdn.00dani.me/'
MEDIA_URL = STATIC_URL + 'media/'
META_SITE_DOMAIN = '00dani.me'
META_FB_APPID = '145311792869199'

@ -1,9 +1,10 @@
{% load compress favtags lemoncurry_tags static %}<!doctype html>
{% load compress favtags lemoncurry_tags meta static %}<!doctype html>
<html lang="en" class="{% block html_class %}{% endblock %}">
<head>
<head{% meta_namespaces %}>
<title class="p-name">{% site_name %}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
{% include 'meta/meta.html' %}
{% placeFavicon %}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"

@ -1,5 +1,6 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
from meta.models import ModelMeta
def avatar_path(instance, name):
@ -18,10 +19,20 @@ class Site(models.Model):
ordering = ('name',)
class User(AbstractUser):
class User(ModelMeta, AbstractUser):
avatar = models.ImageField(upload_to=avatar_path)
note = models.TextField(blank=True)
@property
def avatar_url(self):
return self.avatar.url
_metadata = {
'image': 'avatar_url',
'description': 'note',
'og_type': 'profile',
}
class Profile(models.Model):
user = models.ForeignKey(

Loading…
Cancel
Save