Skip to content

Commit

Permalink
Merge branch 'main' into docs-pat
Browse files Browse the repository at this point in the history
  • Loading branch information
orangesunny authored Oct 23, 2024
2 parents 3171692 + b25e165 commit 16a801b
Show file tree
Hide file tree
Showing 91 changed files with 324 additions and 311 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ repos:
rev: v0.21
hooks:
- id: validate-pyproject
- repo: https://github.com/djlint/djLint
rev: v1.35.2
hooks:
- id: djlint-django
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
19 changes: 0 additions & 19 deletions docs/_templates/footer.html

This file was deleted.

16 changes: 0 additions & 16 deletions docs/_templates/layout.html

This file was deleted.

5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def setup(app) -> None:
},
}

html_css_files = [
"https://s.weblate.org/cdn/font-source/source-sans-3.css",
"https://s.weblate.org/cdn/font-source/source-code-pro.css",
]

# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,26 @@ strict_settings = false

[tool.djlint]
blank_line_after_tag = "load,extends,endblock"
# - reconsider T032 and H014 once formatter is in use
# T003 - Endblock should have name.
# T002 - Double quotes should be used in tags. (makes using tags in attributes hard)
# H013 - Img tag should have an alt attribute.
# H006 - Img tag should have height and width attributes.
# H021 - Inline styles should be avoided.
# H031 - Consider adding meta keywords.
ignore = "T003,H014,T032,T002,H013,H006,H021,H031"
indent = 2
max_attribute_length = 80
max_blank_lines = 2
preserve_blank_lines = true
profile = "django"

[tool.djlint.per-file-ignores]
# Mail templates need inline CSS and do not utilize description
"weblate/templates/mail/base.html" = "H030"
# Test file
"weblate/trans/tests/data/cs.html" = "H005,H007,H016,H030"

[tool.mypy]
check_untyped_defs = true
plugins = [
Expand Down
1 change: 1 addition & 0 deletions weblate/accounts/templatetags/authnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"twitter": {"name": "Twitter", "image": "twitter.svg"},
"stackoverflow": {"name": "Stack Overflow", "image": "stackoverflow.svg"},
"musicbrainz": {"name": "MusicBrainz", "image": "musicbrainz.svg"},
"openinfra": {"name": "OpenInfraID"},
}

SECOND_FACTORS: dict[DeviceType, StrOrPromise] = {
Expand Down
1 change: 0 additions & 1 deletion weblate/legal/templates/legal/cookies.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
{% endif %}
</ul>

</div>
</div>
</div>

Expand Down
9 changes: 4 additions & 5 deletions weblate/legal/templates/legal/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
{% include 'legal/menu.html' %}

<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Terms of Service" %}</h4></div>
<div class="panel-body tos">
<div class="panel-heading"><h4 class="panel-title">{% trans "Terms of Service" %}</h4></div>
<div class="panel-body tos">

{% include "legal/documents/tos.html" %}
{% include "legal/documents/tos.html" %}

</div>
</div>
</div>
</div>

{% endblock %}
14 changes: 12 additions & 2 deletions weblate/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from weblate.auth.models import AuthenticatedHttpRequest, get_auth_backends
from weblate.lang.models import Language
from weblate.logger import LOGGER
from weblate.trans.models import Change, Component, Project
from weblate.utils.errors import report_error
from weblate.utils.site import get_site_url
Expand Down Expand Up @@ -324,9 +325,18 @@ def apply_csp_settings(self) -> None:

def add_csp_host(self, url: str, *directives: CSP_KIND) -> None | str:
domain = urlparse(url).hostname
# Handle domain only URLs (OpenInfraOpenId uses that)
if not domain and ":" not in url and "/" not in url:
domain = url
if domain:
for directive in directives:
self.directives[directive].add(domain)
else:
LOGGER.error(
"could not parse domain from '%s', not adding to Content-Security-Policy",
url,
)

return domain

def build_csp_redoc(self) -> None:
Expand Down Expand Up @@ -435,11 +445,11 @@ def build_csp_auth(self) -> None:
urls = [backend(social_strategy).openid_url()]

# Handle OAuth redirect flow
if issubclass(backend, OAuthAuth):
elif issubclass(backend, OAuthAuth):
urls = [backend(social_strategy).authorization_url()]

# Handle SAML redirect flow
if hasattr(backend, "get_idp"):
elif hasattr(backend, "get_idp"):
# Lazily import here to avoid pulling in xmlsec
from social_core.backends.saml import SAMLAuth

Expand Down
2 changes: 1 addition & 1 deletion weblate/templates/about/donate.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2>
{% else %}
<strong>{% trans "Welcome and thank you for choosing Weblate" %}</strong>
{% endif %}
&mdash;
{% trans "the privacy-respecting localization platform committed to open-source values." %}
</h2>

Expand Down
3 changes: 2 additions & 1 deletion weblate/templates/accounts/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<a data-toggle="tab" href="#{{ form.prefix }}">
{{ form.get_name }}
{% if form.removable %}
<button type="button" class="close" title="{% trans "Remove this notification setting" %}"><span aria-hidden="true">&times;</span></button>
<button type="button" class="close" title="{% trans "Remove this notification setting" %}"><span aria-hidden="true">×</span></button>
{% endif %}
</a>
</li>
Expand Down Expand Up @@ -532,6 +532,7 @@ <h4>
</div>

</div>
</div>


</form>
Expand Down
2 changes: 1 addition & 1 deletion weblate/templates/accounts/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{% endif %}

{% if form.errors %}
{% trans "Please fix errors in the registration form." as msg%}
{% trans "Please fix errors in the registration form." as msg %}
{% show_message "error" msg %}
{% endif %}

Expand Down
25 changes: 12 additions & 13 deletions weblate/templates/accounts/removal.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Account removal" %}</h4></div>
<div class="panel-body">
{{ confirm_form|crispy }}
<p>{% trans "Account removal deletes all your private data." %}</p>
{% if is_confirmation %}
<p>{% blocktrans %}By pressing following button, your will no longer be able to use this account.{% endblocktrans %}</p>
{% else %}
<p>{% blocktrans %}You will have to confirm account removal by clicking link in e-mail you will receive.{% endblocktrans %}</p>
{% endif %}
{% csrf_token %}
</div>
<div class="panel-footer">
<button type="submit" class="btn btn-danger">{% trans "Delete this account" %}</button>
{{ confirm_form|crispy }}
<p>{% trans "Account removal deletes all your private data." %}</p>
{% if is_confirmation %}
<p>{% blocktrans %}By pressing following button, your will no longer be able to use this account.{% endblocktrans %}</p>
{% else %}
<p>{% blocktrans %}You will have to confirm account removal by clicking link in e-mail you will receive.{% endblocktrans %}</p>
{% endif %}
{% csrf_token %}
</div>
<div class="panel-footer">
<button type="submit" class="btn btn-danger">{% trans "Delete this account" %}</button>
</div>
</div>
</form>
</div>
</div>

{% endblock %}
2 changes: 1 addition & 1 deletion weblate/templates/accounts/token.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{% trans "Redirecting you to the authentication provider." as msg %}
{% show_message "info" msg %}

<a href="" class="btn btn-link link-auto link-post" data-href="{% url 'social:complete' backend %}?partial_token={{ partial_token}}&amp;verification_code={{verification_code}}&amp;confirm=1">{% auth_name backend %}</a>
<a href="" class="btn btn-link link-auto link-post" data-href="{% url 'social:complete' backend %}?partial_token={{ partial_token }}&amp;verification_code={{ verification_code }}&amp;confirm=1">{% auth_name backend %}</a>

{% endblock %}
11 changes: 5 additions & 6 deletions weblate/templates/accounts/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ <h3>{{ page_user }}</h3>

<div class="tab-pane active" id="contributed">
<div class="list-group">
{% include "snippets/list-objects.html" with objects=page_user_translations label=_("Translation") show_admin_badge=True name_source="translation" empty_message=_("No recent contributions found.")%}
{% include "snippets/list-objects.html" with objects=page_user_translations label=_("Translation") show_admin_badge=True name_source="translation" empty_message=_("No recent contributions found.") %}
<a href="{% url 'user_contributions' user=page_user.username %}" class="btn btn-primary">{% trans "Browse all translations with contribution" %}</a>
</div>
</div>
Expand All @@ -177,7 +177,7 @@ <h3>{{ page_user }}</h3>
<div class="list-group">
{% include "list-projects.html" with projects=page_owned_projects %}
{% if page_owned_projects_more %}
<a href="{% url 'projects' %}?owned={{page_user.username}}" class="btn btn-primary">{% trans "Browse all managed projects" %}</a>
<a href="{% url 'projects' %}?owned={{ page_user.username }}" class="btn btn-primary">{% trans "Browse all managed projects" %}</a>
{% endif %}
</div>
</div>
Expand All @@ -186,7 +186,7 @@ <h3>{{ page_user }}</h3>
<div class="list-group">
{% include "list-projects.html" with projects=page_watched_projects %}
{% if page_watched_projects_more %}
<a href="{% url 'projects' %}?watched={{page_user.username}}" class="btn btn-primary">{% trans "Browse all watched projects" %}</a>
<a href="{% url 'projects' %}?watched={{ page_user.username }}" class="btn btn-primary">{% trans "Browse all watched projects" %}</a>
{% endif %}
</div>
</div>
Expand Down Expand Up @@ -261,7 +261,6 @@ <h3>{{ page_user }}</h3>
{% include "billing/list.html" with objects=billings show_expiry=1 show_removal=1 %}
</div>
{% endif %}
</tr>

<div class="tab-pane" id="audit">
<table class="table table-listing">
Expand Down Expand Up @@ -307,7 +306,7 @@ <h3>{{ page_user }}</h3>
<th>{{ group.name }}</th>
<td class="number">{{ group.user__count }}</td>
<td>
<a href="" class="btn btn-link btn-xs red link-post" data-href="{{ page_user.get_absolute_url }}" data-params='{"remove_group": {{ group.pk }}}' title="{% trans "Remove user from this team" %}">
<a href="" class="btn btn-link btn-xs red link-post" data-href="{{ page_user.get_absolute_url }}" data-params='{"remove_group": {{ group.pk }} }' title="{% trans "Remove user from this team" %}">
{% icon 'delete.svg' %}
</a>
</td>
Expand Down Expand Up @@ -380,7 +379,7 @@ <h4 class="panel-title">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans "Close" %}"><span aria-hidden="true">&times;</span></button>
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans "Close" %}"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">{% trans "Are you absolutely sure?" %}</h4>
</div>
<div class="modal-body">
Expand Down
10 changes: 7 additions & 3 deletions weblate/templates/addons/addon_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% include 'addons/addon_head.html' with addon=addon.addon %}
</td>
<td class="bottom-button">
<form method="POST" action="{{ addon.get_absolute_url }}" class="inlineform">{% csrf_token %}<input type="hidden" name="delete" value="{{ addon.name }}" /><button type="submit" class="btn btn-danger">{% trans "Uninstall" %}</button></form>
<form method="post" action="{{ addon.get_absolute_url }}" class="inlineform">{% csrf_token %}<input type="hidden" name="delete" value="{{ addon.name }}" /><button type="submit" class="btn btn-danger">{% trans "Uninstall" %}</button></form>
<a class="btn btn-primary" href="{% url 'addon-logs' addon.id %}">{% trans "View Logs" %}</a>
{% if addon.addon.has_settings %}
<a class="btn btn-primary" href="{{ addon.get_absolute_url }}">{% trans "Configure" %}</a>
Expand Down Expand Up @@ -85,7 +85,11 @@
{% if scope != "component" and addon.needs_component %}
<button class="btn btn-primary" disabled title="{% trans "The add-on can only be installed on the component." %}">{% trans "Install" %}</button>
{% else %}
<form method="POST" class="inlineform">{% csrf_token %}<input type="hidden" name="name" value="{{ addon.name }}" /><button type="submit" class="btn btn-primary" data-addon="{{ addon.name }}">{% trans "Install" %}</button></form>
<form method="post" class="inlineform">
{% csrf_token %}
<input type="hidden" name="name" value="{{ addon.name }}" />
<button type="submit" class="btn btn-primary" data-addon="{{ addon.name }}">{% trans "Install" %}</button>
</form>
{% endif %}
</td>
</tr>
Expand All @@ -104,7 +108,7 @@

<div class="tab-pane" id="history">
{% include "last-changes-content.html" %}
<a class="btn btn-primary" href="{% if object %}{% url 'changes' path=object.get_url_path %}{% else %}{% url 'changes' %}{% endif %}?{% for action in change_actions %}action={{action}}{% if not forloop.last %}&amp;{% endif %}{% endfor %}">{% trans "Browse all add-on changes" %}</a>
<a class="btn btn-primary" href="{% if object %}{% url 'changes' path=object.get_url_path %}{% else %}{% url 'changes' %}{% endif %}?{% for action in change_actions %}action={{ action }}{% if not forloop.last %}&amp;{% endif %}{% endfor %}">{% trans "Browse all add-on changes" %}</a>
</div>

</div>
Expand Down
8 changes: 4 additions & 4 deletions weblate/templates/addons/addon_logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ <h4 class="panel-title">{% trans "Add-on Activity Logs" %}</h4>
<td>
{% if log.details.error_occured %}
<!-- This is a warning sign -->
<span class="text-danger">&#9888;</span>
<span class="text-danger"></span>
{% else %}
<!-- This is a green tick -->
<span class="text-success">&#10004;</span>
<span class="text-success"></span>
{% endif %}
</td>
<td>
Expand All @@ -68,10 +68,10 @@ <h4 class="panel-title">{% trans "Add-on Activity Logs" %}</h4>
<nav>
<ul class="pagination">
{% if addon_activity_log.has_previous %}
<li><a href="?page={{ addon_activity_log.previous_page_number }}">&laquo; {% trans "Previous" %}</a></li>
<li><a href="?page={{ addon_activity_log.previous_page_number }}">« {% trans "Previous" %}</a></li>
{% endif %}
{% if addon_activity_log.has_next %}
<li><a href="?page={{ addon_activity_log.next_page_number }}">{% trans "Next" %} &raquo;</a></li>
<li><a href="?page={{ addon_activity_log.next_page_number }}">{% trans "Next" %} »</a></li>
{% endif %}
</ul>
</nav>
Expand Down
10 changes: 5 additions & 5 deletions weblate/templates/auth/team.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% block content %}
{% perm "meta:team.users" object as user_can_edit_team_users %}

<form method="POST">
<form method="post">
{% csrf_token %}
<ul class="nav nav-pills">
<li role="presentation" class="active"><a href="#basic" role="tab" data-toggle="tab">{% trans "Settings" %}</a></li>
Expand Down Expand Up @@ -132,7 +132,7 @@ <h4 class="panel-title">
</table>
{% if users.paginator.num_pages > 1 %}
<div class="panel-footer">
{% include "paginator.html" with page_obj=users anchor="users" paginator_form="paginator-form"%}
{% include "paginator.html" with page_obj=users anchor="users" paginator_form="paginator-form" %}
</div>
{% endif %}
<div class="panel-footer">
Expand All @@ -156,7 +156,7 @@ <h4 class="panel-title">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans "Close" %}"><span aria-hidden="true">&times;</span></button>
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans "Close" %}"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">{% trans "Are you absolutely sure?" %}</h4>
</div>
<div class="modal-body">
Expand All @@ -177,7 +177,7 @@ <h4 class="modal-title">{% trans "Are you absolutely sure?" %}</h4>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans "Close" %}"><span aria-hidden="true">&times;</span></button>
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans "Close" %}"><span aria-hidden="true">×</span></button>
{% trans "Add a user" %}
{% documentation_icon 'admin/access' 'invite-user' %}
</div>
Expand All @@ -191,5 +191,5 @@ <h4 class="modal-title">{% trans "Are you absolutely sure?" %}</h4>
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</form>
<form method="GET" id="paginator-form"></form>
<form method="get" id="paginator-form"></form>
{% endblock %}
Loading

0 comments on commit 16a801b

Please sign in to comment.