Merge pull request #1401 from bookwyrm-social/opensearch
Adds opensearch xml file
This commit is contained in:
commit
0a37556941
|
@ -10,6 +10,8 @@
|
||||||
<link rel="stylesheet" href="{% static "css/vendor/icons.css" %}">
|
<link rel="stylesheet" href="{% static "css/vendor/icons.css" %}">
|
||||||
<link rel="stylesheet" href="{% static "css/bookwyrm.css" %}">
|
<link rel="stylesheet" href="{% static "css/bookwyrm.css" %}">
|
||||||
|
|
||||||
|
<link rel="search" type="application/opensearchdescription+xml" href="{% url 'opensearch' %}" title="{% blocktrans with site_name=site.name %}{{ site_name }} search{% endblocktrans %}" />
|
||||||
|
|
||||||
<link rel="shortcut icon" type="image/x-icon" href="{% if site.favicon %}{% get_media_prefix %}{{ site.favicon }}{% else %}{% static "images/favicon.ico" %}{% endif %}">
|
<link rel="shortcut icon" type="image/x-icon" href="{% if site.favicon %}{% get_media_prefix %}{{ site.favicon }}{% else %}{% static "images/favicon.ico" %}{% endif %}">
|
||||||
|
|
||||||
{% if preview_images_enabled is True %}
|
{% if preview_images_enabled is True %}
|
||||||
|
@ -34,7 +36,7 @@
|
||||||
<a class="navbar-item" href="/">
|
<a class="navbar-item" href="/">
|
||||||
<img class="image logo" src="{% if site.logo_small %}{% get_media_prefix %}{{ site.logo_small }}{% else %}{% static "images/logo-small.png" %}{% endif %}" alt="Home page">
|
<img class="image logo" src="{% if site.logo_small %}{% get_media_prefix %}{{ site.logo_small }}{% else %}{% static "images/logo-small.png" %}{% endif %}" alt="Home page">
|
||||||
</a>
|
</a>
|
||||||
<form class="navbar-item column" action="/search/">
|
<form class="navbar-item column" action="{% url 'search' %}">
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{% load i18n %}{% load static %}<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<OpenSearchDescription
|
||||||
|
xmlns="http://a9.com/-/spec/opensearch/1.1/"
|
||||||
|
xmlns:moz="http://www.mozilla.org/2006/browser/search/"
|
||||||
|
>
|
||||||
|
<ShortName>BW</ShortName>
|
||||||
|
<Description>{% blocktrans trimmed with site_name=site.name %}
|
||||||
|
{{ site_name }} search
|
||||||
|
{% endblocktrans %}</Description>
|
||||||
|
<Image width="16" height="16" type="image/x-icon">{{ image }}</Image>
|
||||||
|
<Url
|
||||||
|
type="text/html"
|
||||||
|
method="get"
|
||||||
|
template="https://{{ DOMAIN }}{% url 'search' %}?q={searchTerms}"
|
||||||
|
/>
|
||||||
|
</OpenSearchDescription>
|
|
@ -43,6 +43,7 @@ urlpatterns = [
|
||||||
re_path(r"^nodeinfo/2\.0/?$", views.nodeinfo),
|
re_path(r"^nodeinfo/2\.0/?$", views.nodeinfo),
|
||||||
re_path(r"^api/v1/instance/?$", views.instance_info),
|
re_path(r"^api/v1/instance/?$", views.instance_info),
|
||||||
re_path(r"^api/v1/instance/peers/?$", views.peers),
|
re_path(r"^api/v1/instance/peers/?$", views.peers),
|
||||||
|
re_path(r"^opensearch.xml$", views.opensearch, name="opensearch"),
|
||||||
# polling updates
|
# polling updates
|
||||||
re_path("^api/updates/notifications/?$", views.get_notification_count),
|
re_path("^api/updates/notifications/?$", views.get_notification_count),
|
||||||
re_path("^api/updates/stream/(?P<stream>[a-z]+)/?$", views.get_unread_status_count),
|
re_path("^api/updates/stream/(?P<stream>[a-z]+)/?$", views.get_unread_status_count),
|
||||||
|
|
|
@ -128,3 +128,14 @@ def peers(_):
|
||||||
def host_meta(request):
|
def host_meta(request):
|
||||||
"""meta of the host"""
|
"""meta of the host"""
|
||||||
return TemplateResponse(request, "host_meta.xml", {"DOMAIN": DOMAIN})
|
return TemplateResponse(request, "host_meta.xml", {"DOMAIN": DOMAIN})
|
||||||
|
|
||||||
|
|
||||||
|
@require_GET
|
||||||
|
def opensearch(request):
|
||||||
|
"""Open Search xml spec"""
|
||||||
|
site = models.SiteSettings.get()
|
||||||
|
logo_path = site.favicon or "images/favicon.png"
|
||||||
|
logo = f"{MEDIA_FULL_URL}{logo_path}"
|
||||||
|
return TemplateResponse(
|
||||||
|
request, "opensearch.xml", {"image": logo, "DOMAIN": DOMAIN}
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue