This commit is contained in:
Valeria Fadeeva 2023-12-12 13:21:53 +05:00
parent 4dccc22e0a
commit 2a7cb2b07b
5 changed files with 1827 additions and 0 deletions

10
public/json/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="ru-RU">
<head>
<link rel="stylesheet" href="theme.css" media="all">
</head>
<body>
<div id="log"></div>
<script src="index.js" type="module" async="async"></script>
</body>
</html>

106
public/json/index.js Normal file
View File

@ -0,0 +1,106 @@
let tplUrl = 'mas-tpl.html';
let response = await fetch(tplUrl);
var tpl = "";
let log = document.getElementById('log');
log.innerHTML = "";
const controller = new AbortController();
const signal = controller.signal;
// Cancel the fetch request in 500ms
setTimeout(() => controller.abort(), 500);
try {
const response = await fetch(tplUrl, { signal });
tpl = await response.text();
} catch (error) {
// DOMException: The user aborted a request.
console.log('Error: ', error)
log.innerHTML = "<p>1) Ой всё сломалось :(</p>";
}
if (!tpl) {
log.innerHTML = "<p>2) Ой всё сломалось :(</p>";
}
// else {
// log.innerHTML = tpl;
// }
async function fetchData() {
var log = document.getElementById('log');
var server_address = `techhub.social`;
const response = await fetch('posts.json');
// const response = await fetch(`https://${server_address}/api/v1/accounts/111518136987654656/statuses`);
const data = await response.json();
data.forEach(obj => {
let post_tpl = tpl;
var media_link = "";
Object.entries(obj).forEach(([key, value]) => {
if (key == "id") {
post_tpl = post_tpl.replace(/{post_id}/g, `${value}`);
}
if (key == "account") {
post_tpl = post_tpl.replace(/{id}/g, `${value.id}`);
post_tpl = post_tpl.replace(/{name}/g, `${value.display_name}`);
post_tpl = post_tpl.replace(/{server_address}/g, `${server_address}`);
post_tpl = post_tpl.replace(/{account_name}/g, `<a href="https://${server_address}/@${value.username}" target="_blank">@${value.username}@${server_address}</a>`);
// post_tpl = post_tpl.replace('{avatar}', `<img src="${value.avatar}" alt="${value.username}'s Avatar" style="width:48px;height:48px;">`);
post_tpl = post_tpl.replace(/{avatar}/g, `${value.avatar}`);
post_tpl = post_tpl.replace(/{profile_link}/g, `${value.url}`);
}
if (key == "content") {
post_tpl = post_tpl.replace('{content}', `${value}`);
}
if (key == "media_attachments") {
value.forEach(obj1 => {
Object.entries(obj1).forEach(([k, v]) => {
if (k == "preview_url") {
media_link += `<img src="${v}">`;
}
});
});
post_tpl = post_tpl.replace('{media_attachments}', `${media_link}`);
}
if (key == "created_at") {
post_tpl = post_tpl.replace(/{created_at}/g, `${value}`);
}
if (key == "edited_at") {
post_tpl = post_tpl.replace(/{edited_at}/g, `${value}`);
}
if (key == "favorites_count") {
post_tpl = post_tpl.replace(/{favorites_count}/g, `${value}`);
}
if (key == "replies_count") {
post_tpl = post_tpl.replace(/{replies_count}/g, `${value}`);
}
if (key == "reblogs_count") {
post_tpl = post_tpl.replace(/{reblogs_count}/g, `${value}`);
}
// log.innerHTML = log.innerHTML + `${key} ${value}` + '<br>';
});
log.innerHTML += `${post_tpl}<br>`;
});
}
async function openInNewTab(url) {
window.open(url, '_blank').focus();
}
fetchData();

26
public/json/mas-tpl.html Normal file
View File

@ -0,0 +1,26 @@
<article aria-posinset="3" aria-setsize="3" data-id="{post_id}" tabindex="-1" style="">
<div tabindex="-1">
<div class="status__wrapper status__wrapper-public focusable" tabindex="0" aria-label="{head}">
<div class="status status-public" data-id="{post_id}">
<div class="status__info">
<a href="https://{server_address}/@{name}/{post_id}" class="status__relative-time" target="_blank" rel="noopener noreferrer"><span class="status__visibility-icon"><i class="fa fa-globe" title="Публичный"></i></span><time datetime="{created_at}" title="{created_at}">{created_at}</time><abbr title="Последнее изменение: {edited_at}"> *</abbr></a>
<a href="https://{server_address}/@{name}" title="{name}" class="status__display-name" target="_blank" rel="noopener noreferrer">
<div class="status__avatar">
<div class="account__avatar" style="width: 46px; height: 46px;"><img src="{avatar}" alt="{name}"></div>
</div>
<span class="display-name"><bdi><strong class="display-name__html">{name}</strong></bdi> <span class="display-name__account">@{name}</span></span>
</a>
</div>
<div class="status__content status__content--with-action" tabindex="0">
<div class="status__content__text status__content__text--visible translate" lang="ru">
{content}
</div>
</div>
<div class="media-gallery" style="aspect-ratio: 1.77778 / 1;">
{media_attachments}
</div>
<div class="hashtag-bar"><a href="https://{server_address}/tags/Linux">#<span>Linux</span></a><a href="https://{server_address}/tags/MelawyLinux">#<span>MelawyLinux</span></a><a href="https://{server_address}/tags/ArchLinux">#<span>ArchLinux</span></a></div>
</div>
</div>
</div>
</article>

391
public/json/posts.json Normal file
View File

@ -0,0 +1,391 @@
[
{
"id": "111538833346981161",
"created_at": "2023-12-07T11:12:10.319Z",
"in_reply_to_id": null,
"in_reply_to_account_id": null,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"language": "ru",
"uri": "https://techhub.social/users/Melawy/statuses/111538833346981161",
"url": "https://techhub.social/@Melawy/111538833346981161",
"replies_count": 0,
"reblogs_count": 0,
"favourites_count": 0,
"edited_at": null,
"content": "",
"reblog": null,
"application": {
"name": "Web",
"website": null
},
"account": {
"id": "111518136987654656",
"username": "Melawy",
"acct": "Melawy",
"display_name": "Melawy",
"locked": false,
"bot": false,
"discoverable": true,
"group": false,
"created_at": "2023-12-03T00:00:00.000Z",
"note": "<p>Founder and developer: Melawy Linux<br />Software Developer: Rust, Python, JavaScript, SQL.<br />Linux, KVM, Docker, Git</p>",
"url": "https://techhub.social/@Melawy",
"uri": "https://techhub.social/users/Melawy",
"avatar": "https://files.techhub.social/accounts/avatars/111/518/136/987/654/656/original/1ec75ce936565914.png",
"avatar_static": "https://files.techhub.social/accounts/avatars/111/518/136/987/654/656/original/1ec75ce936565914.png",
"header": "https://files.techhub.social/accounts/headers/111/518/136/987/654/656/original/a93374adfeeb0662.png",
"header_static": "https://files.techhub.social/accounts/headers/111/518/136/987/654/656/original/a93374adfeeb0662.png",
"followers_count": 0,
"following_count": 0,
"statuses_count": 3,
"last_status_at": "2023-12-07",
"noindex": false,
"emojis": [],
"roles": [],
"fields": [
{
"name": "Сайт",
"value": "<a href=\"https://melawy.ru\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">melawy.ru</span><span class=\"invisible\"></span></a>",
"verified_at": "2023-12-03T19:52:31.690+00:00"
}
]
},
"media_attachments": [
{
"id": "111538832683581688",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/538/832/683/581/688/original/a87af6712ebac943.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/538/832/683/581/688/small/a87af6712ebac943.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UQ8}x;xbVXI:V@ofW=V@HqWAkXn$T0aei^o#"
},
{
"id": "111538833143434254",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/538/833/143/434/254/original/31007d4fbffbe64d.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/538/833/143/434/254/small/31007d4fbffbe64d.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UD7UoAnOt:NZM_bbaKnjHqkWQ+f5OsnOb^og"
}
],
"mentions": [],
"tags": [],
"emojis": [],
"card": null,
"poll": null
},
{
"id": "111538831710206486",
"created_at": "2023-12-07T11:11:45.344Z",
"in_reply_to_id": null,
"in_reply_to_account_id": null,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"language": "ru",
"uri": "https://techhub.social/users/Melawy/statuses/111538831710206486",
"url": "https://techhub.social/@Melawy/111538831710206486",
"replies_count": 0,
"reblogs_count": 0,
"favourites_count": 0,
"edited_at": null,
"content": "",
"reblog": null,
"application": {
"name": "Web",
"website": null
},
"account": {
"id": "111518136987654656",
"username": "Melawy",
"acct": "Melawy",
"display_name": "Melawy",
"locked": false,
"bot": false,
"discoverable": true,
"group": false,
"created_at": "2023-12-03T00:00:00.000Z",
"note": "<p>Founder and developer: Melawy Linux<br />Software Developer: Rust, Python, JavaScript, SQL.<br />Linux, KVM, Docker, Git</p>",
"url": "https://techhub.social/@Melawy",
"uri": "https://techhub.social/users/Melawy",
"avatar": "https://files.techhub.social/accounts/avatars/111/518/136/987/654/656/original/1ec75ce936565914.png",
"avatar_static": "https://files.techhub.social/accounts/avatars/111/518/136/987/654/656/original/1ec75ce936565914.png",
"header": "https://files.techhub.social/accounts/headers/111/518/136/987/654/656/original/a93374adfeeb0662.png",
"header_static": "https://files.techhub.social/accounts/headers/111/518/136/987/654/656/original/a93374adfeeb0662.png",
"followers_count": 0,
"following_count": 0,
"statuses_count": 3,
"last_status_at": "2023-12-07",
"noindex": false,
"emojis": [],
"roles": [],
"fields": [
{
"name": "Сайт",
"value": "<a href=\"https://melawy.ru\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">melawy.ru</span><span class=\"invisible\"></span></a>",
"verified_at": "2023-12-03T19:52:31.690+00:00"
}
]
},
"media_attachments": [
{
"id": "111538828810423496",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/538/828/810/423/496/original/49b1cde37f081e4a.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/538/828/810/423/496/small/49b1cde37f081e4a.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UW98Y|s9VsJ7V?ozbIV@L}X9bbn$TKaJe-o#"
},
{
"id": "111538829908799325",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/538/829/908/799/325/original/e8167b00d422e93c.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/538/829/908/799/325/small/e8167b00d422e93c.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UI8}fLxvVrE1V=o#X9VsHqRObat7PBaJi^o~"
},
{
"id": "111538830509113563",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/538/830/509/113/563/original/5d3cc1d1855046cf.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/538/830/509/113/563/small/5d3cc1d1855046cf.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UF8}Gc%OXB9XX8oJWXV?DNROaItRNEg3jYt8"
},
{
"id": "111538831262228419",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/538/831/262/228/419/original/cd416011a585b7a3.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/538/831/262/228/419/small/cd416011a585b7a3.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UM72p:Q+Z~XnROo#bcadL}pJbvi^TeivaJo#"
}
],
"mentions": [],
"tags": [],
"emojis": [],
"card": null,
"poll": null
},
{
"id": "111518300393041393",
"created_at": "2023-12-03T20:10:22.306Z",
"in_reply_to_id": null,
"in_reply_to_account_id": null,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"language": "ru",
"uri": "https://techhub.social/users/Melawy/statuses/111518300393041393",
"url": "https://techhub.social/@Melawy/111518300393041393",
"replies_count": 0,
"reblogs_count": 0,
"favourites_count": 0,
"edited_at": "2023-12-06T22:56:01.225Z",
"content": "<p>Melawy Linux - дистрибутив операционной системы Linux, основанный на пакетной базе Arch Linux, установщике Calamares, с индивидуально разработанным оформлением под загрузчик rEFInd, экран загрузки Plymouth, менеджер входа в систему SDDM, рабочий стол KDE Plasma.</p><p>Продукт является открытым программным обеспечением со свободной лицензией.</p><p>Проект нацелен на сегмент ПК и ноутбуков.</p><p>Приглашаем энтузиастов для совместной разработки, тестирования программ и оформления.</p><p>Проект начался в апреле 2022 года и спустя более 1,5 лет разработки дистрибутив увидел свет.</p><p>Скачать -&gt; <a href=\"https://melawy.ru\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">melawy.ru</span><span class=\"invisible\"></span></a></p><p>Установка на виртуальную машину -&gt; <a href=\"https://www.youtube.com/watch?v=waCnwyxdSS0\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">youtube.com/watch?v=waCnwyxdSS</span><span class=\"invisible\">0</span></a></p><p><a href=\"https://techhub.social/tags/Linux\" class=\"mention hashtag\" rel=\"tag\">#<span>Linux</span></a> <a href=\"https://techhub.social/tags/MelawyLinux\" class=\"mention hashtag\" rel=\"tag\">#<span>MelawyLinux</span></a> <a href=\"https://techhub.social/tags/ArchLinux\" class=\"mention hashtag\" rel=\"tag\">#<span>ArchLinux</span></a></p>",
"reblog": null,
"application": {
"name": "Web",
"website": null
},
"account": {
"id": "111518136987654656",
"username": "Melawy",
"acct": "Melawy",
"display_name": "Melawy",
"locked": false,
"bot": false,
"discoverable": true,
"group": false,
"created_at": "2023-12-03T00:00:00.000Z",
"note": "<p>Founder and developer: Melawy Linux<br />Software Developer: Rust, Python, JavaScript, SQL.<br />Linux, KVM, Docker, Git</p>",
"url": "https://techhub.social/@Melawy",
"uri": "https://techhub.social/users/Melawy",
"avatar": "https://files.techhub.social/accounts/avatars/111/518/136/987/654/656/original/1ec75ce936565914.png",
"avatar_static": "https://files.techhub.social/accounts/avatars/111/518/136/987/654/656/original/1ec75ce936565914.png",
"header": "https://files.techhub.social/accounts/headers/111/518/136/987/654/656/original/a93374adfeeb0662.png",
"header_static": "https://files.techhub.social/accounts/headers/111/518/136/987/654/656/original/a93374adfeeb0662.png",
"followers_count": 0,
"following_count": 0,
"statuses_count": 3,
"last_status_at": "2023-12-07",
"noindex": false,
"emojis": [],
"roles": [],
"fields": [
{
"name": "Сайт",
"value": "<a href=\"https://melawy.ru\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">melawy.ru</span><span class=\"invisible\"></span></a>",
"verified_at": "2023-12-03T19:52:31.690+00:00"
}
]
},
"media_attachments": [
{
"id": "111535938147168430",
"type": "image",
"url": "https://files.techhub.social/media_attachments/files/111/535/938/147/168/430/original/c02c9ef9b944fca3.png",
"preview_url": "https://files.techhub.social/media_attachments/files/111/535/938/147/168/430/small/c02c9ef9b944fca3.png",
"remote_url": null,
"preview_remote_url": null,
"text_url": null,
"meta": {
"original": {
"width": 1920,
"height": 1080,
"size": "1920x1080",
"aspect": 1.7777777777777777
},
"small": {
"width": 640,
"height": 360,
"size": "640x360",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": "UGC$[z4n01?II;R%Rj%gIUxaxuR*%Ma}IUxa"
}
],
"mentions": [],
"tags": [
{
"name": "linux",
"url": "https://techhub.social/tags/linux"
},
{
"name": "melawylinux",
"url": "https://techhub.social/tags/melawylinux"
},
{
"name": "archlinux",
"url": "https://techhub.social/tags/archlinux"
}
],
"emojis": [],
"card": {
"url": "https://melawy.ru",
"title": "Melawy Linux",
"description": "Melawy Linux - Arch Linux based distro",
"language": "ru",
"type": "link",
"author_name": "",
"author_url": "",
"provider_name": "Melawy Linux",
"provider_url": "",
"html": "",
"width": 512,
"height": 512,
"image": "https://files.techhub.social/cache/preview_cards/images/015/283/057/original/ca9748708815ce66.png",
"image_description": "",
"embed_url": "",
"blurhash": "UfL3M_wJ.mX8kDs9n%Shy?W;^+a{NZShj]wJ",
"published_at": null
},
"poll": null
}
]

1294
public/json/theme.css Normal file

File diff suppressed because one or more lines are too long