Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2021-08-21 12:10:06 -07:00
commit 0f419d2b06
22 changed files with 109 additions and 96 deletions

28
.github/workflows/curlylint.yaml vendored Normal file
View file

@ -0,0 +1,28 @@
name: Templates validator
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install curlylint
run: pip install curlylint
- name: Run linter
run: >
curlylint --rule 'aria_role: true' \
--rule 'django_forms_rendering: true' \
--rule 'html_has_lang: true' \
--rule 'image_alt: true' \
--rule 'meta_viewport: true' \
--rule 'no_autofocus: true' \
--rule 'tabindex_no_positive: true' \
--exclude '_modal.html|create_status/layout.html' \
bookwyrm/templates

View file

@ -57,7 +57,7 @@
{% if author.wikipedia_link %}
<p class="my-1">
<a itemprop="sameAs" href="{{ author.wikipedia_link }}" rel=”noopener” target="_blank">
<a itemprop="sameAs" href="{{ author.wikipedia_link }}" rel="noopener" target="_blank">
{% trans "Wikipedia" %}
</a>
</p>

View file

@ -134,7 +134,7 @@
<form name="add-description" method="POST" action="/add-description/{{ book.id }}">
{% csrf_token %}
<p class="fields is-grouped">
<label class="label"for="id_description_{{ book.id }}">{% trans "Description:" %}</label>
<label class="label" for="id_description_{{ book.id }}">{% trans "Description:" %}</label>
<textarea name="description" cols="None" rows="None" class="textarea" id="id_description_{{ book.id }}"></textarea>
</p>
<div class="field">

View file

@ -42,11 +42,18 @@
</div>
{% endif %}
{% if book %}
<form class="block" name="edit-book" action="{{ book.local_path }}/{% if confirm_mode %}confirm{% else %}edit{% endif %}" method="post" enctype="multipart/form-data">
{% else %}
<form class="block" name="create-book" action="/create-book{% if confirm_mode %}/confirm{% endif %}" method="post" enctype="multipart/form-data">
{% endif %}
<form
class="block"
{% if book %}
name="edit-book"
action="{{ book.local_path }}/{% if confirm_mode %}confirm{% else %}edit{% endif %}"
{% else %}
name="create-book"
action="/create-book{% if confirm_mode %}/confirm{% endif %}"
{% endif %}
method="post"
enctype="multipart/form-data"
>
{% csrf_token %}
{% if confirm_mode %}

View file

@ -6,7 +6,6 @@
<div class="columns">
<div class="column">
{% trans "Progress Updates:" %}
</dl>
<ul>
{% if readthrough.finish_date or readthrough.progress %}
<li>

View file

@ -1,4 +1,4 @@
<html>
<html lang="{% get_lang %}">
<body>
<div>
<strong>Subject:</strong> {% include subject_path %}

View file

@ -40,11 +40,10 @@
{% if suggested_users %}
{# suggested users for when things are very lonely #}
{% include 'feed/suggested_users.html' with suggested_users=suggested_users %}
{% endif %}
</div>
{% endif %}
{% endif %}
{% for activity in activities %}
{% if not activities.number > 1 and forloop.counter0 == 2 and suggested_users %}

View file

@ -2,5 +2,5 @@
<section class="block">
<h2 class="title is-5">{% trans "Who to follow" %}</h2>
{% include 'snippets/suggested_users.html' with suggested_users=suggested_users %}
<a class="help" href="{% url 'directory' %}">View directory <span class="icon icon-arrow-right"></a>
<a class="help" href="{% url 'directory' %}">{% trans "View directory" %} <span class="icon icon-arrow-right"></span></a>
</section>

View file

@ -20,10 +20,10 @@
<dt class="has-text-weight-medium">{% trans "Import completed:" %}</dt>
<dd class="ml-2">{{ task.date_done | naturaltime }}</dd>
</div>
</dl>
{% elif task.failed %}
<div class="notification is-danger">{% trans "TASK FAILED" %}</div>
{% endif %}
</dl>
</div>
<div class="block">
@ -84,6 +84,7 @@
<button class="button is-block mt-3" type="submit">{% trans "Retry items" %}</button>
</fieldset>
</form>
<hr>
@ -103,7 +104,6 @@
{% endfor %}
</ul>
{% endif %}
</form>
</div>
{% endif %}
@ -153,7 +153,6 @@
{% endfor %}
</table>
</div>
</div>
{% endspaceless %}{% endblock %}
{% block scripts %}

View file

@ -1,33 +0,0 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}{% trans "Search Results" %}{% endblock %}
{% block content %}
{% with book_results|first as local_results %}
<div class="block">
<h1 class="title">{% blocktrans %}Search Results for "{{ query }}"{% endblocktrans %}</h1>
</div>
<div class="block columns">
<div class="column">
<h2 class="title">{% trans "Matching Books" %}</h2>
<section class="block">
{% if not results %}
<p>{% blocktrans %}No books found for "{{ query }}"{% endblocktrans %}</p>
{% else %}
<ul>
{% for result in results %}
<li class="pd-4">
<a href="{{ result.key }}">{% include 'snippets/search_result_text.html' with result=result link=True %}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</section>
<div class="column">
</div>
</div>
{% endwith %}
{% endblock %}

View file

@ -7,7 +7,6 @@
{% block edit-button %}
{% trans "Create Announcement" as button_text %}
{% include 'snippets/toggle/open_button.html' with controls_text="create_announcement" icon_with_text="plus" text=button_text focus="create_announcement_header" %}
</a>
{% endblock %}
{% block panel %}

View file

@ -54,7 +54,7 @@
{% endif %}
{% for invite in invites %}
<tr>
<td><a href="{{ invite.link }}">{{ invite.link }}</td>
<td><a href="{{ invite.link }}">{{ invite.link }}</a></td>
<td>{{ invite.expiry|naturaltime }}</td>
<td>{{ invite.use_limit }}</td>
<td>{{ invite.times_used }}</td>

View file

@ -47,7 +47,7 @@
<div class="field">
<label class="label" for="id_file">JSON data:</label>
<aside class="help">
Expects a json file in the format provided by <a href="https://fediblock.org/" target="_blank" rel=”noopener”>FediBlock</a>, with a list of entries that have <code>instance</code> and <code>url</code> fields. For example:
Expects a json file in the format provided by <a href="https://fediblock.org/" target="_blank" rel="noopener">FediBlock</a>, with a list of entries that have <code>instance</code> and <code>url</code> fields. For example:
<pre>
[
{

View file

@ -10,7 +10,7 @@
<a
href="{{ result.view_link|default:result.key }}"
{% if remote_result %}
rel=”noopener”
rel="noopener"
target="_blank"
{% endif %}
>{{ result.title }}</a>

View file

@ -13,7 +13,9 @@
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start_reading" controls_uid=button_uuid focus="modal_title_start_reading" disabled=is_current fallback_url=fallback_url %}
{% endif %}{% elif shelf.identifier == 'read' and active_shelf.shelf.identifier == 'read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
<button type="button" class="button {{ class }}" disabled><span>{% trans "Read" %}</span>
<button type="button" class="button {{ class }}" disabled>
<span>{% trans "Read" %}</span>
</button>
{% endif %}{% elif shelf.identifier == 'read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
{% trans "Finish reading" as button_text %}

View file

@ -25,7 +25,7 @@
<div class="content">
<div
dir="auto"
{% if itemprop %}itemprop="{{ itemprop }}{% endif %}"
{% if itemprop %}itemprop="{{ itemprop }}"{% endif %}
>
{{ full }}
</div>
@ -41,7 +41,7 @@
<div class="content">
<div
dir="auto"
{% if itemprop %}itemprop="{{ itemprop }}{% endif %}"
{% if itemprop %}itemprop="{{ itemprop }}"{% endif %}
>
{{ full }}
</div>

View file

@ -31,8 +31,8 @@
{% spaceless %}
<div class="column box has-background-white-bis content preserve-whitespace">
{{ user.summary|to_markdown|safe }}
{% endspaceless %}
</div>
{% endspaceless %}
{% endif %}
</div>
{% if not is_self and request.user.is_authenticated %}

View file

@ -71,7 +71,7 @@
{% endfor %}
{% if not activities %}
<div class="block">
<p>{% trans "No activities yet!" %}</a>
<p>{% trans "No activities yet!" %}</p>
</div>
{% endif %}

View file

@ -2,23 +2,30 @@
{% load utilities %}
{% if widget.is_initial %}
<p class="mb-1">
<p class="mb-1">
{{ widget.initial_text }}:
<a href="{{ widget.value.url }}">{{ widget.value|truncatepath:10 }}</a>
</p>
{% if not widget.required %}
<p class="mb-1">
</p>
{% if not widget.required %}
<p class="mb-1">
<label class="has-text-weight-normal">
<input type="checkbox" name="{{ widget.checkbox_name }}" id="{{ widget.checkbox_id }}"{% if widget.attrs.disabled %} disabled{% endif %}>
{{ widget.clear_checkbox_label }}
</label>{% endif %}
</p>
<p class="mb-1">
{{ widget.input_text }}:
{% else %}
<p class="mb-1">
</label>
</p>
{% endif %}
{% endif %}
<p class="mb-1">
{% if widget.is_initial %}
{{ widget.input_text }}:
{% endif %}
<input type="{{ widget.type }}" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>
<span class="help file-cta is-hidden file-too-big">{% trans "File exceeds maximum size: 10MB" %}</span>
<span class="help file-cta is-hidden file-too-big">
{% trans "File exceeds maximum size: 10MB" %}
</span>
</p>

View file

@ -71,7 +71,7 @@ def get_header_template(status):
if isinstance(status, models.Boost):
status = status.boosted_status
try:
header_type = status.reading_status
header_type = status.reading_status.replace("-", "_")
if not header_type:
raise AttributeError()
except AttributeError:

View file

@ -62,7 +62,7 @@ class Book(View):
queryset = queryset.filter(user=request.user, deleted=False)
else:
queryset = reviews.exclude(Q(content__isnull=True) | Q(content=""))
queryset = queryset.select_related("user")
queryset = queryset.select_related("user").order_by("-published_date")
paginated = Paginator(queryset, PAGE_LENGTH)
lists = privacy_filter(

View file

@ -1,9 +1,11 @@
""" isbn search view """
from django.core.paginator import Paginator
from django.http import JsonResponse
from django.template.response import TemplateResponse
from django.views import View
from bookwyrm.connectors import connector_manager
from bookwyrm.settings import PAGE_LENGTH
from .helpers import is_api_request
# pylint: disable= no-self-use
@ -17,8 +19,12 @@ class Isbn(View):
if is_api_request(request):
return JsonResponse([r.json() for r in book_results], safe=False)
paginated = Paginator(book_results, PAGE_LENGTH).get_page(
request.GET.get("page")
)
data = {
"results": book_results,
"results": [{"results": paginated}],
"query": isbn,
"type": "book",
}
return TemplateResponse(request, "isbn_search_results.html", data)
return TemplateResponse(request, "search/book.html", data)