Moves titles into templates and adds i18n support

This commit is contained in:
Mouse Reeve 2021-02-28 10:00:36 -08:00
parent c4116c93b7
commit c483768544
55 changed files with 121 additions and 102 deletions

View file

@ -1,6 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block title %}{{ author.name }}{% endblock %}
{% block content %}
<div class="block">
<div class="columns is-mobile">

View file

@ -2,8 +2,10 @@
{% load i18n %}
{% load bookwyrm_tags %}
{% load humanize %}
{% block content %}
{% block title %}{{ book.title }}{% endblock %}
{% block content %}
<div class="block">
<div class="columns is-mobile">
<div class="column">

View file

@ -1,10 +1,10 @@
{% extends 'discover/landing_layout.html' %}
{% load i18n %}
{% block panel %}
{% block panel %}
<div class="block columns mt-4">
<nav class="menu column is-one-quarter">
<h2 class="menu-label">About {{ site.name }}</h2>
<h2 class="menu-label">{% blocktrans with site_name=site.name %}About {{ site_name }}{% endblocktrans %}</h2>
<ul class="menu-list">
<li>
<a href="#coc">{% trans "Code of Conduct" %}</a>

View file

@ -1,8 +1,10 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block content %}
{% block title %}{% trans "Welcome" %}{% endblock %}
{% block content %}
<header class="block has-text-centered">
<h1 class="title">{{ site.name }}</h1>
<h2 class="subtitle">{{ site.instance_tagline }}</h2>

View file

@ -1,6 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load humanize %}
{% block title %}{% trans "Edit Author" %}: {{ author.name }}{% endblock %}
{% block content %}
<header class="block">
<h1 class="title level-left">

View file

@ -1,6 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load humanize %}
{% block title %}{% trans "Edit Book" %}{% endblock %}
{% block content %}
<header class="block">
<h1 class="title level-left">

View file

@ -1,6 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block title %}{% blocktrans with book_title=work.title %}Editions of {{ book_title }}{% endblocktrans %}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% blocktrans with path=work.local_path work_title=work.title %}Editions of <a href="{{ work_path }}">"{{ work_title }}"</a>{% endblocktrans %}</h1>

View file

@ -1,11 +1,12 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block content %}
{% block title %}{% trans "Oops!" %}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% trans "Server Error" %}</h1>
<p>{% trans "Something went wrong! Sorry about that." %}</p>
</div>
{% endblock %}

View file

@ -3,7 +3,13 @@
{% block panel %}
<header class="block">
<h1 class="title">Direct Messages{% if partner %} with {% include 'snippets/username.html' with user=partner %}{% endif %}</h1>
<h1 class="title">
{% if partner %}
{% blocktrans with username=partner.display_name path=partner.local_path %}Direct Messages with <a href="{{ path }}">{{ username }}</a>{% endblocktrans %}
{% else %}
{% trans "Direct Messsages" %}
{% endif %}
</h1>
{% if partner %}<p class="subtitle"><a href="/direct-messages"><span class="icon icon-arrow-left" aria-hidden="true"></span> {% trans "All messages" %}</a></p>{% endif %}
</header>

View file

@ -1,9 +1,10 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block title %}Updates{% endblock %}
{% block content %}
{% block title %}{% trans "Updates" %}{% endblock %}
{% block content %}
<div class="columns">
{% if user.is_authenticated %}
<div class="column is-one-third">

View file

@ -1,5 +1,6 @@
{% extends 'feed/feed_layout.html' %}
{% load i18n %}
{% block panel %}
<header class="block">
<a href="/#feed" class="button" data-back>

View file

@ -22,7 +22,7 @@
<section class="card {% if goal %}hidden{% endif %}" id="show-edit-goal">
<header class="card-header">
<h2 class="card-header-title has-background-primary has-text-white" tabindex="0" id="edit-form-header">
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {{ year }} reading goal
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {% blocktrans %}{{ year }} reading goal{% endblocktrans %}
</h2>
</header>
<section class="card-content content">
@ -45,7 +45,13 @@
{% if goal.books %}
<section class="content">
<h2>{% if goal.user == request.user %}Your{% else %}{{ goal.user.display_name }}'s{% endif %} {{ year }} Books</h2>
<h2>
{% if goal.user == request.user %}
{% blocktrans %}Your {{ year }} Books{% endblocktrans %}
{% else %}
{% blocktrans with username=goal.user.display_name %}{{ username }}'s {{ year }} Books{% endblocktrans %}
{% endif %}
</h2>
<div class="columns is-multiline">
{% for book in goal.books %}
<div class="column is-narrow">

View file

@ -1,6 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load humanize %}
{% block title %}{% trans "Import Books" %}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% trans "Import Books" %}</h1>

View file

@ -2,6 +2,9 @@
{% load i18n %}
{% load bookwyrm_tags %}
{% load humanize %}
{% block title %}{% trans "Import Status" %}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% trans "Import Status" %}</h1>

View file

@ -1,5 +1,8 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}{% trans "Create an Account" %}{% endblock %}
{% block content %}
<div class="columns">

View file

@ -1,8 +1,8 @@
{% extends 'lists/list_layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block panel %}
{% block panel %}
{% if request.user == list.user and pending_count %}
<div class="block content">
<p>

View file

@ -1,8 +1,10 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block content %}
{% block title %}{{ list.name }}{% endblock %}
{% block content %}
<header class="columns content is-mobile">
<div class="column">
<h1 class="title">{{ list.name }} <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=list %}</span></h1>

View file

@ -1,5 +1,8 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}{% trans "Lists" %}{% endblock %}
{% block content %}
<header class="block">

View file

@ -1,7 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block content %}
{% block title %}{% trans "Login" %}{% endblock %}
{% block content %}
<div class="columns">
<div class="column">
<div class="box">

View file

@ -1,10 +1,11 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block content %}
{% block title %}{% trans "Not Found" %}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% trans "Not Found" %}</h1>
<p>{% trans "The page your requested doesn't seem to exist!" %}</p>
</div>
{% endblock %}

View file

@ -2,6 +2,9 @@
{% load i18n %}
{% load humanize %}
{% load bookwyrm_tags %}
{% block title %}{% trans "Notifications" %}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% trans "Notifications" %}</h1>

View file

@ -1,7 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block content %}
{% block title %}{% trans "Reset Password" %}{% endblock %}
{% block content %}
<div class="columns">
<div class="column">
<div class="block">

View file

@ -1,7 +1,9 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block content %}
{% block title %}{% trans "Reset Password" %}{% endblock %}
{% block content %}
<div class="columns is-centered">
<div class="column is-half">
<div class="block">

View file

@ -1,6 +1,8 @@
{% extends 'preferences/preferences_layout.html' %}
{% load i18n %}
{% block title %}{% trans "Blocked Users" %}{{ author.name }}{% endblock %}
{% block header %}
{% trans "Blocked Users" %}
{% endblock %}

View file

@ -1,5 +1,8 @@
{% extends 'preferences/preferences_layout.html' %}
{% load i18n %}
{% block title %}{% trans "Change Password" %}{% endblock %}
{% block header %}
{% trans "Change Password" %}
{% endblock %}

View file

@ -1,5 +1,8 @@
{% extends 'preferences/preferences_layout.html' %}
{% load i18n %}
{% block title %}{% trans "Edit Profile" %}{% endblock %}
{% block header %}
{% trans "Edit Profile" %}
{% endblock %}

View file

@ -1,5 +1,8 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}{% trans "Search Results" %}{% endblock %}
{% block content %}
{% with book_results|first as local_results %}
<div class="block">

View file

@ -1,5 +1,8 @@
{% extends 'settings/admin_layout.html' %}
{% load i18n %}
{% block title %}{% trans "Federated Servers" %}{% endblock %}
{% block header %}{% trans "Federated Servers" %}{% endblock %}
{% block panel %}

View file

@ -1,6 +1,9 @@
{% extends 'settings/admin_layout.html' %}
{% load i18n %}
{% block header %}{% trans "Site Configuration" %}{% endblock %}
{% block title %}{% trans "Site Settings" %}{% endblock %}
{% block header %}{% trans "Site Settings" %}{% endblock %}
{% block panel %}

View file

@ -1,13 +1,14 @@
{% extends 'layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block content %}
{% block title %}{{ tag.name }}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{% blocktrans %}Books tagged "{{ tag.name }}"{% endblocktrans %}</h1>
{% include 'snippets/book_tiles.html' with books=books.all %}
</div>
{% endblock %}

View file

@ -4,11 +4,7 @@
{% block header %}
<h1 class="title">
{% if is_self %}Your
{% else %}
{% include 'snippets/username.html' with user=user possessive=True %}
{% endif %}
followers
{% trans "User Profile" %}
</h1>
{% endblock %}

View file

@ -4,11 +4,7 @@
{% block header %}
<h1 class="title">
Users following
{% if is_self %}you
{% else %}
{% include 'snippets/username.html' with user=user %}
{% endif %}
{% trans "User Profile" %}
</h1>
{% endblock %}

View file

@ -5,11 +5,11 @@
<div class="columns is-mobile">
<div class="column">
<h1 class="title">
{% if is_self %}Your
{% if is_self %}
{% trans "Your Lists" %}
{% else %}
{% include 'snippets/username.html' with user=user %}'s
{% blocktrans with username=user.display_name %}Lists: {{ username }}{% endblocktrans %}
{% endif %}
Lists
</h1>
</div>
{% if is_self %}

View file

@ -1,14 +1,17 @@
{% extends 'user/user_layout.html' %}
{% load bookwyrm_tags %}
{% load i18n %}
{% block title %}{% blocktrans with username=user.display_name %}Shelves: {{ username }}{% endblocktrans %}{% endblock %}
{% block header %}
<header class="columns">
<h1 class="title">
{% if is_self %}Your
{% if is_self %}
{% trans "Your Shelves" %}
{% else %}
{% include 'snippets/username.html' with user=user possessive=True %}
{% blocktrans with username=user.display_name %}{{ username }}: Shelves{% endblocktrans %}
{% endif %}
shelves
</h1>
</header>
{% endblock %}
@ -29,7 +32,8 @@
{% if is_self %}
<div class="column is-narrow">
{% include 'snippets/toggle/open_button.html' with text="Create shelf" icon="plus" controls_text="create-shelf-form" focus="create-shelf-form-header" %}
{% trans "Create Shelf" as button_text %}
{% include 'snippets/toggle/open_button.html' with text=button_text icon="plus" controls_text="create-shelf-form" focus="create-shelf-form-header" %}
</div>
{% endif %}
</div>

View file

@ -1,10 +1,12 @@
{% extends 'user/user_layout.html' %}
{% load i18n %}
{% block title %}{{ user.name }}{% endblock %}
{% block header %}
<div class="columns is-mobile">
<div class="column">
<h1 class="title">{% trans "User profile" %}</h1>
<h1 class="title">{% trans "User Profile" %}</h1>
</div>
{% if is_self %}
<div class="column is-narrow">

View file

@ -3,6 +3,8 @@
{% load humanize %}
{% load bookwyrm_tags %}
{% block title %}{{ user.display_name }}{% endblock %}
{% block content %}
<header class="block">
{% block header %}{% endblock %}

View file

@ -21,7 +21,6 @@ class Login(View):
return redirect('/')
# sene user to the login page
data = {
'title': 'Login',
'login_form': forms.LoginForm(),
'register_form': forms.RegisterForm(),
}

View file

@ -24,7 +24,6 @@ class Author(View):
books = models.Work.objects.filter(
Q(authors=author) | Q(editions__authors=author)).distinct()
data = {
'title': author.name,
'author': author,
'books': [b.get_default_edition() for b in books],
}
@ -41,7 +40,6 @@ class EditAuthor(View):
''' info about a book '''
author = get_object_or_404(models.Author, id=author_id)
data = {
'title': 'Edit Author',
'author': author,
'form': forms.AuthorForm(instance=author)
}
@ -54,7 +52,6 @@ class EditAuthor(View):
form = forms.AuthorForm(request.POST, request.FILES, instance=author)
if not form.is_valid():
data = {
'title': 'Edit Author',
'author': author,
'form': form
}

View file

@ -15,8 +15,7 @@ class Block(View):
''' blocking users '''
def get(self, request):
''' list of blocked users? '''
return TemplateResponse(
request, 'preferences/blocks.html', {'title': 'Blocked Users'})
return TemplateResponse(request, 'preferences/blocks.html')
def post(self, request, user_id):
''' block a user '''

View file

@ -82,7 +82,6 @@ class Book(View):
)
data = {
'title': book.title,
'book': book,
'reviews': reviews_page,
'review_count': reviews.count(),
@ -113,7 +112,6 @@ class EditBook(View):
if not book.description:
book.description = book.parent_work.description
data = {
'title': 'Edit Book',
'book': book,
'form': forms.EditionForm(instance=book)
}
@ -126,7 +124,6 @@ class EditBook(View):
form = forms.EditionForm(request.POST, request.FILES, instance=book)
if not form.is_valid():
data = {
'title': 'Edit Book',
'book': book,
'form': form
}
@ -146,7 +143,6 @@ class Editions(View):
return ActivitypubResponse(work.to_edition_list(**request.GET))
data = {
'title': 'Editions of %s' % work.title,
'editions': work.editions.order_by('-edition_rank').all(),
'work': work,
}

View file

@ -3,11 +3,9 @@ from django.template.response import TemplateResponse
def server_error_page(request):
''' 500 errors '''
return TemplateResponse(
request, 'error.html', {'title': 'Oops!'}, status=500)
return TemplateResponse(request, 'error.html', status=500)
def not_found_page(request, _):
''' 404s '''
return TemplateResponse(
request, 'notfound.html', {'title': 'Not found'}, status=404)
return TemplateResponse(request, 'notfound.html', status=404)

View file

@ -17,8 +17,5 @@ class Federation(View):
def get(self, request):
''' edit form '''
servers = models.FederatedServer.objects.all()
data = {
'title': 'Federated Servers',
'servers': servers
}
data = {'servers': servers}
return TemplateResponse(request, 'settings/federation.html', data)

View file

@ -38,7 +38,6 @@ class Feed(View):
paginated = Paginator(activities, PAGE_LENGTH)
data = {**feed_page_data(request.user), **{
'title': 'Updates Feed',
'user': request.user,
'activities': paginated.page(page),
'tab': tab,
@ -75,7 +74,6 @@ class DirectMessage(View):
paginated = Paginator(activities, PAGE_LENGTH)
activity_page = paginated.page(page)
data = {**feed_page_data(request.user), **{
'title': 'Direct Messages',
'user': request.user,
'partner': user,
'activities': activity_page,
@ -108,7 +106,6 @@ class Status(View):
status.to_activity(pure=not is_bookwyrm_request(request)))
data = {**feed_page_data(request.user), **{
'title': 'Status by %s' % user.username,
'status': status,
}}
return TemplateResponse(request, 'feed/status.html', data)

View file

@ -30,7 +30,6 @@ class Goal(View):
return HttpResponseNotFound()
data = {
'title': '%s\'s %d Reading' % (user.display_name, year),
'goal_form': forms.GoalForm(instance=goal),
'goal': goal,
'user': user,
@ -53,7 +52,6 @@ class Goal(View):
form = forms.GoalForm(request.POST, instance=goal)
if not form.is_valid():
data = {
'title': '%s\'s %d Reading' % (request.user.display_name, year),
'goal_form': form,
'goal': goal,
'year': year,

View file

@ -19,7 +19,6 @@ class Import(View):
def get(self, request):
''' load import page '''
return TemplateResponse(request, 'import.html', {
'title': 'Import Books',
'import_form': forms.ImportForm(),
'jobs': models.ImportJob.
objects.filter(user=request.user).order_by('-created_date'),
@ -71,7 +70,6 @@ class ImportStatus(View):
failed_items = [i for i in items if i.fail_reason]
items = [i for i in items if not i.fail_reason]
return TemplateResponse(request, 'import_status.html', {
'title': 'Import Status',
'job': job,
'items': items,
'failed_items': failed_items,

View file

@ -30,7 +30,6 @@ class ManageInvites(View):
).order_by('-created_date'), PAGE_LENGTH)
data = {
'title': 'Invitations',
'invites': paginated.page(page),
'form': forms.CreateInviteForm(),
}
@ -50,7 +49,6 @@ class ManageInvites(View):
user=request.user
).order_by('-created_date'), PAGE_LENGTH)
data = {
'title': 'Invitations',
'invites': paginated.page(1),
'form': form
}
@ -66,7 +64,6 @@ class Invite(View):
invite = get_object_or_404(models.SiteInvite, code=code)
data = {
'title': 'Join',
'register_form': forms.RegisterForm(),
'invite': invite,
'valid': invite.valid() if invite else True,

View file

@ -12,10 +12,7 @@ class About(View):
''' create invites '''
def get(self, request):
''' more information about the instance '''
data = {
'title': 'About',
}
return TemplateResponse(request, 'discover/about.html', data)
return TemplateResponse(request, 'discover/about.html')
class Home(View):
''' discover page or home feed depending on auth '''
@ -43,7 +40,6 @@ class Discover(View):
).order_by('-review__published_date__max')[:6]
data = {
'title': 'Discover',
'register_form': forms.RegisterForm(),
'books': list(set(books)),
}

View file

@ -40,7 +40,6 @@ class Lists(View):
paginated = Paginator(lists, 12)
data = {
'title': 'Lists',
'lists': paginated.page(page),
'list_form': forms.ListForm(),
'path': '/list',
@ -72,7 +71,6 @@ class UserLists(View):
paginated = Paginator(lists, 12)
data = {
'title': '%s: Lists' % user.name,
'user': user,
'is_self': request.user.id == user.id,
'lists': paginated.page(page),
@ -114,7 +112,6 @@ class List(View):
data = {
'title': '%s | Lists' % book_list.name,
'list': book_list,
'items': book_list.listitem_set.filter(approved=True),
'pending_count': book_list.listitem_set.filter(
@ -149,7 +146,6 @@ class Curate(View):
return HttpResponseNotFound()
data = {
'title': 'Curate "%s" | Lists' % book_list.name,
'list': book_list,
'pending': book_list.listitem_set.filter(approved=False),
'list_form': forms.ListForm(instance=book_list),

View file

@ -16,7 +16,6 @@ class Notifications(View):
.order_by('-created_date')
unread = [n.id for n in notifications.filter(read=False)]
data = {
'title': 'Notifications',
'notifications': notifications,
'unread': unread,
}

View file

@ -19,7 +19,6 @@ class PasswordResetRequest(View):
return TemplateResponse(
request,
'password_reset_request.html',
{'title': 'Reset Password'}
)
def post(self, request):
@ -53,11 +52,7 @@ class PasswordReset(View):
except models.PasswordReset.DoesNotExist:
raise PermissionDenied
return TemplateResponse(
request,
'password_reset.html',
{'title': 'Reset Password', 'code': reset_code.code}
)
return TemplateResponse(request, 'password_reset.html')
def post(self, request, code):
''' allow a user to change their password through an emailed token '''
@ -90,10 +85,7 @@ class ChangePassword(View):
''' change password as logged in user '''
def get(self, request):
''' change password page '''
data = {
'title': 'Change Password',
'user': request.user,
}
data = {'user': request.user}
return TemplateResponse(
request, 'preferences/change_password.html', data)

View file

@ -58,7 +58,6 @@ class Search(View):
book_results = connector_manager.search(
query, min_confidence=min_confidence)
data = {
'title': 'Search Results',
'book_results': book_results,
'user_results': user_results,
'list_results': list_results,

View file

@ -53,7 +53,6 @@ class Shelf(View):
).order_by('-updated_date').all()
data = {
'title': '%s\'s %s shelf' % (user.display_name, shelf.name),
'user': user,
'is_self': is_self,
'shelves': shelves.all(),

View file

@ -19,10 +19,7 @@ class Site(View):
def get(self, request):
''' edit form '''
site = models.SiteSettings.objects.get()
data = {
'title': 'Site Settings',
'site_form': forms.SiteForm(instance=site)
}
data = {'site_form': forms.SiteForm(instance=site)}
return TemplateResponse(request, 'settings/site.html', data)
def post(self, request):
@ -30,10 +27,7 @@ class Site(View):
site = models.SiteSettings.objects.get()
form = forms.SiteForm(request.POST, instance=site)
if not form.is_valid():
data = {
'title': 'Site Settings',
'site_form': form
}
data = {'site_form': form}
return TemplateResponse(request, 'settings/site.html', data)
form.save()

View file

@ -25,7 +25,6 @@ class Tag(View):
usertag__tag__identifier=tag_id
).distinct()
data = {
'title': tag_obj.name,
'books': books,
'tag': tag_obj,
}

View file

@ -79,7 +79,6 @@ class User(View):
if not object_visible_to_user(request.user, goal):
goal = None
data = {
'title': user.name,
'user': user,
'is_self': is_self,
'shelves': shelf_preview,
@ -108,7 +107,6 @@ class Followers(View):
user.to_followers_activity(**request.GET))
data = {
'title': '%s: followers' % user.name,
'user': user,
'is_self': request.user.id == user.id,
'followers': user.followers.all(),
@ -133,7 +131,6 @@ class Following(View):
user.to_following_activity(**request.GET))
data = {
'title': '%s: following' % user.name,
'user': user,
'is_self': request.user.id == user.id,
'following': user.following.all(),
@ -147,7 +144,6 @@ class EditUser(View):
def get(self, request):
''' edit profile page for a user '''
data = {
'title': 'Edit profile',
'form': forms.EditUserForm(instance=request.user),
'user': request.user,
}