From 16a80bf80ca2789da7b4b4cce5358a76f5db2b72 Mon Sep 17 00:00:00 2001 From: b1ek Date: Tue, 21 Feb 2023 19:59:31 +1000 Subject: [PATCH] move timesince to lib folder --- view/guestbook.pug | 29 +---------------------------- view/lib/since.pug | 28 ++++++++++++++++++++++++++++ view/projects/blek_bin.pug | 6 ++++-- 3 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 view/lib/since.pug diff --git a/view/guestbook.pug b/view/guestbook.pug index 288fc4b..33a08b6 100644 --- a/view/guestbook.pug +++ b/view/guestbook.pug @@ -1,34 +1,7 @@ extends layout/main.pug block root - var title = 'Guestbook' - - - function TimeSince(date) { - - var seconds = Math.floor((new Date() - date) / 1000); - - var interval = seconds / 31536000; - - if (interval > 1) { - return Math.floor(interval) + " years"; - } - interval = seconds / 2592000; - if (interval > 1) { - return Math.floor(interval) + " months"; - } - interval = seconds / 86400; - if (interval > 1) { - return Math.floor(interval) + " days"; - } - interval = seconds / 3600; - if (interval > 1) { - return Math.floor(interval) + " hours"; - } - interval = seconds / 60; - if (interval > 1) { - return Math.floor(interval) + " minutes"; - } - return Math.floor(seconds) + " seconds"; - } + include lib/since.pug block head diff --git a/view/lib/since.pug b/view/lib/since.pug new file mode 100644 index 0000000..a6d8c65 --- /dev/null +++ b/view/lib/since.pug @@ -0,0 +1,28 @@ +- + function TimeSince(date) { + + var seconds = Math.floor((new Date() - date) / 1000); + + var interval = seconds / 31536000; + + if (interval > 1) { + return Math.floor(interval) + " years"; + } + interval = seconds / 2592000; + if (interval > 1) { + return Math.floor(interval) + " months"; + } + interval = seconds / 86400; + if (interval > 1) { + return Math.floor(interval) + " days"; + } + interval = seconds / 3600; + if (interval > 1) { + return Math.floor(interval) + " hours"; + } + interval = seconds / 60; + if (interval > 1) { + return Math.floor(interval) + " minutes"; + } + return Math.floor(seconds) + " seconds"; + } \ No newline at end of file diff --git a/view/projects/blek_bin.pug b/view/projects/blek_bin.pug index 0dd38c9..945a136 100644 --- a/view/projects/blek_bin.pug +++ b/view/projects/blek_bin.pug @@ -1,6 +1,7 @@ extends ../layout/project.pug block root - var title = 'blek! Bin' + include ../lib/since.pug block append content h2 blek! Bin @@ -17,5 +18,6 @@ block append content a(href='https://github.com/hnhx/librebin') Librebin | , which is built on bare PHP and the code is barely readable or maintainable. br - | Also, Librebin has only 8 commits and the last commit was on May 30 2022 (at this moment). - \ No newline at end of file + | Also, Librebin has only 8 commits and the last commit was on May 30 2022 (at this moment), or + span(style='background:#30303010;padding:2px 4px;border:1px solid #c2c4c2;font-size:10pt;border-radius:8px') + | #{TimeSince(new Date(2022, 6, 30))} ago \ No newline at end of file