forked from mirrors/bookwyrm
Add embed URL component to list layout
This commit is contained in:
parent
1b9291616b
commit
306ea962c4
2 changed files with 16 additions and 0 deletions
|
@ -186,6 +186,13 @@
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div>
|
||||
<h2 class="title is-5 mt-6" id="embed-label">
|
||||
{% trans "Embed this list on a website" %}
|
||||
</h2>
|
||||
<textarea readonly class="textarea is-small" aria-labelledby="embed-label" data-copytext data-copytext-label="{% trans 'Copy embed code' %}" data-copytext-success="{% trans 'Copied!' %}"><iframe style="border-width:0;" id="bookwyrm_list_embed" width="400" height="600" title="{% blocktrans with list_name=list.name site_name=site.name owner=list.user.display_name %}{{ list_name }}, a list by {{owner}} on {{ site_name }}{% endblocktrans %}" src="{{ embed_url }}"></iframe></textarea>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -168,6 +168,14 @@ class List(View):
|
|||
][: 5 - len(suggestions)]
|
||||
|
||||
page = paginated.get_page(request.GET.get("page"))
|
||||
|
||||
embed_key = str(book_list.embed_key.hex)
|
||||
embed_url = reverse("embed-list", args=[book_list.id, embed_key])
|
||||
embed_url = request.build_absolute_uri(embed_url)
|
||||
|
||||
if request.GET:
|
||||
embed_url = "%s?%s" % (embed_url, request.GET.urlencode())
|
||||
|
||||
data = {
|
||||
"list": book_list,
|
||||
"items": page,
|
||||
|
@ -181,6 +189,7 @@ class List(View):
|
|||
"sort_form": forms.SortListForm(
|
||||
{"direction": direction, "sort_by": sort_by}
|
||||
),
|
||||
"embed_url": embed_url,
|
||||
}
|
||||
return TemplateResponse(request, "lists/list.html", data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue