Skip to content

Commit

Permalink
Réindente et corrige divers templates
Browse files Browse the repository at this point in the history
Fait avec https://github.com/motet-a/jinjalint.

Alors comme il n’y a pas de “styleguide” précisement documenté, j’ai essayé
de suivre le style utilisé un peu partout.

J’ai aussi corrigé une ou deux erreurs de balisage.

Notez que pour les attributs HTML sur plusieurs lignes, les deux formes
suivantes sont utilisées et tolérées :

    <canvas id="première ligne"
            style="deuxième ligne alignée avec le début de `id`"
            class="troisième ligne toujours alignée” />

    <canvas
        id="première ligne indentée de 4 espaces"
        style="deuxième ligne alignée avec le début de `id`"
        class="troisième ligne toujours alignée” />

N’hésitez pas à me dire si ce style ne vous convient pas. Ces choses sont très
subjectives et je veux juste rendre le code existant plus cohérent, et non
répandre mes goûts personnels partout.

-----------------------

Reformat and fix various templates

Done with https://github.com/motet-a/jinjalint.

Since there is no precisely defined and documented “styleguide”, I tried
to follow the same style currently in use about everywhere.

I also fixed one or two markup errors.

These two patterns are allowed for HTML attributes stretched over multiple
lines:

    <canvas id="first line"
            style="second line aligned with the beginning of `id`"
            class="third line still aligned” />

    <canvas
        id="first line shift with four spaces"
        style="second line aligned with the beginning of `id`"
        class="third line still aligned” />

Please let me know if you don’t like this indent style. These things are very
subjective and I just want to make the code more consistent, and not to
scatter my personal tastes everywhere.
  • Loading branch information
motet-a authored and artragis committed Nov 13, 2018
1 parent ae53acd commit 5c2d284
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 174 deletions.
18 changes: 9 additions & 9 deletions templates/crispy/checkboxselectmultiple.html
Expand Up @@ -13,17 +13,17 @@
<{% if tag %}{{ tag }}{% else %}div{% endif %}
id="div_{{ field.auto_id }}"
class="control-group
{% if wrapper_class %}
{{ wrapper_class }}
{% endif %}
{% if wrapper_class %}
{{ wrapper_class }}
{% endif %}

{% if form_show_errors and field.errors%}
error
{% endif %}
{% if form_show_errors and field.errors%}
error
{% endif %}

{% if field.css_classes %}
{{ field.css_classes }}
{% endif %}">
{% if field.css_classes %}
{{ field.css_classes }}
{% endif %}">

{% if field.label and not field|is_checkbox and form_show_labels %}
<label for="{{ field.id_for_label }}"
Expand Down
4 changes: 2 additions & 2 deletions templates/forum/last_topics.html
Expand Up @@ -39,14 +39,14 @@ <h3>{% trans "Ordre de tri" %}</h3>
<ul>
<li>
<a href="{% url 'last-subjects' %}?order=creation"
class="ico-after move {% if request.GET.order == 'creation' %}selected{% endif %}"
class="ico-after move {% if request.GET.order == 'creation' %}selected{% endif %}"
>
{% trans "Date de création" %}
</a>
</li>
<li>
<a href="{% url 'last-subjects' %}?order=last_post"
class="ico-after history {% if request.GET.order == 'last_post' %}selected{% endif %}"
class="ico-after history {% if request.GET.order == 'last_post' %}selected{% endif %}"
>
{% trans "Date de la dernière réponse" %}
</a>
Expand Down
158 changes: 79 additions & 79 deletions templates/gallery/gallery/details.html
Expand Up @@ -32,89 +32,89 @@

{% block content %}
<div class="authors">
{% with users=gallery.get_linked_users %}
<span class="authors-label">{% trans "Galerie partagée avec" %} : </span>
<ul>
{% for u in users %}
{% captureas info %}
{% if u.mode == 'R' %}
{% trans "Lecture" %}
{% elif u.mode == 'W' %}
{% trans "Écriture" %}
{% endif %}
{% endcaptureas %}
<li>
{% include "misc/member_item.part.html" with member=u.user avatar=True %}
</li>
{% endfor %}

{% if permissions.write and not content_linked %}
<li>
<a href="#add-user-modal" class="open-modal ico-after more blue">{% trans "Ajouter un utilisateur" %}</a>
{% crispy form %}
</li>
<li>
<a href="#edit-user-modal" class="open-modal ico-after edit blue">{% trans "Gérer les utilisateurs" %}</a>
<div id="edit-user-modal" class="modal" data-modal-close="{% trans "Fermer" %}">
{% if users|length > 1 %}
<table>
<thead>
<th>{% trans "Auteur" %}</th>
<th width="300px">{% trans "Droits" %}</th>
<th>{% trans "Suppression" %}</th>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{% include "misc/member_item.part.html" with member=u.user %}</td>
<td>
{# droits #}
{% if u.user != current_user %}
{% with users=gallery.get_linked_users %}
<span class="authors-label">{% trans "Galerie partagée avec" %} : </span>
<ul>
{% for u in users %}
{% captureas info %}
{% if u.mode == 'R' %}
{% trans "Lecture" %}
{% elif u.mode == 'W' %}
{% trans "Écriture" %}
{% endif %}
{% endcaptureas %}
<li>
{% include "misc/member_item.part.html" with member=u.user avatar=True %}
</li>
{% endfor %}

{% if permissions.write and not content_linked %}
<li>
<a href="#add-user-modal" class="open-modal ico-after more blue">{% trans "Ajouter un utilisateur" %}</a>
{% crispy form %}
</li>
<li>
<a href="#edit-user-modal" class="open-modal ico-after edit blue">{% trans "Gérer les utilisateurs" %}</a>
<div id="edit-user-modal" class="modal" data-modal-close="{% trans "Fermer" %}">
{% if users|length > 1 %}
<table>
<thead>
<th>{% trans "Auteur" %}</th>
<th width="300px">{% trans "Droits" %}</th>
<th>{% trans "Suppression" %}</th>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{% include "misc/member_item.part.html" with member=u.user %}</td>
<td>
{# droits #}
{% if u.user != current_user %}
<form action="{% url "gallery-members" gallery.pk %}" method="post">
{% csrf_token %}
<input type="hidden" name="action" value="edit">
<input type="hidden" name="user" value="{{ u.user.username }}">
<select name="mode">
{% for mode in mode_choices %}
<option value="{{ mode.0 }}"{% if u.mode == mode.0 %} selected{% endif %}>{{ mode.1 }}</option>
{% endfor %}
</select>
<button type="submit" value="{% trans "Modifier" %}" class="modal-inner btn">{% trans "Modifier" %}</button>
</form>
{% endif %}
</td>
<td>
{# suppression #}
<form action="{% url "gallery-members" gallery.pk %}" method="post">
{% csrf_token %}
<input type="hidden" name="action" value="edit">
<input type="hidden" name="action" value="leave">
<input type="hidden" name="user" value="{{ u.user.username }}">
<select name="mode">
{% for mode in mode_choices %}
<option value="{{ mode.0 }}"{% if u.mode == mode.0 %} selected{% endif %}>{{ mode.1 }}</option>
{% endfor %}
</select>
<button type="submit" value="{% trans "Modifier" %}" class="modal-inner btn">{% trans "Modifier" %}</button>
<button type="submit" class="modal-inner btn btn-cancel">
{% if u.user != current_user %}
{% trans "Supprimer" %}
{% else %}
{% trans "Quitter" %}
{% endif %}
</button>
</form>
{% endif %}
</td>
<td>
{# suppression #}
<form action="{% url "gallery-members" gallery.pk %}" method="post">
{% csrf_token %}
<input type="hidden" name="action" value="leave">
<input type="hidden" name="user" value="{{ u.user.username }}">
<button type="submit" class="modal-inner btn btn-cancel">
{% if u.user != current_user %}
{% trans "Supprimer" %}
{% else %}
{% trans "Quitter" %}
{% endif %}
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "Vous êtes seul." %}</p>
{% endif %}
<p>
<button type="submit" href="#add-user-modal" class="open-modal">
{% trans "Ajouter un utilisateur" %}
</button>
</p>
</div>
</li>
{% endif %}
</ul>
{% endwith %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "Vous êtes seul." %}</p>
{% endif %}
<p>
<button type="submit" href="#add-user-modal" class="open-modal">
{% trans "Ajouter un utilisateur" %}
</button>
</p>
</div>
</li>
{% endif %}
</ul>
{% endwith %}
</div>

{% if images %}
Expand Down
43 changes: 23 additions & 20 deletions templates/header.html
Expand Up @@ -25,7 +25,10 @@
</div>

{# Menu #}
<nav class="header-menu" id="menu" data-title="Menu"
<nav
class="header-menu"
id="menu"
data-title="Menu"
{% if user.is_authenticated and user.profile.is_hover_enabled %}
data-hovering-mode
{% endif %}
Expand All @@ -39,10 +42,10 @@
<span class="arrow"></span>
</a>

{% cache 1800 menu_publications user|groups %}
{% cache 1800 menu_publications user|groups %}
<div class="dropdown header-menu-dropdown">
<a href="{% url "publication:list" %}" class="dropdown-link-all">
{% trans "Accéder à tous les contenus de la bibliothèque" %}
<a href="{% url "publication:list" %}" class="dropdown-link-all">
{% trans "Accéder à tous les contenus de la bibliothèque" %}
</a>

<ul class="dropdown-list">
Expand All @@ -54,9 +57,9 @@
<li class="dropdown-title">
{{ title }}
</li>
{% for subcat, slug, parent_slug in subcats %}
{% for subcat, slug, parent_slug in subcats %}
<li>
<a href="{% url 'publication:subcategory' slug_category=parent_slug slug=slug %}">
<a href="{% url 'publication:subcategory' slug_category=parent_slug slug=slug %}">
{{ subcat }}
</a>
</li>
Expand Down Expand Up @@ -109,7 +112,7 @@
<li class="dropdown-title">
{{ title }}
</li>
{% for subcat, slug, parent_slug in subcats %}
{% for subcat, slug, parent_slug in subcats %}
<li>
<a href="{% url "opinion:list" %}?category={{ slug }}">
{{ subcat }}
Expand Down Expand Up @@ -217,24 +220,24 @@
<span class="dropdown-title dropdown-pm">
{% trans "Messagerie privée" %}
<a href="{% url "mp-new" %}" class="ico-after pm-new white" title="{% trans 'Envoyer un nouveau message privé' %}"></a>
</span>
</span>

<ul class="dropdown-list">
{% for notification in header_private_topic_notifications.list %}
<li>
<a href="{{ notification.url }}">
<img src="{{ notification.sender.profile.get_avatar_url|remove_url_scheme }}" alt="" class="avatar">
<span class="username">{{ notification.sender.username }}</span>
<span class="date">{{ notification.pubdate|format_date:True|capfirst }}</span>
<span class="topic">{{ notification.title }}</span>
</a>
</li>
<li>
<a href="{{ notification.url }}">
<img src="{{ notification.sender.profile.get_avatar_url|remove_url_scheme }}" alt="" class="avatar">
<span class="username">{{ notification.sender.username }}</span>
<span class="date">{{ notification.pubdate|format_date:True|capfirst }}</span>
<span class="topic">{{ notification.title }}</span>
</a>
</li>
{% endfor %}

{% if header_private_topic_notifications.total == 0 %}
<li class="dropdown-empty-message">
{% trans "Aucun nouveau message" %}
</li>
<li class="dropdown-empty-message">
{% trans "Aucun nouveau message" %}
</li>
{% endif %}
</ul>
<a href="{% url "mp-list" %}" class="dropdown-link-all">
Expand Down Expand Up @@ -421,7 +424,7 @@
>
{% csrf_token %}
<button type="submit">{% trans "Déconnexion" %}</button>
</form>
</form>
</li>

</ul>
Expand Down
12 changes: 6 additions & 6 deletions templates/home.html
Expand Up @@ -84,7 +84,7 @@ <h2>{% trans "… sur une plate-forme libre" %}</h2>
</section>
{% endif %}
{% if app.display_search_bar %}
<section class="search-box">
<section class="search-box">
{% crispy search_form %}
</section>
{% endif %}
Expand Down Expand Up @@ -176,11 +176,11 @@ <h2 class="home-heading ico-after ico-forum" itemprop="name">
<meta itemprop="itemListOrder" content="Descending">

<div class="content-item-list">
{% for topic in last_topics %}
{% include 'forum/includes/topic_item.part.html' %}
{% empty %}
<p>{% trans "Aucun sujet disponible." %}</p>
{% endfor %}
{% for topic in last_topics %}
{% include 'forum/includes/topic_item.part.html' %}
{% empty %}
<p>{% trans "Aucun sujet disponible." %}</p>
{% endfor %}
</div>
</section>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/member/settings/solved_hat_requests.html
Expand Up @@ -53,7 +53,7 @@
</td>
<td>{% include 'misc/member_item.part.html' with member=request.user avatar=True %}</td>
<td>{{ request.is_granted|yesno:_('Acceptée,Refusée') }}</td>
<td class="wide">{% include 'misc/member_item.part.html' with member=request.moderator avatar=True %}
<td class="wide">{% include 'misc/member_item.part.html' with member=request.moderator avatar=True %}</td>
<td class="wide">{{ request.solved_at|format_date:True|capfirst }}</td>
</tr>
{% endfor %}
Expand Down
9 changes: 7 additions & 2 deletions templates/misc/graph.part.html
Expand Up @@ -5,8 +5,13 @@
<div id="{{ tab_name }}" class="tabcontent">
<div class="stat-graph">
<h3>{% trans graph_title %}</h3>
<canvas id="{{ canvas_id }}" {% for url in stats %} data-views-{{ forloop.counter0 }}="[{% for view in url.stats|dict_get:metric %}{{view|dict_get:metric}} {% if not forloop.last %},{% endif %}{% endfor %}]"
data-label-views-{{ forloop.counter0 }}="{{url.label}}" {% endfor %} data-time='[{% for view in stats.0.stats|dict_get:metric %}"{{view.date}}"{% if not forloop.last %},{% endif %} {% endfor %}]'>
<canvas
id="{{ canvas_id }}"
{% for url in stats %}
data-views-{{ forloop.counter0 }}="[{% for view in url.stats|dict_get:metric %}{{view|dict_get:metric}} {% if not forloop.last %},{% endif %}{% endfor %}]"
data-label-views-{{ forloop.counter0 }}="{{url.label}}"
{% endfor %}
data-time='[{% for view in stats.0.stats|dict_get:metric %}"{{view.date}}"{% if not forloop.last %},{% endif %} {% endfor %}]'>
</canvas>
</div>
</div>

0 comments on commit 5c2d284

Please sign in to comment.