From d269b1a839ffcf0e477f20412fe1c78b48a5f705 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sun, 3 Mar 2019 22:17:27 +1100 Subject: [PATCH] Add datetime_format config option. Moves the datetime_format used in various places to the config and allows a global override per site. Signed-off-by: Ben Sturmfels --- mediagoblin/config_spec.ini | 3 +++ .../mediagoblin/fragments/header_notifications.html | 2 +- mediagoblin/templates/mediagoblin/media_displays/image.html | 2 +- mediagoblin/templates/mediagoblin/moderation/report.html | 6 +++--- .../templates/mediagoblin/user_pages/blog_media.html | 4 ++-- mediagoblin/templates/mediagoblin/user_pages/media.html | 4 ++-- mediagoblin/templates/mediagoblin/user_pages/report.html | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini index c696c327..8901cefa 100644 --- a/mediagoblin/config_spec.ini +++ b/mediagoblin/config_spec.ini @@ -92,6 +92,9 @@ no_referrer = boolean(default=True) # Push stuff push_urls = string_list(default=list()) +# Python strftime's format [0] +# https://docs.python.org/library/datetime.html#strftime-strptime-behavior +datetime_format = string(default="%I:%M%p %Y-%m-%d") exif_visible = boolean(default=False) original_date_visible = boolean(default=False) diff --git a/mediagoblin/templates/mediagoblin/fragments/header_notifications.html b/mediagoblin/templates/mediagoblin/fragments/header_notifications.html index 58960e7a..1e1683a0 100644 --- a/mediagoblin/templates/mediagoblin/fragments/header_notifications.html +++ b/mediagoblin/templates/mediagoblin/fragments/header_notifications.html @@ -21,7 +21,7 @@ user=comment_target.get_actor.username, media=comment_target.slug_or_id) }}#comment" class="comment_whenlink"> - + {%- trans formatted_time=timesince(comment_object.created) -%} {{ formatted_time }} ago {%- endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/media_displays/image.html b/mediagoblin/templates/mediagoblin/media_displays/image.html index d0050f50..93bd72a0 100644 --- a/mediagoblin/templates/mediagoblin/media_displays/image.html +++ b/mediagoblin/templates/mediagoblin/media_displays/image.html @@ -35,7 +35,7 @@ {% if original_date %}

{% trans %}Created{% endtrans %}

-

+

{%- trans formatted_time=timesince(original_date) -%} {{ formatted_time }} ago {%- endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/moderation/report.html b/mediagoblin/templates/mediagoblin/moderation/report.html index abbd4a0c..efd1adae 100644 --- a/mediagoblin/templates/mediagoblin/moderation/report.html +++ b/mediagoblin/templates/mediagoblin/moderation/report.html @@ -54,7 +54,7 @@ user=target.get_actor.username, media=target.slug_or_id) }}#comment" class="comment_whenlink"> - + {%- trans formatted_time=timesince(comment.created) -%} {{ formatted_time }} ago {%- endtrans -%} @@ -117,7 +117,7 @@ - + {%- trans formatted_time=timesince(report.created) -%} {{ formatted_time }} ago {%- endtrans -%} @@ -150,7 +150,7 @@ {% trans %}Status{% endtrans %}: {% trans %}RESOLVED{% endtrans %} - {{ report.resolved.strftime("%I:%M%p %Y-%m-%d") }} + {{ report.resolved.strftime(app_config['datetime_format']) }}

       

{{ report.result }}

diff --git a/mediagoblin/templates/mediagoblin/user_pages/blog_media.html b/mediagoblin/templates/mediagoblin/user_pages/blog_media.html index 24328725..322770f4 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/blog_media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/blog_media.html @@ -128,7 +128,7 @@ user=media.get_actor.username, media=media.slug_or_id) }}#comment" class="comment_whenlink"> - + {%- trans formatted_time=timesince(comment_object.created) -%} {{ formatted_time }} ago {%- endtrans -%} @@ -148,7 +148,7 @@

{% trans %}Added{% endtrans %}

-

+

{%- trans formatted_time=timesince(media.created) -%} {{ formatted_time }} ago {%- endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index b93da06e..39a09d45 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -148,7 +148,7 @@ user=media.get_actor.username, media=media.slug_or_id) }}#comment" class="comment_whenlink"> - + {%- trans formatted_time=timesince(comment_object.created) -%} {{ formatted_time }} ago {%- endtrans -%} @@ -183,7 +183,7 @@

{% trans %}Added{% endtrans %}

-

+

{%- trans formatted_time=timesince(media.created) -%} {{ formatted_time }} ago {%- endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/user_pages/report.html b/mediagoblin/templates/mediagoblin/user_pages/report.html index 4a88f4b7..78bcc62a 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/report.html +++ b/mediagoblin/templates/mediagoblin/user_pages/report.html @@ -38,7 +38,7 @@ user=media.get_actor.username, media=media.slug_or_id) }}#comment" class="comment_whenlink"> - + {%- trans formatted_time=timesince(comment_object.created) -%} {{ formatted_time }} ago {%- endtrans -%} -- 2.25.1