forked from mirrors/bookwyrm
Add opengraph image depending on context
This commit is contained in:
parent
65de40a95a
commit
e5e549d125
4 changed files with 23 additions and 7 deletions
|
@ -1,8 +1,13 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load i18n %}{% load bookwyrm_tags %}{% load humanize %}{% load utilities %}
|
||||
{% load i18n %}{% load bookwyrm_tags %}{% load humanize %}{% load utilities %}{% load layout %}
|
||||
|
||||
{% block title %}{{ book|book_title }}{% endblock %}
|
||||
|
||||
{% block opengraph_images %}
|
||||
<meta name="twitter:image" content="{{ get_path }}/images/{{ book.preview_image }}">
|
||||
<meta name="og:image" content="{{ get_path }}/images/{{ book.preview_image }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% with user_authenticated=request.user.is_authenticated can_edit_book=perms.bookwyrm.edit_book %}
|
||||
<div class="block" itemscope itemtype="https://schema.org/Book">
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
<meta name="twitter:description" content="{{ site.instance_tagline }}">
|
||||
<meta name="og:description" content="{{ site.instance_tagline }}">
|
||||
|
||||
<meta name="twitter:image" content="{% if site.logo %}/images/{{ site.logo }}{% else %}/static/images/logo.png{% endif %}">
|
||||
<meta name="og:image" content="{% if site.logo %}/images/{{ site.logo }}{% else %}/static/images/logo.png{% endif %}">
|
||||
{% block opengraph_images %}
|
||||
<meta name="twitter:image" content="{{ get_path }}/images/{{ site.preview_image }}">
|
||||
<meta name="og:image" content="{{ get_path }}/images/{{ site.preview_image }}">
|
||||
{% endblock %}
|
||||
<meta name="twitter:image:alt" content="BookWyrm Logo">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load i18n %}
|
||||
{% load humanize %}
|
||||
{% load utilities %}
|
||||
{% load markdown %}
|
||||
{% load i18n %}{% load humanize %}{% load utilities %}{% load markdown %}{% load layout %}
|
||||
|
||||
{% block title %}{{ user.display_name }}{% endblock %}
|
||||
|
||||
{% block opengraph_images %}
|
||||
<meta name="twitter:image" content="{{ get_path }}/images/{{ user.preview_image }}">
|
||||
<meta name="og:image" content="{{ get_path }}/images/{{ user.preview_image }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<header class="block">
|
||||
{% block header %}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
""" template filters used for creating the layout"""
|
||||
from django import template, utils
|
||||
|
||||
from bookwyrm.settings import DOMAIN
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -10,3 +11,9 @@ def get_lang():
|
|||
"""get current language, strip to the first two letters"""
|
||||
language = utils.translation.get_language()
|
||||
return language[0 : language.find("-")]
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=False)
|
||||
def get_path():
|
||||
"""get protocol and host"""
|
||||
return "https://%s" % DOMAIN
|
||||
|
|
Loading…
Reference in a new issue