forked from 00dani/lemoncurry
Remove django-shorturls with my own implementation, since it's incompatible with Django 2 and unmaintained
This commit is contained in:
parent
27e0cb9a34
commit
098284a617
18 changed files with 252 additions and 184 deletions
|
@ -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)
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue