You've already forked hotpocket
BTHLABS-81: OG Properties on Share Association page
Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl> Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
@@ -2,10 +2,24 @@
|
||||
|
||||
{% load i18n static ui %}
|
||||
|
||||
{% block title %}{{ association.title }}{% endblock %}
|
||||
{% block title %}{% if association.title %}{{ association.title }}{% else %}{{ association.target.url }}{% endif %}{% endblock %}
|
||||
|
||||
{% block button_bar_class %}d-none{% endblock %}
|
||||
|
||||
{% block page_head %}
|
||||
{{ block.super}}
|
||||
<meta property="og:title" content="{% if association.title %}{{ association.title }}{% else %}{{ association.target.url }}{% endif %}">
|
||||
{% if association.description %}
|
||||
<meta property="og:description" content="{{ association.description|truncatechars:125 }}">
|
||||
{% endif %}
|
||||
<meta property="og:image" content="{{ og_card_url }}">
|
||||
<meta property="og:image:width" content="1200">
|
||||
<meta property="og:image:height" content="630">
|
||||
<meta property="og:url" content="{{ share_url }}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:site_name" content="{{ SITE_TITLE }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block page_body %}
|
||||
<div id="ViewAssociationView" class="container pb-3">
|
||||
<p class="display-3 mt-3 mb-0 text-center">
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.contrib import messages
|
||||
import django.db
|
||||
from django.http import HttpRequest, HttpResponse, JsonResponse
|
||||
from django.shortcuts import redirect, render
|
||||
from django.templatetags.static import static
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import FormView, View
|
||||
@@ -198,12 +199,18 @@ def view(request: HttpRequest, pk: uuid.UUID) -> HttpResponse:
|
||||
if is_share is True:
|
||||
show_controls = show_controls and False
|
||||
|
||||
share_url = reverse(
|
||||
'ui.associations.view',
|
||||
args=(association.pk,),
|
||||
query=[
|
||||
('share', 'true'),
|
||||
],
|
||||
share_url = request.build_absolute_uri(
|
||||
reverse(
|
||||
'ui.associations.view',
|
||||
args=(association.pk,),
|
||||
query=[
|
||||
('share', 'true'),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
og_card_url = request.build_absolute_uri(
|
||||
static('ui/img/og-card.png'),
|
||||
)
|
||||
|
||||
return render(
|
||||
@@ -213,6 +220,12 @@ def view(request: HttpRequest, pk: uuid.UUID) -> HttpResponse:
|
||||
'association': association,
|
||||
'show_controls': show_controls,
|
||||
'share_url': share_url,
|
||||
'is_share': is_share,
|
||||
'og_card_url': (
|
||||
og_card_url
|
||||
if is_share is True
|
||||
else None
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user