Browse Source

Switch to another relative-date-formatting library which supports tiny abbreviated formats

tags/v1.10.0
Danielle McLean 1 year ago
parent
commit
c8faa30724
Signed by: Danielle McLean <dani@00dani.me> GPG Key ID: 8EB789DDF3ABD240
5 changed files with 55 additions and 74 deletions
  1. 1
    0
      Pipfile
  2. 43
    69
      Pipfile.lock
  3. 3
    3
      entries/jinja2/entries/h-entry.html
  4. 2
    2
      lemoncurry/jinja2/__init__.py
  5. 6
    0
      lemoncurry/jinja2/ago.py

+ 1
- 0
Pipfile View File

@@ -48,6 +48,7 @@ pyup-django = "*"
48 48
 "jinja2" = "*"
49 49
 msgpack = "*"
50 50
 django-randomslugfield = "*"
51
+ago = "*"
51 52
 
52 53
 [dev-packages]
53 54
 ptpython = "*"

+ 43
- 69
Pipfile.lock View File

@@ -1,7 +1,7 @@
1 1
 {
2 2
     "_meta": {
3 3
         "hash": {
4
-            "sha256": "868083c903aad618a8a0907889d57326df0a7a0b4b521441464281cbaefd67b6"
4
+            "sha256": "64691d8ff1af1c678ce146dc2801ade76d3b44f364baeef46b8e956a8776d259"
5 5
         },
6 6
         "pipfile-spec": 6,
7 7
         "requires": {
@@ -23,6 +23,14 @@
23 23
             "index": "pypi",
24 24
             "version": "==0.3.0"
25 25
         },
26
+        "ago": {
27
+            "hashes": [
28
+                "sha256:81e838ef978a19f8a263e72e4ae75345b639943e9853b33c4572b04b1d6f01f9",
29
+                "sha256:aaba95a800e96aa50173d5fa32f3870dc9faa7355cb8b493ddfc7aad7259c4e8"
30
+            ],
31
+            "index": "pypi",
32
+            "version": "==0.0.92"
33
+        },
26 34
         "argon2-cffi": {
27 35
             "hashes": [
28 36
                 "sha256:05dd15949be3a7d9f65807fe58fad70526023a319747054bb89da209c4071a33",
@@ -198,11 +206,11 @@
198 206
         },
199 207
         "django-cors-headers": {
200 208
             "hashes": [
201
-                "sha256:0e9532628b3aa8806442d4d0b15e56112e6cfbef3735e13401935c98b842a2b4",
202
-                "sha256:c7ec4816ec49416517b84f317499d1519db62125471922ab78d670474ed9b987"
209
+                "sha256:1460b67c51706307e3f66515e86b10181badd66448a2fc44278f47bf402c6fd3",
210
+                "sha256:3c618a964e3034ae4dad8bbb902e625daa6c894444ddeaf7b24125299add54f0"
203 211
             ],
204 212
             "index": "pypi",
205
-            "version": "==2.2.0"
213
+            "version": "==2.3.0"
206 214
         },
207 215
         "django-debug-toolbar": {
208 216
             "hashes": [
@@ -396,36 +404,28 @@
396 404
         },
397 405
         "lxml": {
398 406
             "hashes": [
399
-                "sha256:01c45df6d90497c20aa2a07789a41941f9a1029faa30bf725fc7f6d515b1afe9",
400
-                "sha256:0c9fef4f8d444e337df96c54544aeb85b7215b2ed7483bb6c35de97ac99f1bcd",
401
-                "sha256:0e3cd94c95d30ba9ca3cff40e9b2a14e1a10a4fd8131105b86c6b61648f57e4b",
402
-                "sha256:0e7996e9b46b4d8b4ac1c329a00e2d10edcd8380b95d2a676fccabf4c1dd0512",
403
-                "sha256:1858b1933d483ec5727549d3fe166eeb54229fbd6a9d3d7ea26d2c8a28048058",
404
-                "sha256:1b164bba1320b14905dcff77da10d5ce9c411ac4acc4fb4ed9a2a4d10fae38c9",
405
-                "sha256:1b46f37927fa6cd1f3fe34b54f1a23bd5bea1d905657289e08e1297069a1a597",
406
-                "sha256:231047b05907315ae9a9b6925751f9fd2c479cf7b100fff62485a25e382ca0d4",
407
-                "sha256:28f0c6652c1b130f1e576b60532f84b19379485eb8da6185c29bd8c9c9bc97bf",
408
-                "sha256:34d49d0f72dd82b9530322c48b70ac78cca0911275da741c3b1d2f3603c5f295",
409
-                "sha256:3682a17fbf72d56d7e46db2e80ca23850b79c28cfe75dcd9b82f58808f730909",
410
-                "sha256:3cf2830b9a6ad7f6e965fa53a768d4d2372a7856f20ffa6ce43d2fe9c0d34b19",
411
-                "sha256:5b653c9379ce29ce271fbe1010c5396670f018e78b643e21beefbb3dc6d291de",
412
-                "sha256:65a272821d5d8194358d6b46f3ca727fa56a6b63981606eac737c86d27309cdd",
413
-                "sha256:691f2cd97cf026c611df1ea5055755eec7f878f2d4f4330dc8686583de6fc5fd",
414
-                "sha256:6b6379495d3baacf7ed755ac68547c8dff6ce5d37bf370f0b7678888dc1283f9",
415
-                "sha256:75322a531504d4f383264391d89993a42e286da8821ddc5ac315e57305cb84f0",
416
-                "sha256:7f457cbda964257f443bac861d3a36732dcba8183149e7818ee2fb7c86901b94",
417
-                "sha256:7ff1fc76d8804e0f870c343a72007ff587090c218b0f92d8ee784ac2b6eaf5b9",
418
-                "sha256:8523fbde9c2216f3f2b950cb01ebe52e785eaa8a07ffeb456dd3576ca1b4fb9b",
419
-                "sha256:8f37627f16e026523fca326f1b5c9a43534862fede6c3e99c2ba6a776d75c1ab",
420
-                "sha256:a7182ea298cc3555ea56ffbb0748fe0d5e0d81451e2bc16d7f4645cd01b1ca70",
421
-                "sha256:abbd2fb4a5a04c11b5e04eb146659a0cf67bb237dd3d7ca3b9994d3a9f826e55",
422
-                "sha256:accc9f6b77bed0a6f267b4fae120f6008a951193d548cdbe9b61fc98a08b1cf8",
423
-                "sha256:bd88c8ce0d1504fdfd96a35911dd4f3edfb2e560d7cfdb5a3d09aa571ae5fbae",
424
-                "sha256:c557ad647facb3c0027a9d0af58853f905e85a0a2f04dcb73f8e665272fcdc3a",
425
-                "sha256:defabb7fbb99f9f7b3e0b24b286a46855caef4776495211b066e9e6592d12b04",
426
-                "sha256:e2629cdbcad82b83922a3488937632a4983ecc0fed3e5cfbf430d069382eeb9b"
427
-            ],
428
-            "version": "==4.2.1"
407
+                "sha256:0941f4313208c07734410414d8308812b044fd3fb98573454e3d3a0d2e201f3d",
408
+                "sha256:0b18890aa5730f9d847bc5469e8820f782d72af9985a15a7552109a86b01c113",
409
+                "sha256:21f427945f612ac75576632b1bb8c21233393c961f2da890d7be3927a4b6085f",
410
+                "sha256:24cf6f622a4d49851afcf63ac4f0f3419754d4e98a7a548ab48dd03c635d9bd3",
411
+                "sha256:2e43b2e5b7d2b9abe6e0301eef2c2c122ab45152b968910eae68bdee2c4cfae0",
412
+                "sha256:329a6d8b6d36f7d6f8b6c6a1db3b2c40f7e30a19d3caf62023c9d6a677c1b5e1",
413
+                "sha256:4651ea05939374cfb5fe87aab5271ed38c31ea47997e17ec3834b75b94bd9f15",
414
+                "sha256:4be3bbfb2968d7da6e5c2cd4104fc5ec1caf9c0794f6cae724da5a53b4d9f5a3",
415
+                "sha256:622f7e40faef13d232fb52003661f2764ce6cdef3edb0a59af7c1559e4cc36d1",
416
+                "sha256:6ec908b4c8a4faa7fe1a0080768e2ce733f268b287dfefb723273fb34141475f",
417
+                "sha256:8c39babd923c431dcf1e5874c0f778d3a5c745a62c3a9b6bd755efd489ee8a1d",
418
+                "sha256:949ca5bc56d6cb73d956f4862ba06ad3c5d2808eac76304284f53ae0c8b2334a",
419
+                "sha256:9f0daddeefb0791a600e6195441910bdf01eac470be596b9467e6122b51239a6",
420
+                "sha256:a359893b01c30e949eae0e8a85671a593364c9f0b8162afe0cb97317af0953bf",
421
+                "sha256:ad5d5d8efed59e6b1d4c50c1eac59fb6ecec91b2073676af1e15fc4d43e9b6c5",
422
+                "sha256:bc1a36f95a6b3667c09b34995fc3a46a82e4cf0dc3e7ab281e4c77b15bd7af05",
423
+                "sha256:be37b3f55b6d7d923f43bf74c356fc1878eb36e28505f38e198cb432c19c7b1a",
424
+                "sha256:c45bca5e544eb75f7500ffd730df72922eb878a2f0213b0dc5a5f357ded3a85d",
425
+                "sha256:ccee7ebbb4735ebc341d347fca9ee09f2fa6c0580528c1414bc4e1d31372835c",
426
+                "sha256:f7d9d5aa1c7e54167f1a3cba36b5c52c7c540f30952c9bd7d9302a1eda318424"
427
+            ],
428
+            "version": "==4.2.3"
429 429
         },
430 430
         "markdown": {
431 431
             "hashes": [
@@ -623,23 +623,10 @@
623 623
         },
624 624
         "pyyaml": {
625 625
             "hashes": [
626
-                "sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8",
627
-                "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",
628
-                "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",
629
-                "sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608",
630
-                "sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8",
631
-                "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
632
-                "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7",
633
-                "sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3",
634
-                "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",
635
-                "sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6",
636
-                "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",
637
-                "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",
638
-                "sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca",
639
-                "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269"
626
+                "sha256:a9b322285f419429402d5ce15e8f6d5c7a64f659eb87251af8b35c106f00a8e3"
640 627
             ],
641 628
             "index": "pypi",
642
-            "version": "==3.12"
629
+            "version": "==4.1"
643 630
         },
644 631
         "qrcode": {
645 632
             "hashes": [
@@ -824,10 +811,10 @@
824 811
         },
825 812
         "py": {
826 813
             "hashes": [
827
-                "sha256:29c9fab495d7528e80ba1e343b958684f4ace687327e6f789a94bf3d1915f881",
828
-                "sha256:983f77f3331356039fdd792e9220b7b8ee1aa6bd2b25f567a963ff1de5a64f6a"
814
+                "sha256:3fd59af7435864e1a243790d322d763925431213b6b8529c6ca71081ace3bbf7",
815
+                "sha256:e31fb2767eb657cbde86c454f02e99cb846d3cd9d61b318525140214fdc0e98e"
829 816
             ],
830
-            "version": "==1.5.3"
817
+            "version": "==1.5.4"
831 818
         },
832 819
         "pygments": {
833 820
             "hashes": [
@@ -853,23 +840,10 @@
853 840
         },
854 841
         "pyyaml": {
855 842
             "hashes": [
856
-                "sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8",
857
-                "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",
858
-                "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",
859
-                "sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608",
860
-                "sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8",
861
-                "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
862
-                "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7",
863
-                "sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3",
864
-                "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",
865
-                "sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6",
866
-                "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",
867
-                "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",
868
-                "sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca",
869
-                "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269"
870
-            ],
871
-            "index": "pypi",
872
-            "version": "==3.12"
843
+                "sha256:a9b322285f419429402d5ce15e8f6d5c7a64f659eb87251af8b35c106f00a8e3"
844
+            ],
845
+            "index": "pypi",
846
+            "version": "==4.1"
873 847
         },
874 848
         "six": {
875 849
             "hashes": [

+ 3
- 3
entries/jinja2/entries/h-entry.html View File

@@ -9,12 +9,12 @@
9 9
     {{i}}<a class="u-uid u-url" href="{{ entry.url }}">
10 10
       {{i}}<time class="dt-published media" datetime="{{ entry.published.isoformat() }}">
11 11
         {{i}}<i class="fas fa-fw fa-calendar" aria-hidden="true"></i>
12
-        {{i}}<div class="media-body">{{ entry.published | naturaltime }}</div>
12
+        {{i}}<div class="media-body">{{ entry.published | ago }}</div>
13 13
         {{i}}</time>
14 14
     {{i}}</a>
15
-    {{i}}<time class="dt-updated media" datetime="{{ entry.updated.isoformat() }}"{% if (entry.updated | naturaltime) == (entry.published | naturaltime) %} hidden{% endif %}>
15
+    {{i}}<time class="dt-updated media" datetime="{{ entry.updated.isoformat() }}"{% if (entry.updated | ago) == (entry.published | ago) %} hidden{% endif %}>
16 16
       {{i}}<i class="fas fa-fw fa-pencil-alt" aria-hidden="true"></i>
17
-      {{i}}<div class="media-body">{{ entry.updated | naturaltime }}</div>
17
+      {{i}}<div class="media-body">{{ entry.updated | ago }}</div>
18 18
     {{i}}</time>
19 19
     {{i}}<a class="u-url media" href="{{ entry.short_url }}">
20 20
       {{i}}<i class="fas fa-fw fa-link" aria-hidden="true"></i>

+ 2
- 2
lemoncurry/jinja2/__init__.py View File

@@ -1,4 +1,3 @@
1
-from django.contrib.humanize.templatetags.humanize import naturaltime
2 1
 from django.contrib.staticfiles.storage import staticfiles_storage
3 2
 from django.conf import settings
4 3
 from django.urls import reverse
@@ -8,6 +7,7 @@ from compressor.contrib.jinja2ext import CompressorExtension
8 7
 from django_activeurl.ext.django_jinja import ActiveUrl
9 8
 
10 9
 from entries.kinds import all as entry_kinds
10
+from .ago import ago
11 11
 from .markdown import markdown
12 12
 from ..theme import color as theme_color
13 13
 from ..utils import friendly_url, load_package_json
@@ -21,9 +21,9 @@ def environment(**options):
21 21
         **options
22 22
     )
23 23
     env.filters.update({
24
+        'ago': ago,
24 25
         'friendly_url': friendly_url,
25 26
         'markdown': markdown,
26
-        'naturaltime': naturaltime,
27 27
     })
28 28
     env.globals.update({
29 29
         'entry_kinds': entry_kinds,

+ 6
- 0
lemoncurry/jinja2/ago.py View File

@@ -0,0 +1,6 @@
1
+from ago import human
2
+from datetime import datetime
3
+
4
+
5
+def ago(dt: datetime) -> str:
6
+    return human(dt, past_tense='{}', abbreviate=True)

Loading…
Cancel
Save