Remove django-shorturls with my own implementation, since it's incompatible with Django 2 and unmaintained

This commit is contained in:
Danielle McLean 2018-03-21 21:50:40 +11:00
parent 27e0cb9a34
commit 098284a617
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
18 changed files with 252 additions and 184 deletions

View file

@ -8,6 +8,7 @@ from slugify import slugify
from textwrap import shorten
from urllib.parse import urljoin
from lemonshort.short_url import short_url
from meta.models import ModelMeta
from model_utils.models import TimeStampedModel
from users.models import Profile
@ -148,6 +149,10 @@ class Entry(ModelMeta, TimeStampedModel):
args.append(self.slug)
return reverse('entries:entry_amp', args=args)
@property
def short_url(self):
return short_url(self)
@property
def slug(self):
return slugify(self.name)

View file

@ -1,9 +1,9 @@
{% extends 'lemoncurry/layout.html' %}
{% load shorturl static %}
{% load static %}
{% block head %}
<link rel="amphtml" href="{{ entry.amp_url }}" />
<link rel="shortlink" href="{% shorturl entry %}" />
<link rel="shortlink" href="{{ entry.short_url }}" />
{% endblock %}
{% block styles %}

View file

@ -1,10 +1,10 @@
{% load absolute_url favtags friendly_url humanize jsonify lemoncurry_tags markdown shortlink theme_colour %}<!doctype html>
{% load absolute_url favtags friendly_url humanize jsonify lemoncurry_tags markdown theme_colour %}<!doctype html>
<html lang="en" class="h-entry">
<head>
<meta charset="utf-8" />
<title>{{ entry.title }} ~ {% site_name %}</title>
<link rel="canonical" href="{% absolute_url entry.url %}">
{% shortlink entry as short %}<link rel="shortlink" href="{% absolute_url short %}" />
<link rel="shortlink" href="{% absolute_url entry.short_url %}" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script class="p-json-ld" type="application/ld+json">
{{ entry.json_ld | jsonify }}
@ -132,9 +132,9 @@
amp
</a>
<a class="u-url" href="{% absolute_url short %}">
<a class="u-url" href="{% absolute_url entry.short_url %}">
🔗
{{ short | friendly_url }}
{{ entry.short_url | friendly_url }}
</a>
{% for c in entry.cats.all %}

View file

@ -1,4 +1,4 @@
{% load bleach friendly_url humanize jsonify markdown shortlink %}<article class="card h-entry">
{% load bleach friendly_url humanize jsonify markdown %}<article class="card h-entry">
{% if entry.photo %}<img class="card-img-top u-photo" src="{{ entry.photo.url }}" />{% endif %}
{% if entry.in_reply_to %}{% with reply=entry.reply_context %}
@ -39,9 +39,9 @@
<i class="fas fa-bolt"></i>
amp
</a>
{% shortlink entry as short %}<a class="u-url" href="{{ short }}">
<a class="u-url" href="{{ entry.short_url }}">
<i class="fas fa-link"></i>
{{ short | friendly_url }}
{{ entry.short_url | friendly_url }}
</a>
</div>