forked from vgaNAR6ta/drags-and-nerds
edit: intégration video mastodon + bug fix liens
This commit is contained in:
@@ -22,25 +22,16 @@ function titleAndContent(str){
|
||||
for(let line of contentData){
|
||||
if(line.includes('http')||line.includes('@')){
|
||||
let linkData = line.split("# ");
|
||||
//console.log(title, linkData);
|
||||
console.log(linkData[1]);
|
||||
let linkNoFormat;
|
||||
if (linkData.includes('http')){
|
||||
linkNoFormat = linkData[1].split("\"");
|
||||
} else {
|
||||
linkNoFormat = linkData[0]
|
||||
}
|
||||
let url = "";
|
||||
for(let el of linkNoFormat){
|
||||
if(el.includes('http')){
|
||||
url = el;
|
||||
break
|
||||
} else if(el.includes('@')){
|
||||
url = 'mailto:' + el;
|
||||
break
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
if (linkData[1].includes('http')){
|
||||
linkNoFormat = linkData[1].split("\"");
|
||||
url = linkNoFormat[1];
|
||||
} else if (linkData[1].includes('@')){
|
||||
url = 'mailto:' + linkData[1];
|
||||
}
|
||||
console.log("url info", url)
|
||||
src.push({
|
||||
caption: linkData[0],
|
||||
url: url
|
||||
@@ -70,6 +61,11 @@ function exceptionKey(user, content){
|
||||
return false;
|
||||
}
|
||||
|
||||
function videoExt(str){
|
||||
let data = str.split('.');
|
||||
return data.at(-1)
|
||||
}
|
||||
|
||||
export async function loadPeopleData() {
|
||||
const usernamesRes = await fetch('/DATA/peopleData.json');
|
||||
const pData = await usernamesRes.json();
|
||||
@@ -110,7 +106,8 @@ export async function loadPeopleData() {
|
||||
//console.log(pouet);
|
||||
//ignorer autres que images
|
||||
if (selectedPouet.media_attachments?.length > 0 &&
|
||||
!pouet.media_attachments[0].type.includes('image')) {
|
||||
!pouet.media_attachments[0].type.includes('image') &&
|
||||
!pouet.media_attachments[0].type.includes('video')) {
|
||||
continue;
|
||||
}
|
||||
//ignorer réponses
|
||||
@@ -140,18 +137,37 @@ export async function loadPeopleData() {
|
||||
} else if (selectedPouet.media_attachments?.length > 0) {
|
||||
let textInfos = titleAndContent(selectedPouet.content);
|
||||
//console.log(pouet);
|
||||
entry = {
|
||||
id: 'img' + displayName + infos.id,
|
||||
date: infos.date,
|
||||
dateInfo: selectedPouet.created_at,
|
||||
type: "image",
|
||||
author: displayName,
|
||||
caption: textInfos.title + '.star',
|
||||
src: selectedPouet.media_attachments[0].url,
|
||||
alt: selectedPouet.media_attachments[0].description,
|
||||
description: textInfos.content,
|
||||
like: selectedPouet.favourites_count,
|
||||
isSelected: false
|
||||
if (pouet.media_attachments[0].type.includes('image')){
|
||||
entry = {
|
||||
id: 'img' + displayName + infos.id,
|
||||
date: infos.date,
|
||||
dateInfo: selectedPouet.created_at,
|
||||
type: "image",
|
||||
author: displayName,
|
||||
caption: textInfos.title + '.star',
|
||||
src: selectedPouet.media_attachments[0].url,
|
||||
alt: selectedPouet.media_attachments[0].description,
|
||||
description: textInfos.content,
|
||||
like: selectedPouet.favourites_count,
|
||||
isSelected: false
|
||||
}
|
||||
}
|
||||
if (pouet.media_attachments[0].type.includes('video')){
|
||||
let videoType = videoExt(selectedPouet.media_attachments[0].url)
|
||||
entry = {
|
||||
id: 'vid' + displayName + infos.id,
|
||||
date: infos.date,
|
||||
dateInfo: selectedPouet.created_at,
|
||||
type: "video",
|
||||
format: selectedPouet.media_attachments[0].type + '/' + videoType,
|
||||
author: displayName,
|
||||
caption: textInfos.title + '.move',
|
||||
src: selectedPouet.media_attachments[0].url,
|
||||
alt: selectedPouet.media_attachments[0].description,
|
||||
description: textInfos.content,
|
||||
like: selectedPouet.favourites_count,
|
||||
isSelected: false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let textInfos = titleAndContent(selectedPouet.content);
|
||||
@@ -166,6 +182,7 @@ export async function loadPeopleData() {
|
||||
isSelected: false
|
||||
};
|
||||
}
|
||||
//console.log(entry);
|
||||
files[username].push(entry);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user