Skip to content

Commit

Permalink
Add djhtml to pre-commit check (jointakahe#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuuji3 authored Jan 9, 2023
1 parent 024d956 commit 0c1e513
Show file tree
Hide file tree
Showing 38 changed files with 776 additions and 763 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ repos:
types-cachetools,
types-python-dateutil,
]

- repo: https://github.com/rtts/djhtml
rev: v1.5.2
hooks:
- id: djhtml
- id: djcss
- id: djjs
24 changes: 12 additions & 12 deletions docs/_templates/sidebar/brand.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<a class="sidebar-brand{% if logo %} centered{% endif %}" href="{{ pathto(master_doc) }}">
{% block brand_content %}
{%- if logo_url %}
<div class="sidebar-logo-container">
<img class="sidebar-logo" src="{{ logo_url }}" alt="Takahē"/>
</div>
{%- endif %}
{%- if theme_light_logo and theme_dark_logo %}
<div class="sidebar-logo-container">
<img class="sidebar-logo only-light" src="{{ pathto('_static/' + theme_light_logo, 1) }}" alt="Light Logo"/>
<img class="sidebar-logo only-dark" src="{{ pathto('_static/' + theme_dark_logo, 1) }}" alt="Dark Logo"/>
</div>
{%- endif %}
{%- if logo_url %}
<div class="sidebar-logo-container">
<img class="sidebar-logo" src="{{ logo_url }}" alt="Takahē"/>
</div>
{%- endif %}
{%- if theme_light_logo and theme_dark_logo %}
<div class="sidebar-logo-container">
<img class="sidebar-logo only-light" src="{{ pathto('_static/' + theme_light_logo, 1) }}" alt="Light Logo"/>
<img class="sidebar-logo only-dark" src="{{ pathto('_static/' + theme_dark_logo, 1) }}" alt="Dark Logo"/>
</div>
{%- endif %}
{% endblock brand_content %}
</a>
</a>
<div class="sidebar-tree" style="margin-top:0">
<ul>
<li class="toctree-l1"><a class="reference" href="https://jointakahe.org">Homepage</a></li>
Expand Down
6 changes: 3 additions & 3 deletions templates/activities/_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</a> liked your post
</div>
{% if not event.collapsed %}
{% include "activities/_post.html" with post=event.subject_post %}
{% include "activities/_post.html" with post=event.subject_post %}
{% endif %}
{% elif event.type == "mentioned" %}
<div class="mention-banner">
Expand All @@ -23,7 +23,7 @@
</a> mentioned you
</div>
{% if not event.collapsed %}
{% include "activities/_post.html" with post=event.subject_post %}
{% include "activities/_post.html" with post=event.subject_post %}
{% endif %}
{% elif event.type == "boosted" %}
<div class="boost-banner">
Expand All @@ -32,7 +32,7 @@
</a> boosted your post
</div>
{% if not event.collapsed %}
{% include "activities/_post.html" with post=event.subject_post event=event %}
{% include "activities/_post.html" with post=event.subject_post event=event %}
{% endif %}
{% else %}
Unknown event type {{event.type}}
Expand Down
6 changes: 3 additions & 3 deletions templates/activities/_hashtag.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{{ hashtag.display_name }}
</span>
{% if not hide_stats %}
<span>
Post count: {{ hashtag.stats.total }}
</span>
<span>
Post count: {{ hashtag.stats.total }}
</span>
{% endif %}
</a>
6 changes: 3 additions & 3 deletions templates/activities/_identity.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<div class="post-banner">
{% include "identity/_identity_banner.html" with identity=identity %}
{% if created %}
<time>
{{ event.created | timedeltashort }}
</time>
<time>
{{ event.created | timedeltashort }}
</time>
{% endif %}
</div>

Expand Down
12 changes: 6 additions & 6 deletions templates/activities/_image_upload.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<form
hx-encoding='multipart/form-data'
hx-post='{% url "compose_image_upload" %}'
hx-target="this"
hx-swap="outerHTML"
_="on htmx:xhr:progress(loaded, total)
set #attachmentProgress.value to (loaded/total)*100">
hx-encoding='multipart/form-data'
hx-post='{% url "compose_image_upload" %}'
hx-target="this"
hx-swap="outerHTML"
_="on htmx:xhr:progress(loaded, total)
set #attachmentProgress.value to (loaded/total)*100">
{% csrf_token %}
{% include "forms/_field.html" with field=form.image %}
{% include "forms/_field.html" with field=form.description %}
Expand Down
14 changes: 7 additions & 7 deletions templates/activities/_image_uploaded.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</div>
</div>
{% if request.htmx %}
<button class="add-image"
hx-get='{% url "compose_image_upload" %}'
hx-target="this"
hx-swap="outerHTML"
_="on load if length of <.uploaded-image/> > 3 then hide me">
Add Image
</button>
<button class="add-image"
hx-get='{% url "compose_image_upload" %}'
hx-target="this"
hx-swap="outerHTML"
_="on load if length of <.uploaded-image/> > 3 then hide me">
Add Image
</button>
{% endif %}
2 changes: 2 additions & 0 deletions templates/activities/_image_viewer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script type="text/hyperscript">
{# fmt:off #}
def imageviewer.show(source)
set source_url to (<img /> in source) @data-original-url
set source_alt to (<img /> in source) @alt
Expand All @@ -22,6 +23,7 @@
set <#image-viewer img /> @alt to ''
set <#image-viewer figcaption />'s textContent to ''
end
{# fmt:on #}
</script>
<figure id="image-viewer" _="on click imageviewer.close()">
<picture>
Expand Down
6 changes: 3 additions & 3 deletions templates/activities/_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ <h3></h3>
<i class="fa-solid fa-search"></i> Search
</a>
{% if current_page == "tag" %}
<a href="{% url "tag" hashtag.hashtag %}" class="selected" title="Tag {{ hashtag.display_name }}">
<i class="fa-solid fa-hashtag"></i> {{ hashtag.display_name }}
</a>
<a href="{% url "tag" hashtag.hashtag %}" class="selected" title="Tag {{ hashtag.display_name }}">
<i class="fa-solid fa-hashtag"></i> {{ hashtag.display_name }}
</a>
{% endif %}
<a href="{% url "settings" %}" {% if top_section == "settings" %}class="selected"{% endif %} title="Settings">
<i class="fa-solid fa-gear"></i> Settings
Expand Down
150 changes: 75 additions & 75 deletions templates/activities/_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,102 @@
<div class="post {% if reply %}reply{% endif %} {{ post.summary_class }}" data-takahe-id="{{ post.id }}" role="article" tabindex="0">

<div class="post-banner">
{% include "identity/_identity_banner.html" with identity=post.author %}
<div>
<time _="on click go url {% if link_original %}{{ post.url }}{% else %}{{ post.urls.view }}{% endif %} then halt">
{% if post.visibility == 0 %}
<i class="visibility fa-solid fa-earth-oceania" title="Public" aria-label="public"></i>
{% elif post.visibility == 1 %}
<i class="visibility fa-solid fa-lock-open" title="Unlisted" aria-label="unlisted"></i>
{% elif post.visibility == 2 %}
<i class="visibility fa-solid fa-lock" title="Followers Only" aria-label="followers only"></i>
{% elif post.visibility == 3 %}
<i class="visibility fa-solid fa-at" title="Mentioned Only" aria-label="mentioned only"></i>
{% elif post.visibility == 4 %}
<i class="visibility fa-solid fa-link-slash" title="Local Only" aria-label="local only"></i>
{% endif %}
{% if post.published %}
<a href="{% if link_original %}{{ post.url }}{% else %}{{ post.urls.view }}{% endif %}" title="{{ post.published }}">{{ post.published | timedeltashort }}</a>
{% else %}
<a href="{% if link_original %}{{ post.url }}{% else %}{{ post.urls.view }}{% endif %}" title="{{ post.created }}">{{ post.created | timedeltashort }}</a>
{% endif %}
</time>
</div>
{% include "identity/_identity_banner.html" with identity=post.author %}
<div>
<time _="on click go url {% if link_original %}{{ post.url }}{% else %}{{ post.urls.view }}{% endif %} then halt">
{% if post.visibility == 0 %}
<i class="visibility fa-solid fa-earth-oceania" title="Public" aria-label="public"></i>
{% elif post.visibility == 1 %}
<i class="visibility fa-solid fa-lock-open" title="Unlisted" aria-label="unlisted"></i>
{% elif post.visibility == 2 %}
<i class="visibility fa-solid fa-lock" title="Followers Only" aria-label="followers only"></i>
{% elif post.visibility == 3 %}
<i class="visibility fa-solid fa-at" title="Mentioned Only" aria-label="mentioned only"></i>
{% elif post.visibility == 4 %}
<i class="visibility fa-solid fa-link-slash" title="Local Only" aria-label="local only"></i>
{% endif %}
{% if post.published %}
<a href="{% if link_original %}{{ post.url }}{% else %}{{ post.urls.view }}{% endif %}" title="{{ post.published }}">{{ post.published | timedeltashort }}</a>
{% else %}
<a href="{% if link_original %}{{ post.url }}{% else %}{{ post.urls.view }}{% endif %}" title="{{ post.created }}">{{ post.created | timedeltashort }}</a>
{% endif %}
</time>
</div>
</div>

{% if post.summary %}
{% if config_identity.expand_linked_cws %}
<div class="summary" _="on click or keyup[key is 'Enter'] toggle .enabled on <.{{ post.summary_class }} .summary/> then toggle .hidden on <.{{ post.summary_class }} .content/> then halt" tabindex="0">
<div class="summary" _="on click or keyup[key is 'Enter'] toggle .enabled on <.{{ post.summary_class }} .summary/> then toggle .hidden on <.{{ post.summary_class }} .content/> then halt" tabindex="0">
{% else %}
<div class="summary" _="on click or keyup[key is 'Enter'] toggle .enabled then toggle .hidden on the next .content then halt" tabindex="0">
<div class="summary" _="on click or keyup[key is 'Enter'] toggle .enabled then toggle .hidden on the next .content then halt" tabindex="0">
{% endif %}
{{ post.summary }}
{{ post.summary }}
</div>
{% endif %}

<div class="content {% if post.summary %}hidden {% endif %}">
{{ post.safe_content_local }}

{% if post.attachments.exists %}
<div class="attachments">
{% for attachment in post.attachments.all %}
{% if attachment.is_image %}
<a href="{{ attachment.full_url.relative }}" class="image" target="_blank"
_="on click halt the event then call imageviewer.show(me)">
<img src="{{ attachment.thumbnail_url.relative }}" title="{{ attachment.name }}" alt="{{ attachment.name|default:'(no description)' }}" loading="lazy" data-original-url="{{ attachment.full_url.relative }}">
</a>
{% elif attachment.is_video %}
<a href="{{ attachment.full_url.relative }}" class="video">
<video muted controls loop>
<source src="{{ attachment.full_url.relative }}">
</video>
</a>
{% endif %}
{% endfor %}
</div>
<div class="attachments">
{% for attachment in post.attachments.all %}
{% if attachment.is_image %}
<a href="{{ attachment.full_url.relative }}" class="image" target="_blank"
_="on click halt the event then call imageviewer.show(me)">
<img src="{{ attachment.thumbnail_url.relative }}" title="{{ attachment.name }}" alt="{{ attachment.name|default:'(no description)' }}" loading="lazy" data-original-url="{{ attachment.full_url.relative }}">
</a>
{% elif attachment.is_video %}
<a href="{{ attachment.full_url.relative }}" class="video">
<video muted controls loop>
<source src="{{ attachment.full_url.relative }}">
</video>
</a>
{% endif %}
{% endfor %}
</div>
{% endif %}
</div>

{% if post.edited %}
<div class="edited" title="{{ post.edited }}">
<small>Edited {{ post.edited | timedeltashort }} ago</small>
</div>
<div class="edited" title="{{ post.edited }}">
<small>Edited {{ post.edited | timedeltashort }} ago</small>
</div>
{% endif %}

{% if request.identity %}
<div class="actions" role="menubar">
{% include "activities/_reply.html" %}
{% include "activities/_like.html" %}
{% include "activities/_boost.html" %}
<a title="Menu" class="menu" _="on click or keyup[key is 'Enter'] toggle .enabled on the next <menu/> then halt" role="menuitem" aria-haspopup="menu" tabindex="0">
<i class="fa-solid fa-bars"></i>
</a>
<menu>
<a href="{{ post.urls.view }}" role="menuitem">
<i class="fa-solid fa-comment"></i> View Post &amp; Replies
</a>
<a href="{{ post.urls.action_report }}" role="menuitem">
<i class="fa-solid fa-flag"></i> Report
</a>
{% if post.author == request.identity %}
<a href="{{ post.urls.action_edit }}" role="menuitem">
<i class="fa-solid fa-pen-to-square"></i> Edit
</a>
<a href="{{ post.urls.action_delete }}" role="menuitem">
<i class="fa-solid fa-trash"></i> Delete
<div class="actions" role="menubar">
{% include "activities/_reply.html" %}
{% include "activities/_like.html" %}
{% include "activities/_boost.html" %}
<a title="Menu" class="menu" _="on click or keyup[key is 'Enter'] toggle .enabled on the next <menu/> then halt" role="menuitem" aria-haspopup="menu" tabindex="0">
<i class="fa-solid fa-bars"></i>
</a>
{% elif not post.local and post.url %}
<a href="{{ post.url }}" role="menuitem">
<i class="fa-solid fa-arrow-up-right-from-square"></i> See Original
</a>
{% endif %}
{% if request.user.admin %}
<a href="{{ post.urls.admin_edit }}" role="menuitem">
<i class="fa-solid fa-gear"></i> View In Admin
</a>
{% endif %}
</menu>
</div>
<menu>
<a href="{{ post.urls.view }}" role="menuitem">
<i class="fa-solid fa-comment"></i> View Post &amp; Replies
</a>
<a href="{{ post.urls.action_report }}" role="menuitem">
<i class="fa-solid fa-flag"></i> Report
</a>
{% if post.author == request.identity %}
<a href="{{ post.urls.action_edit }}" role="menuitem">
<i class="fa-solid fa-pen-to-square"></i> Edit
</a>
<a href="{{ post.urls.action_delete }}" role="menuitem">
<i class="fa-solid fa-trash"></i> Delete
</a>
{% elif not post.local and post.url %}
<a href="{{ post.url }}" role="menuitem">
<i class="fa-solid fa-arrow-up-right-from-square"></i> See Original
</a>
{% endif %}
{% if request.user.admin %}
<a href="{{ post.urls.admin_edit }}" role="menuitem">
<i class="fa-solid fa-gear"></i> View In Admin
</a>
{% endif %}
</menu>
</div>
{% endif %}

</div>
18 changes: 9 additions & 9 deletions templates/activities/_type_question.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

<div class="poll">
<h3 style="display: none;">Options: {% if post.type_data.mode == "oneOf" %}<small>(choose one)</small>{% endif %}</h3>
{% for item in post.type_data.options %}
{% if forloop.first %}<ul>{% endif %}{% widthratio item.votes post.type_data.voter_count 100 as item_percent %}
<li><label class="poll-option">
<input style="display:none" name="vote-options" type="{% if post.type_data.mode == "oneOf" %}radio{% else %}checkbox{% endif %}" value="0">
<span class="poll-number" title="{{ item.votes }} votes">{{ item_percent }}%</span>
<span class="poll-option-text">{{ item.name }}</span>
</label>
{% if forloop.last %}</ul>{% endif %}
{% endfor %}
{% for item in post.type_data.options %}
{% if forloop.first %}<ul>{% endif %}{% widthratio item.votes post.type_data.voter_count 100 as item_percent %}
<li><label class="poll-option">
<input style="display:none" name="vote-options" type="{% if post.type_data.mode == "oneOf" %}radio{% else %}checkbox{% endif %}" value="0">
<span class="poll-number" title="{{ item.votes }} votes">{{ item_percent }}%</span>
<span class="poll-option-text">{{ item.name }}</span>
</label>
{% if forloop.last %}</ul>{% endif %}
{% endfor %}
<div class="poll-footer">
<span class="vote-total">{{ post.type_data.voter_count }} people</span>
&mdash;
Expand Down
Loading

0 comments on commit 0c1e513

Please sign in to comment.