From c0d83d4e8075759fe64663bec42403df44210fda Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Tue, 9 Apr 2024 23:07:42 +0800 Subject: [PATCH] fancyindex move into vue --- _src/components/NowBrowsingMirror.vue | 27 +++++++++++++++++++++++++ _src/components/StatusMirrorList.vue | 6 ++++-- _src/entrypoints/fancyIndex.js | 29 +++++++++++++++++++++++++++ _src/styles/fancyIndex.scss | 3 +++ fancy-index/after-legacy.html | 2 -- fancy-index/after.html | 28 -------------------------- fancy-index/before-legacy.html | 14 ------------- fancy-index/before.html | 8 ++++---- static/njs/fancy_index.njs | 14 ++----------- 9 files changed, 69 insertions(+), 62 deletions(-) create mode 100644 _src/components/NowBrowsingMirror.vue create mode 100644 _src/entrypoints/fancyIndex.js create mode 100644 _src/styles/fancyIndex.scss delete mode 100644 fancy-index/after-legacy.html delete mode 100644 fancy-index/before-legacy.html diff --git a/_src/components/NowBrowsingMirror.vue b/_src/components/NowBrowsingMirror.vue new file mode 100644 index 0000000..7193840 --- /dev/null +++ b/_src/components/NowBrowsingMirror.vue @@ -0,0 +1,27 @@ + + + diff --git a/_src/components/StatusMirrorList.vue b/_src/components/StatusMirrorList.vue index f637b97..80321ff 100644 --- a/_src/components/StatusMirrorList.vue +++ b/_src/components/StatusMirrorList.vue @@ -54,7 +54,10 @@ onMounted(() => { {{ mir.name }}{{ mir.is_master ? "" : " [slave]" }} - +
Last Success @@ -232,5 +235,4 @@ table { } } } - diff --git a/_src/entrypoints/fancyIndex.js b/_src/entrypoints/fancyIndex.js new file mode 100644 index 0000000..c54419a --- /dev/null +++ b/_src/entrypoints/fancyIndex.js @@ -0,0 +1,29 @@ +import "./default"; +import "../styles/fancyIndex.scss"; + +import NowBrowsingMirror from "../components/NowBrowsingMirror.vue"; +import { createApp } from "vue"; + +document.getElementById("list").setAttribute("class", "table"); +document.addEventListener("DOMContentLoaded", function () { + Array.from( + document.querySelectorAll("#list tbody tr td:nth-child(3)"), + ).forEach((el) => { + const d = new Date(el.innerText); + if (!isNaN(d.getTime())) { + const date_str = + ("000" + d.getFullYear()).substr(-4) + + "-" + + ("0" + (d.getMonth() + 1)).substr(-2) + + "-" + + ("0" + d.getDate()).substr(-2) + + (" " + + ("0" + d.getHours()).substr(-2) + + ":" + + ("0" + d.getMinutes()).substr(-2)); + el.innerText = date_str; + } + }); +}); + +createApp(NowBrowsingMirror).mount("#now-browsing-mirror"); diff --git a/_src/styles/fancyIndex.scss b/_src/styles/fancyIndex.scss new file mode 100644 index 0000000..312bf84 --- /dev/null +++ b/_src/styles/fancyIndex.scss @@ -0,0 +1,3 @@ +#list tbody td, #path{ + font-family: var(--bs-font-monospace); +} diff --git a/fancy-index/after-legacy.html b/fancy-index/after-legacy.html deleted file mode 100644 index 7fb2bd6..0000000 --- a/fancy-index/after-legacy.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/fancy-index/after.html b/fancy-index/after.html index 37c0ea3..d7b8723 100644 --- a/fancy-index/after.html +++ b/fancy-index/after.html @@ -15,34 +15,6 @@ ref fa-cube icon from before.html {% include footer.html %} - {% raw %} - {% endraw %} - - {% raw %} - - - {% endraw %} diff --git a/fancy-index/before.html b/fancy-index/before.html index f2691ef..32ab6ae 100644 --- a/fancy-index/before.html +++ b/fancy-index/before.html @@ -1,6 +1,7 @@ --- permalink: /fancy-index/before.html title: Index of {{url}} +jsEntry: fancyIndex --- @@ -15,12 +16,11 @@ title: Index of {{url}}
{% raw %} -
+

{% endraw %}{% fa_svg fas.fa-cube %}{% raw %} Index of {{url}}

- Last Update: {{open}}nowBrowsingMirror.last_update{{close}} - {{open}}nowBrowsingMirror.status{{close}} + -->
+
{% endraw %} diff --git a/static/njs/fancy_index.njs b/static/njs/fancy_index.njs index 3b06615..1966301 100644 --- a/static/njs/fancy_index.njs +++ b/static/njs/fancy_index.njs @@ -12,8 +12,6 @@ function fancyIndexRender(r, templateUrl){ var tmpl = rTmpl.responseText; var result = Mark.up(tmpl, { url: r.variables.request_uri.replace(/\/+/g, '/').replace(/\?.*$/, ''), - open: '{{', - close: '}}', }); r.status = 200; r.headersOut['Content-Type'] = 'text/html'; @@ -24,19 +22,11 @@ function fancyIndexRender(r, templateUrl){ } function fancyIndexBeforeRender(r){ - if(r.variables.isbrowser && r.variables.isbrowser != '0'){ - return fancyIndexRender(r, '/fancy-index/before.html'); - }else{ - return fancyIndexRender(r, '/fancy-index/before-legacy.html'); - } + return fancyIndexRender(r, '/fancy-index/before.html'); } function fancyIndexAfterRender(r){ - if(r.variables.isbrowser && r.variables.isbrowser != '0'){ - return fancyIndexRender(r, '/fancy-index/after.html'); - }else{ - return fancyIndexRender(r, '/fancy-index/after-legacy.html'); - } + return fancyIndexRender(r, '/fancy-index/after.html'); } export default {fancyIndexBeforeRender, fancyIndexAfterRender};