forked from vgaNAR6ta/drags-and-nerds
edit: lien entre panneau à propos et mastodon pour permettre à artiste et orga d'y déposer du contenu
This commit is contained in:
@@ -1,4 +1,173 @@
|
||||
export async function loadPeopleData() {
|
||||
const pData = await fetch('./DATA/peopleData.json');
|
||||
return await pData.json();
|
||||
function idAndDate(str){
|
||||
let data = str.split("T");
|
||||
let date = data[0].split("-");
|
||||
return {
|
||||
date: date[2] +'/'+ date[1],
|
||||
id: date[2] + date[1]
|
||||
}
|
||||
}
|
||||
|
||||
function inlineContent(str){
|
||||
let data = str.split("<br>");
|
||||
let content = "";
|
||||
for (let line of data){
|
||||
content += line + '\n';
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
function titleAndContent(str){
|
||||
let data = str.split(" :");
|
||||
let title = data[0];
|
||||
let contentData = data[1].split("<br>").filter(e => e);
|
||||
let content = "";
|
||||
let src = [];
|
||||
for(let line of contentData){
|
||||
if(line.includes('http')){
|
||||
let linkData = line.split("@");
|
||||
let linkNoFormat = linkData[1].split("\"");
|
||||
let url = "";
|
||||
for(let el of linkNoFormat){
|
||||
if(el.includes('http')){
|
||||
url = el;
|
||||
break
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
src.push({
|
||||
caption: linkData[0],
|
||||
url: url
|
||||
})
|
||||
} else {
|
||||
content += line + '\n';
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: title,
|
||||
content: content,
|
||||
links: src,
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadPeopleData() {
|
||||
const usernamesRes = await fetch('./DATA/peopleData.json');
|
||||
const pData = await usernamesRes.json();
|
||||
const res = await fetch("https://pouet.drags-nerds.net/api/v1/timelines/public?local=true&limit=40");
|
||||
|
||||
if (!res.ok)
|
||||
throw new Error(`Server responded with ${res.status} ${res.statusText}`);
|
||||
|
||||
const pouets = await res.json();
|
||||
const filtered = pouets.filter(p => pData.some(user => p.account.display_name === user.name));
|
||||
const files = {};
|
||||
for (const user of pData) {
|
||||
files[user.name] = [];
|
||||
}
|
||||
const description = {};
|
||||
for (const user of pData){
|
||||
const pouet = filtered.find(p => p.account.display_name === user.name);
|
||||
if (pouet){
|
||||
description[user.name] = pouet.account.note;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pouet of filtered) {
|
||||
const username = pouet.account.display_name;
|
||||
let infos = idAndDate(pouet.created_at);
|
||||
let entry;
|
||||
|
||||
//ignorer autres que images
|
||||
if (pouet.media_attachments?.length > 0 &&
|
||||
!pouet.media_attachments[0].type.includes('image')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pouet.content.includes('http')) {
|
||||
let textInfos = titleAndContent(pouet.content);
|
||||
entry = {
|
||||
id: 'link' + username + infos.id,
|
||||
date: infos.date,
|
||||
dateInfo: pouet.created_at,
|
||||
type: "link",
|
||||
author: username,
|
||||
caption: textInfos.title + '.liens',
|
||||
links: textInfos.links,
|
||||
description: textInfos.content,
|
||||
isSelected: false
|
||||
};
|
||||
} else if (pouet.media_attachments?.length > 0) {
|
||||
let textInfos = titleAndContent(pouet.content);
|
||||
entry = {
|
||||
id: 'img' + username + infos.id,
|
||||
date: infos.date,
|
||||
dateInfo: pouet.created_at,
|
||||
type: "image",
|
||||
author: username,
|
||||
caption: textInfos.title + '.star',
|
||||
src: pouet.media_attachments[0].url,
|
||||
description: textInfos.content,
|
||||
like: pouet.favourites_count,
|
||||
isSelected: false
|
||||
}
|
||||
} else {
|
||||
let textInfos = titleAndContent(pouet.content);
|
||||
entry = {
|
||||
id: 'txt' + username + infos.id,
|
||||
date: infos.date,
|
||||
dateInfo: pouet.created_at,
|
||||
type: "text",
|
||||
author: username,
|
||||
caption: textInfos.title + '.msg',
|
||||
description: textInfos.content,
|
||||
isSelected: false
|
||||
};
|
||||
}
|
||||
files[username].push(entry);
|
||||
}
|
||||
|
||||
const dragContent = pData.filter(user => user.folder === 0).map(user => (
|
||||
{
|
||||
type: "folder",
|
||||
caption: user.name + '.info',
|
||||
children: files[user.name],
|
||||
description: description[user.name],
|
||||
isSelected: false
|
||||
}));
|
||||
const nerdContent = pData.filter(user => user.folder === 1).map(user => (
|
||||
{
|
||||
type: "folder",
|
||||
caption: user.name + '.info',
|
||||
children: files[user.name],
|
||||
description: description[user.name],
|
||||
isSelected: false
|
||||
}));
|
||||
|
||||
const otherContent = pData.filter(user => user.folder === 2).flatMap(user => files[user.name]);
|
||||
|
||||
|
||||
const sortedContent = [
|
||||
{
|
||||
type: "folder",
|
||||
caption : "Artistes Drags",
|
||||
description:"Pour en savoir plus sur nos artistes drags, c'est par ici !",
|
||||
children: dragContent,
|
||||
isSelected: false
|
||||
},
|
||||
{
|
||||
type: "folder",
|
||||
caption : "Artistes Nerds",
|
||||
description:"Pour en savoir plus sur nos artistes nerds, c'est par là !",
|
||||
children: nerdContent,
|
||||
isSelected: false
|
||||
},
|
||||
{
|
||||
type: "folder",
|
||||
caption : "Autres contenus",
|
||||
description:"Dans cette section, on place pleins de contenu, en vrac, \n sur nous, nos copaines, des trucs qu'on trouve cool, etc.",
|
||||
children: otherContent,
|
||||
isSelected: false
|
||||
}
|
||||
];
|
||||
return sortedContent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user