🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2024-01-21 12:04:45.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2024-01-21 12:04:45.0 +00:00:00
commit
460d60799d37e04686c3d0199dd9fc02ff0c9c7a [patch]
tree
039f43862f7c6512619bc33b6bfd21a40618af58
parent
235951bac8ef657817d2ae6ab23351b0b3176195
download
460d60799d37e04686c3d0199dd9fc02ff0c9c7a.tar.gz

Fix <time> tag validity



Diff

 templates/index.html            | 2 +-
 src/methods/filters.rs          | 5 ++++-
 templates/repo/macros/refs.html | 6 ++++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/templates/index.html b/templates/index.html
index e449aa0..8dc7bc5 100644
--- a/templates/index.html
+++ a/templates/index.html
@@ -44,7 +44,7 @@
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        <time datetime="{{ repository.last_modified }}" title="{{ repository.last_modified }}">
                        <time datetime="{{ repository.last_modified|format_time }}" title="{{ repository.last_modified|format_time }}">
                            {{- repository.last_modified.clone()|timeago -}}
                        </time>
                    </a>
diff --git a/src/methods/filters.rs b/src/methods/filters.rs
index 273bb7e..b460102 100644
--- a/src/methods/filters.rs
+++ a/src/methods/filters.rs
@@ -1,11 +1,12 @@
// sorry clippy, we don't have a choice. askama forces this on us
#![allow(clippy::unnecessary_wraps, clippy::trivially_copy_pass_by_ref)]

use std::borrow::Borrow;
use time::format_description::well_known::Rfc3339;

pub fn format_time(s: time::OffsetDateTime) -> Result<String, askama::Error> {
    s.format(&Rfc3339)
pub fn format_time(s: impl Borrow<time::OffsetDateTime>) -> Result<String, askama::Error> {
    (*s.borrow())
        .format(&Rfc3339)
        .map_err(Box::from)
        .map_err(askama::Error::Custom)
}
diff --git a/templates/repo/macros/refs.html b/templates/repo/macros/refs.html
index e802355..51128da 100644
--- a/templates/repo/macros/refs.html
+++ a/templates/repo/macros/refs.html
@@ -18,7 +18,7 @@
            {{ commit.get().author.name }}
        </td>
        <td>
            <time datetime="{{ commit.get().author.time }}" title="{{ commit.get().author.time }}">
            <time datetime="{{ commit.get().author.time|format_time }}" title="{{ commit.get().author.time|format_time }}">
                {{- commit.get().author.time|timeago -}}
            </time>
        </td>
@@ -50,7 +50,7 @@
        </td>
        <td>
            {% if let Some(tagger) = tag.get().tagger -%}
            <time datetime="{{ tagger.time }}" title="{{ tagger.time }}">
            <time datetime="{{ tagger.time|format_time }}" title="{{ tagger.time|format_time }}">
                {{- tagger.time|timeago -}}
            </time>
            {%- endif %}
@@ -74,7 +74,7 @@
    {% set commit = commit.get() %}
    <tr>
        <td>
            <time datetime="{{ commit.committer.time }}" title="{{ commit.committer.time }}">
            <time datetime="{{ commit.committer.time|format_time }}" title="{{ commit.committer.time|format_time }}">
                {{- commit.committer.time.clone()|timeago -}}
            </time>
        </td>