From 1bb22a28086800b4e171da80ed00d29b86561e67 Mon Sep 17 00:00:00 2001 From: onezDerv Date: Wed, 18 Sep 2024 01:31:24 -0400 Subject: [PATCH] first commit lop --- LICENSE | 14 ++++++ README.md | 5 +++ css/app.css | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 24 ++++++++++ js/app.js | 96 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 css/app.css create mode 100644 index.html create mode 100644 js/app.js diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e4ed5a7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ +Copyright (C) 2024 Onez + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0f0778 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Scratch Feed + +A clean, descriptive content aggregator for Scratch projects and other data. + +Code is partially from https://codeberg.org/onezDerv/frictionless-browser \ No newline at end of file diff --git a/css/app.css b/css/app.css new file mode 100644 index 0000000..77df323 --- /dev/null +++ b/css/app.css @@ -0,0 +1,125 @@ +:root { + font-family: system-ui, sans-serif; + + --dark-1: rgb(64, 64, 64); + --dark-2: rgb(128, 128, 128); + + --dark-3: rgb(228, 228, 228); + --dark-4: rgb(255, 255, 255); + + background-image: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgb(202, 202, 202)); + background-size: 100vw 100vh !important; + background-repeat: repeat !important; + background-attachment: fixed !important; +} + +textarea { + width: 200px; + height: 200px; +} + +section { + max-width: 90vw; + width: 800px; + margin-left: auto; + margin-right: auto; + background: rgb(255, 255, 255); + border: solid rgb(200, 200, 200) 2px; + border-radius: 10px; + padding: 15px; +} + +a { + text-decoration: none; +} + +section#area-main { + width: 90vw; + margin-top: 15px; +} + +sub { + color: rgb(33, 156, 70) +} + +h1 { + margin-top: 0; +} + +.content { + background: var(--dark-4); + max-width: 95vw; + padding: 10px; + width: 800px; + margin: auto; + +} + +input, button, textarea { + padding: 0.2rem; + margin: 0.2rem; + display: block; + border: solid var(--dark-2) 1px; + border-radius: 0.2rem; + background: var(--dark-3); + font-family: system-ui, sans-serif; +} + +textarea { + font-family: monospace; +} + +.header { + background: var(--dark-1); + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; + position: sticky; + top: 0; +} + +img { + height: 3rem; + margin: 0.5rem; + display: block; + + width: 40vmin; + height: auto; +} + +.header a { + margin: 0.5rem; +} + +.header a { + color: var(--dark-4); +} + +pre { + overflow: scroll; +} + +#area-main { + display: flex; + flex-wrap: wrap; +} + +.proj { + text-align: center; + max-width: 240px; + margin: 10px; +} + +.proj img { + width: 240px; +} + +.eras, .contributors { + overflow: scroll; + height: 180px; +} + +.eras a { + margin-right: 10px; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..1c932f8 --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + + + + + +
+

Scratch Feed

+

Users to follow

+ + +
+
+ +
+ + + diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..5572956 --- /dev/null +++ b/js/app.js @@ -0,0 +1,96 @@ +let area = document.querySelector('#area-main'); +let entries = []; +let users = {}; +let fetchData; +let sum = 0; +let doThings = false; +let i = 0; + +async function genTree(treeId) { + let entry = treeId; + + while (true) { + let entryDat = fetchData[entry]; + + entries.push(entry); + + if (!entryDat) break; + + let us = users[entryDat.username]; + + let s = 1 / ((new Date() - new Date(entryDat.datetime_created.$date)) + 1000 * 60 * 60); + sum += s; + users[entryDat.username] = (us ? us : 0) + s; + entry = entryDat.parent_id; + } + + return entry; +} + +async function main() { + + let users = document.querySelector('#users').value.split('\n'); + + let url = new URL(window.location); + url.search = '?users=' + users.join('&users='); + history.pushState(null, '', url); + + entries = []; + + for (let user of users) { + let extraFetch = await fetch(`https://hf.zenoverse.net/user/${user}`, { + + }); + extraFetch = await extraFetch.json(); + extraFetch.forEach(x => x.username = user); + entries = [...entries, ...extraFetch]; + } + entries = entries.sort((a, b) => b.id - a.id); + + let params = new URL(window.location).searchParams; + + let start = params.get('start') * 1; + let end = params.get('end') * 1; + + end = Math.min(end, entries.length - 2); + + if (start && end) { + entries = entries.splice(entries.length - end - 2, end - start + 1); + } + + doThings = true; + + + setInterval(function () { + if (doThings && (window.innerHeight + window.scrollY) >= document.body.scrollHeight - 25) + scroller(); + }, 500); +} + +function sanitize(content) { + const decoder = document.createElement('div'); + decoder.textContent = content; + return decoder.innerHTML; +} + +function scroller() { + let h = ''; + for (let j = 0; j < 35; j++) { + let entry = entries[i]; + if (!entry) continue; + h += `
${entry.title} by ${entry.username}
`; + i++; + } + area.innerHTML += h; +} + +let sub = document.querySelector('#users'); + +let params = new URLSearchParams(window.location.search).getAll('users'); + +let val = params.join('\n') || sub.value; + +sub.textContent = sub.value = val; + +main(); +document.querySelector('#submit').onclick = main; \ No newline at end of file