mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
fancyindex move into vue
This commit is contained in:
parent
b6aba14bb0
commit
c0d83d4e80
|
|
@ -0,0 +1,27 @@
|
||||||
|
<script setup>
|
||||||
|
import { useMirrorList } from "../lib/mirrorList";
|
||||||
|
import { computed } from "vue";
|
||||||
|
|
||||||
|
const rawMirrorList = useMirrorList();
|
||||||
|
|
||||||
|
const nowBrowsingMirror = computed(() => {
|
||||||
|
let mirrorName = location.pathname.split("/")[1]?.toLowerCase();
|
||||||
|
if (!mirrorName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const result = rawMirrorList.value.filter((m) => {
|
||||||
|
return m.name.toLowerCase() === mirrorName;
|
||||||
|
})[0];
|
||||||
|
if (!result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<template v-if="nowBrowsingMirror">
|
||||||
|
<strong>Last Update: </strong>
|
||||||
|
<UpdateField :mir="nowBrowsingMirror"></UpdateField>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
@ -54,7 +54,10 @@ onMounted(() => {
|
||||||
<td class="col-8 col-lg-2">
|
<td class="col-8 col-lg-2">
|
||||||
{{ mir.name }}{{ mir.is_master ? "" : " [slave]" }}
|
{{ mir.name }}{{ mir.is_master ? "" : " [slave]" }}
|
||||||
</td>
|
</td>
|
||||||
<td class="col-12 col-lg-4 d-lg-none d-lg-redoce-table-ceil" colspan="2">
|
<td
|
||||||
|
class="col-12 col-lg-4 d-lg-none d-lg-redoce-table-ceil"
|
||||||
|
colspan="2"
|
||||||
|
>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<th class="col-4 text-end">Last Success</th>
|
<th class="col-4 text-end">Last Success</th>
|
||||||
<td class="col-8">
|
<td class="col-8">
|
||||||
|
|
@ -232,5 +235,4 @@ table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -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");
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#list tbody td, #path{
|
||||||
|
font-family: var(--bs-font-monospace);
|
||||||
|
}
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -15,34 +15,6 @@ ref fa-cube icon from before.html
|
||||||
{% include footer.html %}
|
{% include footer.html %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
{% raw %}
|
|
||||||
{% endraw %}
|
|
||||||
<script src="/static/js/index.js?{{ site.data['hash'] }}"></script>
|
|
||||||
{% raw %}
|
|
||||||
<script>
|
|
||||||
document.getElementById("list").setAttribute("class", "table");
|
|
||||||
document.addEventListener("DOMContentLoaded", function(){
|
|
||||||
var els = Array.from(document.querySelectorAll("#list tbody tr td:nth-child(3)"))
|
|
||||||
for(var i = 0; i < els.length; i++){
|
|
||||||
var el = els[i];
|
|
||||||
var d = new Date(el.innerText);
|
|
||||||
if(!isNaN(d.getTime())){
|
|
||||||
var 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
#list tbody td, #path{
|
|
||||||
font-family: 'Fira Code Retina', 'Fira Code', 'Fira Mono', 'JetBrains Mono', 'Source Code Pro', 'Consolas', 'Menlo', 'Monaco', monospace;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endraw %}
|
|
||||||
</html>
|
</html>
|
||||||
<!--
|
<!--
|
||||||
vim: ts=2 sts=2 sw=2 noexpandtab
|
vim: ts=2 sts=2 sw=2 noexpandtab
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
permalink: /fancy-index/before-legacy.html
|
|
||||||
title: Index of {{url}}
|
|
||||||
legacy: true
|
|
||||||
---
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
{% capture metaDesc %}Index of {% raw %}{{url}}{% endraw %}{% endcapture %}
|
|
||||||
{% include head.html metaDesc=metaDesc nostyle="true" notArticle=true %}
|
|
||||||
<body>
|
|
||||||
<h1>Index of
|
|
||||||
<!--
|
|
||||||
vim: ts=2 sts=2 sw=2 noexpandtab
|
|
||||||
-->
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
permalink: /fancy-index/before.html
|
permalink: /fancy-index/before.html
|
||||||
title: Index of {{url}}
|
title: Index of {{url}}
|
||||||
|
jsEntry: fancyIndex
|
||||||
---
|
---
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
@ -15,12 +16,11 @@ title: Index of {{url}}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% raw %}
|
{% raw %}
|
||||||
<div class="col-12 table-responsive" id="mirror-list">
|
<div class="col-12 table-responsive">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-8 col-12"><h3>{% endraw %}{% fa_svg fas.fa-cube %}{% raw %} Index of <span id="path">{{url}}</span></h3></div><!--
|
<div class="col-lg-8 col-12"><h3>{% endraw %}{% fa_svg fas.fa-cube %}{% raw %} Index of <span id="path">{{url}}</span></h3></div><!--
|
||||||
--><div class="col-lg-4 col-12 d-flex align-items-end justify-content-start justify-content-lg-end" v-if="nowBrowsingMirror">
|
--><div class="col-lg-4 col-12 d-flex align-items-end justify-content-start justify-content-lg-end">
|
||||||
<strong>Last Update:</strong> {{open}}nowBrowsingMirror.last_update{{close}}
|
<div id="now-browsing-mirror"></div>
|
||||||
<span v-if="nowBrowsingMirror.show_status" :class="['label', 'label-status', nowBrowsingMirror.label, 'hidden-xs']">{{open}}nowBrowsingMirror.status{{close}}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ function fancyIndexRender(r, templateUrl){
|
||||||
var tmpl = rTmpl.responseText;
|
var tmpl = rTmpl.responseText;
|
||||||
var result = Mark.up(tmpl, {
|
var result = Mark.up(tmpl, {
|
||||||
url: r.variables.request_uri.replace(/\/+/g, '/').replace(/\?.*$/, ''),
|
url: r.variables.request_uri.replace(/\/+/g, '/').replace(/\?.*$/, ''),
|
||||||
open: '{{',
|
|
||||||
close: '}}',
|
|
||||||
});
|
});
|
||||||
r.status = 200;
|
r.status = 200;
|
||||||
r.headersOut['Content-Type'] = 'text/html';
|
r.headersOut['Content-Type'] = 'text/html';
|
||||||
|
|
@ -24,19 +22,11 @@ function fancyIndexRender(r, templateUrl){
|
||||||
}
|
}
|
||||||
|
|
||||||
function fancyIndexBeforeRender(r){
|
function fancyIndexBeforeRender(r){
|
||||||
if(r.variables.isbrowser && r.variables.isbrowser != '0'){
|
return fancyIndexRender(r, '/fancy-index/before.html');
|
||||||
return fancyIndexRender(r, '/fancy-index/before.html');
|
|
||||||
}else{
|
|
||||||
return fancyIndexRender(r, '/fancy-index/before-legacy.html');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fancyIndexAfterRender(r){
|
function fancyIndexAfterRender(r){
|
||||||
if(r.variables.isbrowser && r.variables.isbrowser != '0'){
|
return fancyIndexRender(r, '/fancy-index/after.html');
|
||||||
return fancyIndexRender(r, '/fancy-index/after.html');
|
|
||||||
}else{
|
|
||||||
return fancyIndexRender(r, '/fancy-index/after-legacy.html');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {fancyIndexBeforeRender, fancyIndexAfterRender};
|
export default {fancyIndexBeforeRender, fancyIndexAfterRender};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue