Add datetime_format config option.
authorOlivier Mehani <shtrom+mediagoblin@ssji.net>
Sun, 3 Mar 2019 11:17:27 +0000 (22:17 +1100)
committerBen Sturmfels <ben@sturm.com.au>
Fri, 20 Sep 2019 00:38:09 +0000 (10:38 +1000)
Moves the datetime_format used in various places to the config and allows a
global override per site.

Signed-off-by: Ben Sturmfels <ben@sturm.com.au>
mediagoblin/config_spec.ini
mediagoblin/templates/mediagoblin/fragments/header_notifications.html
mediagoblin/templates/mediagoblin/media_displays/image.html
mediagoblin/templates/mediagoblin/moderation/report.html
mediagoblin/templates/mediagoblin/user_pages/blog_media.html
mediagoblin/templates/mediagoblin/user_pages/media.html
mediagoblin/templates/mediagoblin/user_pages/report.html

index c696c32796f221c0d836c228954e3e41d67ef06f..8901cefa86d64f207dab53cc75a685eeddf57fff 100644 (file)
@@ -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)
 
index 58960e7a10a32b099dc45b22407a6a1166bb1f01..1e1683a048a9bfa263f17d177d65d086b9db9d25 100644 (file)
@@ -21,7 +21,7 @@
                             user=comment_target.get_actor.username,
                             media=comment_target.slug_or_id) }}#comment"
                     class="comment_whenlink">
-                    <span title='{{- comment_object.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+                    <span title='{{- comment_object.created.strftime(app_config['datetime_format']) -}}'>
                     {%- trans formatted_time=timesince(comment_object.created) -%}
                         {{ formatted_time }} ago
                     {%- endtrans -%}
index d0050f5088c6dfa6ac60c417822df0f65f86b6fb..93bd72a0c5347a7879a70c1ef1ba219696a16456 100644 (file)
@@ -35,7 +35,7 @@
     {% if original_date %}
       <h3>{% trans %}Created{% endtrans %}</h3>
 
-      <p><span title="{{ original_date.strftime("%I:%M%p %Y-%m-%d") }}">
+      <p><span title="{{ original_date.strftime(app_config['datetime_format']) }}">
         {%- trans formatted_time=timesince(original_date) -%}
           {{ formatted_time }} ago
         {%- endtrans -%}
index abbd4a0cf4b4a9b96a0eb421657d2d8f52fa9060..efd1adae2e23943cad680a095c9bf90f113a2ccb 100644 (file)
@@ -54,7 +54,7 @@
                         user=target.get_actor.username,
                         media=target.slug_or_id) }}#comment"
            class="comment_whenlink">
-          <span title='{{- comment.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+          <span title='{{- comment.created.strftime(app_config['datetime_format']) -}}'>
             {%- trans formatted_time=timesince(comment.created) -%}
               {{ formatted_time }} ago
             {%- endtrans -%}
         <a href="{{ request.urlgen('mediagoblin.moderation.reports_detail',
                         report_id=report.id) }}"
            class="report_whenlink">
-          <span title='{{- report.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+          <span title='{{- report.created.strftime(app_config['datetime_format']) -}}'>
             {%- trans formatted_time=timesince(report.created) -%}
               {{ formatted_time }} ago
             {%- endtrans -%}
           {% trans %}Status{% endtrans %}:
     </h2>
     <b>{% trans %}RESOLVED{% endtrans %}</b>
-    {{ report.resolved.strftime("%I:%M%p %Y-%m-%d") }}
+    {{ report.resolved.strftime(app_config['datetime_format']) }}
     <pre>
       <p>{{ report.result }}</p>
     </pre>
index 24328725717d51c89edd1ca1f774fd0b818e87a1..322770f4363b9cfd43b55d962de8f4af72e58f5a 100644 (file)
                             user=media.get_actor.username,
                             media=media.slug_or_id) }}#comment"
                class="comment_whenlink">
-              <span title='{{- comment_object.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+              <span title='{{- comment_object.created.strftime(app_config['datetime_format']) -}}'>
                 {%- trans formatted_time=timesince(comment_object.created) -%}
                   {{ formatted_time }} ago
                 {%- endtrans -%}
   </div>
   <div class="media_sidebar">
     <h3>{% trans %}Added{% endtrans %}</h3>
-    <p><span title="{{ media.created.strftime("%I:%M%p %Y-%m-%d") }}">
+    <p><span title="{{ media.created.strftime(app_config['datetime_format']) }}">
         {%- trans formatted_time=timesince(media.created) -%}
           {{ formatted_time }} ago
         {%- endtrans -%}
index b93da06ee0c232fd8bce1cae503f5e797c346bc9..39a09d45c46d76363b0fd9d9767fc9b477de8a24 100644 (file)
                             user=media.get_actor.username,
                             media=media.slug_or_id) }}#comment"
                class="comment_whenlink">
-              <span title='{{- comment_object.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+              <span title='{{- comment_object.created.strftime(app_config['datetime_format']) -}}'>
                 {%- trans formatted_time=timesince(comment_object.created) -%}
                   {{ formatted_time }} ago
                 {%- endtrans -%}
 
   <div class="five columns media_sidebar">
     <h3>{% trans %}Added{% endtrans %}</h3>
-    <p><span title="{{ media.created.strftime("%I:%M%p %Y-%m-%d") }}">
+    <p><span title="{{ media.created.strftime(app_config['datetime_format']) }}">
         {%- trans formatted_time=timesince(media.created) -%}
           {{ formatted_time }} ago
         {%- endtrans -%}
index 4a88f4b7accf2cb2aee29609df694a64a9fe96e4..78bcc62a86c111b7bf1d4312e6bb9e51aeb86394 100644 (file)
@@ -38,7 +38,7 @@
                             user=media.get_actor.username,
                             media=media.slug_or_id) }}#comment"
                class="comment_whenlink">
-              <span title='{{- comment_object.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+              <span title='{{- comment_object.created.strftime(app_config['datetime_format']) -}}'>
                 {%- trans formatted_time=timesince(comment_object.created) -%}
                   {{ formatted_time }} ago
                 {%- endtrans -%}