first commit lop
This commit is contained in:
commit
1bb22a2808
5 changed files with 264 additions and 0 deletions
14
LICENSE
Normal file
14
LICENSE
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
5
README.md
Normal file
5
README.md
Normal file
|
@ -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
|
125
css/app.css
Normal file
125
css/app.css
Normal file
|
@ -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;
|
||||||
|
}
|
24
index.html
Normal file
24
index.html
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="css/app.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<section>
|
||||||
|
<h1><a href='https://codeberg.org/onezDerv/scratch-feed'>Scratch Feed</a></h1>
|
||||||
|
<h2>Users to follow</h2>
|
||||||
|
<textarea id='users'>User1
|
||||||
|
User2
|
||||||
|
...
|
||||||
|
</textarea>
|
||||||
|
<button id='submit'>Submit</button>
|
||||||
|
</section>
|
||||||
|
<section id='area-main'>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
<script src='js/data.js'></script>
|
||||||
|
<script src='js/app.js'></script>
|
||||||
|
</body>
|
96
js/app.js
Normal file
96
js/app.js
Normal file
|
@ -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 += `<div class='proj'><a href="https://scratch.mit.edu/projects/${entry.id}"><img src='https://uploads.scratch.mit.edu/get_image/project/${entry.id}_1920x1080.png'>${entry.title}</a> <sub>by ${entry.username}</sub></div>`;
|
||||||
|
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;
|
Loading…
Reference in a new issue