Skip to content

Commit

Permalink
templates: use shared breadcrumb renderer
Browse files Browse the repository at this point in the history
This will make projectlanguge and category work consistently at all
levels.

Issue #263
  • Loading branch information
nijel committed Aug 16, 2023
1 parent 0c0de71 commit 02ee900
Show file tree
Hide file tree
Showing 22 changed files with 33 additions and 72 deletions.
3 changes: 1 addition & 2 deletions weblate/templates/addons/addon_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{% load permissions %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}
<li><a href="{% url 'addons' path=object.get_url_path %}">{% trans "Add-ons" %}</a></li>
<li>
{% if instance %}
Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/addons/addon_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{% load permissions %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}
<li><a href="{% url 'addons' path=object.get_url_path %}">{% trans "Add-ons" %}</a></li>
{% endblock %}

Expand Down
7 changes: 2 additions & 5 deletions weblate/templates/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
{% endblock %}

{% block breadcrumbs %}
<li><a href="{{ project.get_absolute_url }}">{{ project }}</a></li>
{% if object.component.slug != "-" %}
{% include "snippets/component-breadcrumb.html" with object=object.component %}
{% endif %}
{% include "snippets/translation-breadcrumb.html" %}
{% path_object_breadcrumbs object %}

<li><a href="{% url 'browse' path=object.get_url_path %}">{% trans "Browse" %}</a></li>
<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' path=object.get_url_path widget='svg' color='badge' extension='svg' %}?native=1" />
Expand Down
4 changes: 2 additions & 2 deletions weblate/templates/component-progress.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{% load permissions %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}

<li><a href="{% url 'component_progress' path=object.get_url_path %}">{% trans "Progress" %}</a></li>
{% endblock %}

Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/component-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
{% load crispy_forms_tags %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}
<li><a href="{% url 'settings' path=object.get_url_path %}">{% trans "Settings" %}</a></li>
{% endblock %}

Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
{% load metrics %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs path_object %}

<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' path=object.get_url_path widget='svg' color='badge' extension='svg' %}?native=1" />
Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/contributor-agreement.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
{% load crispy_forms_tags %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}
<li><a href="{% url 'contributor-agreement' path=object.get_url_path %}">{% trans "Contributor agreement" %}</a></li>
{% endblock %}

Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{% load icons %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs path_object %}
<li><a href="{% url 'guide' path=object.get_url_path %}">{% trans "Community localization checklist" %}</a></li>

<a class="pull-right flip" href="{{ object.get_widgets_url }}">
Expand Down
4 changes: 2 additions & 2 deletions weblate/templates/matrix.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{% load i18n %}
{% load crispy_forms_tags %}
{% load icons %}
{% load translations %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}
<li><a href="{% url 'matrix' path=object.get_url_path %}">{% trans "Matrix" %}</a></li>
{% endblock %}

Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/new-language.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{% load crispy_forms_tags %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs path_object %}
{% endblock %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion weblate/templates/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% load metrics %}

{% block breadcrumbs %}
<li><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
{% path_object_breadcrumbs path_object %}

<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' path=object.get_url_path widget='svg' color='badge' extension='svg' %}?native=1" />
Expand Down
13 changes: 1 addition & 12 deletions weblate/templates/replace.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
{% load icons %}

{% block breadcrumbs %}
<li><a href="{{ project.get_absolute_url }}">{{ project.name }}</a></li>
{% if component %}
{% include "snippets/component-breadcrumb.html" with object=component %}
{% if translation %}
{% include "snippets/translation-breadcrumb.html" with object=translation %}
{% endif %}
{% elif language %}
<li>
<a href="{{ language.get_absolute_url }}">{{ language }}</a>
</li>

{% endif %}
{% path_object_breadcrumbs path_object %}
<li>{% trans "Search and replace" %}</li>
{% endblock %}

Expand Down
3 changes: 1 addition & 2 deletions weblate/templates/screenshots/screenshot_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
{% load icons %}

{% block breadcrumbs %}
<li><a href="{{ object.translation.component.project.get_absolute_url }}">{{ object.translation.component.project }}</a></li>
{% include "snippets/component-breadcrumb.html" with object=object.translation.component %}
{% path_object_breadcrumbs object.translation.component %}
<li><a href="{% url 'screenshots' path=object.translation.component.get_url_path %}">{% trans "Screenshots" %}</a></li>
<li><a href="{{ object.get_absolute_url }}">{{ object.name }}</a></li>
{% endblock %}
Expand Down
4 changes: 2 additions & 2 deletions weblate/templates/screenshots/screenshot_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{% load crispy_forms_tags %}
{% load humanize %}
{% load icons %}
{% load translations %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
{% include "snippets/component-breadcrumb.html" %}
{% path_object_breadcrumbs object %}
<li><a href="{% url 'screenshots' path=object.get_url_path %}">{% trans "Screenshots" %}</a></li>
{% endblock %}

Expand Down
6 changes: 0 additions & 6 deletions weblate/templates/snippets/component-breadcrumb.html

This file was deleted.

9 changes: 0 additions & 9 deletions weblate/templates/snippets/translation-breadcrumb.html

This file was deleted.

9 changes: 1 addition & 8 deletions weblate/templates/translate.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@
{% endblock %}

{% block breadcrumbs %}
<li><a href="{{ project.get_absolute_url }}">{{ project }}</a></li>
{% if object.component.slug != "-" %}
{% include "snippets/component-breadcrumb.html" with object=object.component %}
{% endif %}
{% include "snippets/translation-breadcrumb.html" %}
{% if object.component.slug == "-" %}
<li><a href="{{ unit.translation.component.get_absolute_url }}">{{ unit.translation.component.name }}</a></li>
{% endif %}
{% path_object_breadcrumbs path_object %}
<li><a href="{{ object.get_translate_url }}">{% trans "Translate" %}</a></li>
<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' path=object.get_url_path widget='svg' color='badge' extension='svg' %}?native=1" />
Expand Down
5 changes: 2 additions & 3 deletions weblate/templates/translation.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
{% load metrics %}

{% block breadcrumbs %}
<li><a href="{{ object.component.project.get_absolute_url }}">{{ object.component.project }}</a></li>
{% include "snippets/component-breadcrumb.html" with object=object.component %}
{% include "snippets/translation-breadcrumb.html" %}
{% path_object_breadcrumbs path_object %}

<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' path=object.get_url_path widget='svg' color='badge' extension='svg' %}?native=1" />
</a>
Expand Down
6 changes: 1 addition & 5 deletions weblate/templates/zen.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
{% endblock %}

{% block breadcrumbs %}
<li><a href="{{ project.get_absolute_url }}">{{ project }}</a></li>
{% if object.component.slug != "-" %}
{% include "snippets/component-breadcrumb.html" with object=object.component %}
{% endif %}
{% include "snippets/translation-breadcrumb.html" %}
{% path_object_breadcrumbs path_object %}
<li><a href="{% url 'zen' path=object.get_url_path %}">{% trans "Zen" %}</a></li>
<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' path=object.get_url_path widget='svg' color='badge' extension='svg' %}?native=1" />
Expand Down
6 changes: 6 additions & 0 deletions weblate/trans/views/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def show_engage(request, path):
{
"allow_index": True,
"object": obj,
"path_object": obj,
"project": project,
"full_stats": obj.stats,
"languages": stats_obj.languages,
Expand Down Expand Up @@ -211,6 +212,7 @@ def show_project(request, obj):
{
"allow_index": True,
"object": obj,
"path_object": obj,
"project": obj,
"last_changes": last_changes,
"last_announcements": last_announcements,
Expand Down Expand Up @@ -272,6 +274,7 @@ def show_component(request, obj):
{
"allow_index": True,
"object": obj,
"path_object": obj,
"project": obj.project,
"component": obj,
"translations": translations,
Expand Down Expand Up @@ -358,6 +361,7 @@ def show_translation(request, obj):
"translation.html",
{
"allow_index": True,
"path_object": obj,
"object": obj,
"project": project,
"component": obj.component,
Expand Down Expand Up @@ -484,6 +488,7 @@ def new_language(request, path):
"new-language.html",
{
"object": obj,
"path_object": obj,
"project": obj.project,
"component": obj,
"form": form,
Expand Down Expand Up @@ -526,6 +531,7 @@ def guide(request, path):
"guide.html",
{
"object": obj,
"path_object": obj,
"project": obj.project,
"component": obj,
"guidelines": obj.guidelines,
Expand Down
4 changes: 4 additions & 0 deletions weblate/trans/views/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def translate(request, path): # noqa: C901
request,
"translate.html",
{
"path_object": obj,
"this_unit_url": this_unit_url,
"first_unit_url": base_unit_url + "1",
"last_unit_url": base_unit_url + str(num_results),
Expand Down Expand Up @@ -864,6 +865,7 @@ def zen(request, path):
"zen.html",
{
"object": obj,
"path_object": obj,
"project": project,
"component": obj.component
if not isinstance(obj, ProjectLanguage)
Expand Down Expand Up @@ -901,6 +903,7 @@ def load_zen(request, path):
"zen-units.html",
{
"object": obj,
"path_object": obj,
"project": project,
"component": obj.component
if not isinstance(obj, ProjectLanguage)
Expand Down Expand Up @@ -1032,6 +1035,7 @@ def browse(request, path):
"browse.html",
{
"object": obj,
"path_object": obj,
"project": project,
"component": getattr(obj, "component", None),
"units": units,
Expand Down
2 changes: 1 addition & 1 deletion weblate/utils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def parse_path(
def parse_path_units(request, path: list[str], types: tuple[Any]):
obj = parse_path(request, path, types)

context = {"components": None}
context = {"components": None, "path_object": obj}
if isinstance(obj, Translation):
unit_set = obj.unit_set.all()
context["translation"] = obj
Expand Down

0 comments on commit 02ee900

Please sign in to comment.