add lightweight web frontend

This commit is contained in:
Twann 2023-05-29 02:14:40 +02:00
parent 97cf388925
commit def5a43214
No known key found for this signature in database
GPG Key ID: A964862B572E3094
7 changed files with 279 additions and 3 deletions

View File

@ -1,8 +1,63 @@
<!doctype html>
<html>
<head>
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0; url='https://update.tblock.me/2.4.0/index.json'">
<!-- HTML Meta Tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<title>Filter list repository | TBlock</title>
<meta name="description" content="Browse filter lists using this leightweight web frontend.">
<!-- Facebook Meta Tags -->
<meta property="og:url" content="https://update.tblock.me">
<meta property="og:type" content="website">
<meta property="og:title" content="Filter list repository | TBlock">
<meta property="og:description" content="Browse filter lists using this leightweight web frontend.">
<meta property="og:image" content="https://update.tblock.me/static/tblock.svg">
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="update.tblock.me">
<meta property="twitter:url" content="https://update.tblock.me">
<meta name="twitter:title" content="Filter list repository | TBlock">
<meta name="twitter:description" content="Browse filter lists using this leightweight web frontend.">
<meta name="twitter:image" content="https://update.tblock.me/static/tblock.svg">
<!-- Meta Tags Generated via https://www.opengraph.xyz -->
<!-- HTML links -->
<link rel="canonical" href="https://update.tblock.me/">
<link rel="icon" href="/static/img/tblock.svg" type="image/x-icon">
<link rel="stylesheet" href="./static/explorer.css">
<link rel="shortcut icon" href="./static/tblock.svg">
<script src="./static/base.js"></script>
</head>
<body></body>
<body>
<noscript>
<p class="noscript">This page requires JavaScript, sorry :/</p>
</noscript>
<main id="main">
<div class="header">
<h1>TBlock filter list repository</h1>
<em>Lightweight web frontend</em>
<ul>
<li><a href="./2.4.0/index.json">View raw (JSON)</a></li>
<li>Total filter lists: <code id="total"></code></li>
<li>Repository version: <code id="version"></code></li>
<li>Latest version of TBlock: <code id="tblock-version"></code></li>
</ul>
</div>
<table id="explorer">
<tr>
<th>Filter list</th>
<th>Title</th>
<th>Description</th>
<th>License</th>
</tr>
</table>
<div class="footer">
<p>
View this list with the command-line:
</p>
<pre>$ tblock -Lk</pre>
</div>
</main>
</body>
<script src="./static/explorer.js"></script>
</html>

4
static/base.js Normal file
View File

@ -0,0 +1,4 @@
async function fetchJSON(url) {
const response = await fetch(url);
return await response.json();
}

57
static/explorer.css Normal file
View File

@ -0,0 +1,57 @@
body{
font-family: sans-serif;
margin:1rem auto;
max-width:80rem;
}
#main{
visibility: hidden;
}
.header,table{
margin:3rem 1rem 1rem 1rem;
}
.footer{
margin:2rem 1rem 3rem 1rem;
}
table,th,td{
border:2px solid black;
border-collapse:collapse;
}
th,td{
padding:5px 10px;
}
a{
color:rgb(19, 84, 148);
text-decoration: underline rgb(19, 84, 148);
}
.noscript,#error{
max-width:20rem;
text-align:center;
margin:1rem auto;
background-color:rgb(235, 34, 75);
border:rgb(160, 23, 50) solid 4px;
border-radius:15px;
padding:1rem 3rem;
}
#error{
display:none;
}
#error a{
color:black;
text-decoration: underline black;
}
code,pre{
font-family: monospace;
font-size:100%;
background-color:rgb(34, 34, 34);
color:white;
padding:2px 5px;
border-radius:5px;
}
li{
margin:10px 0px;
}
pre{
font-size:120%;
padding:1rem;
overflow-x:scroll;
}

31
static/explorer.js Normal file
View File

@ -0,0 +1,31 @@
(async function() {
const data = await fetchJSON("/2.4.0/index.json");
const table = document.getElementById("explorer");
const filters = Object.keys(data.filters);
document.getElementById("main").style.visibility = "visible";
document.getElementById("tblock-version").innerText = data.repo.latest_version;
document.getElementById("version").innerText = data.repo.version;
document.getElementById("total").innerText = filters.length;
for await(id of filters){
let tr = document.createElement("tr");
let td_id = document.createElement("td");
let td_id_a = document.createElement("a");
td_id_a.href = "view.html?id=".concat(id);
td_id_a.innerText = id;
td_id.appendChild(td_id_a);
tr.appendChild(td_id);
let td_title = document.createElement("td");
td_title.innerText = data.filters[id].title;
tr.appendChild(td_title);
let td_description = document.createElement("td");
td_description.innerText = data.filters[id].desc;
tr.appendChild(td_description);
let td_license = document.createElement("td");
let td_license_a = document.createElement("a");
td_license_a.href = data.filters[id].license[1];
td_license_a.innerText = data.filters[id].license[0];
td_license.appendChild(td_license_a);
tr.appendChild(td_license);
table.appendChild(tr);
}
})();

1
static/tblock.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="500" width="500"><defs><linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" style="stop-color:#ff00ff;stop-opacity:1" /><stop offset="100%" style="stop-color:#8000ff;stop-opacity:1" /></linearGradient></defs><circle cx="250" cy="250" r="225" fill="url(#bg)" /><path d="M140 165 L140 130 L360 130 L360 165 L267.5 165 L267.5 395 L232.5 395 L232.5 165 Z" fill="#fff" /></svg>

After

Width:  |  Height:  |  Size: 443 B

33
static/viewer.js Normal file
View File

@ -0,0 +1,33 @@
(async function() {
id = new URLSearchParams(document.location.search).get("id");
const data = await fetchJSON("/2.4.0/index.json");
filters = Object.keys(data.filters);
if(filters.indexOf(id) != -1){
document.getElementById("main").style.visibility = "visible";
document.getElementById("id").innerText = id;
document.getElementById("id-code").innerText = id;
document.getElementById("id-code-2").innerText = id;
document.getElementById("title").innerText = data.filters[id].title;
document.getElementById("description").innerText = data.filters[id].desc;
const source = document.createElement("a");
source.href = data.filters[id].source;
source.innerText = source;
document.getElementById("source").appendChild(source);
document.getElementById("syntax").innerText = data.filters[id].syntax;
document.getElementById("mirrors").innerText = data.filters[id].mirrors.length;
const homepage = document.createElement("a");
homepage.href = data.filters[id].homepage;
homepage.innerText = data.filters[id].homepage;
document.getElementById("homepage").appendChild(homepage);
const license = document.createElement("a");
license.href = data.filters[id].license[1];
license.innerText = data.filters[id].license[0];
document.getElementById("license").appendChild(license);
for(tag of data.filters[id].tags){
document.getElementById("tags").innerText += " ".concat(tag);
}
}
else{
document.getElementById("error").style.display = "block";
}
})();

95
view.html Normal file
View File

@ -0,0 +1,95 @@
<!doctype html>
<html>
<head>
<!-- HTML Meta Tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<title>Filter list repository | TBlock</title>
<meta name="description" content="Browse filter lists using this leightweight web frontend.">
<!-- Facebook Meta Tags -->
<meta property="og:url" content="https://update.tblock.me/view.html">
<meta property="og:type" content="website">
<meta property="og:title" content="Filter list repository | TBlock">
<meta property="og:description" content="Browse filter lists using this leightweight web frontend.">
<meta property="og:image" content="https://update.tblock.me/static/tblock.svg">
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="update.tblock.me">
<meta property="twitter:url" content="https://update.tblock.me/view.html">
<meta name="twitter:title" content="Filter list repository | TBlock">
<meta name="twitter:description" content="Browse filter lists using this leightweight web frontend.">
<meta name="twitter:image" content="https://update.tblock.me/static/tblock.svg">
<!-- Meta Tags Generated via https://www.opengraph.xyz -->
<!-- HTML links -->
<link rel="canonical" href="https://update.tblock.me/view.html">
<link rel="icon" href="/static/img/tblock.svg" type="image/x-icon">
<link rel="stylesheet" href="./static/explorer.css">
<link rel="shortcut icon" href="./static/tblock.svg">
<script src="./static/base.js"></script>
</head>
<body>
<noscript>
<p class="noscript">This page requires JavaScript, sorry :/</p>
</noscript>
<p id="error">This filter list does not exist. <a href="./">Click here</a> to view all filter lists.</p>
<main id="main">
<div class="header">
<h1>TBlock filter list repository</h1>
<em>Lightweight web frontend</em>
<ul>
<li><a href="./">Browse all filter lists</a></li>
</ul>
</div>
<table id="viewer">
<tr>
<td><strong>Filter list</strong></td>
<td id="id"></td>
</tr>
<tr>
<td><strong>Title</strong></td>
<td id="title"></td>
</tr>
<tr>
<td><strong>Description</strong></td>
<td id="description"></td>
</tr>
<tr>
<td><strong>Source</strong></td>
<td id="source"></td>
</tr>
<tr>
<td><strong>Format</strong></td>
<td id="syntax"></td>
</tr>
<tr>
<td><strong>Mirrors</strong></td>
<td id="mirrors"></td>
</tr>
<tr>
<td><strong>Homepage</strong></td>
<td id="homepage"></td>
</tr>
<tr>
<td><strong>License</strong></td>
<td id="license"></td>
</tr>
<tr>
<td><strong>Tags</strong></td>
<td id="tags"></td>
</tr>
</table>
<div class="footer">
<p>
Subscribe to this filter list:
</p>
<pre>$ tblock -S <span id="id-code"></span></pre>
<p>
View this information with the command-line:
</p>
<pre>$ tblock -I <span id="id-code-2"></span></pre>
</div>
</main>
</body>
<script src="./static/viewer.js"></script>
</html>