Merge pull request 'Add opengraph' (#30) from dev into main
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
continuous-integration/drone Build is passing

Reviewed-on: #30
This commit is contained in:
Jannis Portmann 2023-11-06 17:44:09 +01:00
commit b2ffde33e4
2 changed files with 7 additions and 1 deletions

View file

@ -6,6 +6,11 @@
<meta name="description"
content="{{ offer.user.username }} offers {{ offer.title }}!">
<meta name="author" content="{{ offer.user.username }}">
<meta property="og:title" content="{{ offer.title }}">
<meta property="og:description"
content="{{ offer.user.username }} offers {{ offer.title }}!">
<meta property="og:url" content="{{ host }}/offer/{{ offer.id }}">
<meta property="og:image" content="{{ host }}{{ offer.image.url }}">
{% endblock %}
{% block content %}
{% if offer.user == request.user %}

View file

@ -53,6 +53,7 @@ def create_offer(request):
def offer_detail(request, offer_id):
offer = get_object_or_404(Offer, id=offer_id)
wishes = Wish.objects.filter(user=offer.user)
host = f"{request.scheme}://{request.META.get('HTTP_HOST')}"
if request.user.is_authenticated:
if offer.zipcode and request.user.zipcode:
@ -68,7 +69,7 @@ def offer_detail(request, offer_id):
else:
dist = None
return render(request, "offer/detail.html", {"offer": offer, "wishes": wishes, "dist": dist})
return render(request, "offer/detail.html", {"host": host, "offer": offer, "wishes": wishes, "dist": dist})
@login_required