mirror of
https://codeberg.org/kirche-im-netz/Startodon-Hub.git
synced 2025-07-31 16:24:33 +02:00
Alles via kirche.social laden
Gleicher Anbieter (LUKi), daher kein Datenschutzpopup notwendig
This commit is contained in:
parent
47460e0104
commit
089183abd8
18 changed files with 55 additions and 235 deletions
3
.domains
3
.domains
|
@ -1,2 +1 @@
|
|||
https://fedikirche.de
|
||||
https://www.fedikirche.de
|
||||
csett86.codeberg.page
|
|
@ -3,15 +3,8 @@ import { checkConsent, showConsentPopup, setUserConsent } from '../components/co
|
|||
export async function loadPostwall() {
|
||||
const container = document.getElementById('postswall-container');
|
||||
|
||||
// Überprüfe, ob Consent erteilt wurde
|
||||
if (!checkConsent()) {
|
||||
// Consent nicht erteilt – alternative Kachel anzeigen
|
||||
renderConsentRequest();
|
||||
return; // Beende die Funktion, kein weiterer Datenabruf
|
||||
}
|
||||
|
||||
// Mastodon API-URL für Hashtag-Suche
|
||||
const apiUrl = 'https://libori.social/api/v1/timelines/tag/fedikirche?limit=20';
|
||||
const apiUrl = 'https://kirche.social/api/v1/timelines/tag/fedikirche?limit=20';
|
||||
|
||||
// Posts laden
|
||||
async function fetchPosts() {
|
||||
|
@ -106,54 +99,6 @@ export async function loadPostwall() {
|
|||
fetchPosts();
|
||||
}
|
||||
|
||||
// Alternative Kachel anzeigen, wenn kein Consent erteilt wurde
|
||||
function renderConsentRequest() {
|
||||
const container = document.getElementById('postswall-container');
|
||||
container.innerHTML = ''; // Vorherige Inhalte leeren
|
||||
|
||||
const consentCard = document.createElement('div');
|
||||
consentCard.classList.add('post'); // Verwendet die Post-Klasse für Konsistenz
|
||||
|
||||
consentCard.innerHTML = `
|
||||
<div class="post-header">
|
||||
<!-- Skeleton-Loader für Avatar -->
|
||||
<div class="skeleton avatar-skeleton"></div>
|
||||
|
||||
<!-- Skeleton-Loader für Autor und Username -->
|
||||
<div class="post-author">
|
||||
<div class="skeleton skeleton-text skeleton-text-name"></div>
|
||||
<div class="skeleton skeleton-text skeleton-text-username"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="post-content">
|
||||
<p>Du musst zuerst zustimmen, um Inhalte anzuzeigen.</p>
|
||||
<div class="consent-buttons">
|
||||
<button id="open-consent-popup" class="btn">Datenschutzeinstellungen öffnen</button>
|
||||
<a href="https://libori.social/tags/fedikirche" target="_blank" rel="noopener noreferrer">
|
||||
<button class="btn">Beiträge auf Mastodon ansehen</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
container.appendChild(consentCard);
|
||||
|
||||
// Event-Listener für Button zum erneuten Anzeigen des Consent-Popups
|
||||
document.getElementById('open-consent-popup').addEventListener('click', () => {
|
||||
showConsentPopup(
|
||||
() => {
|
||||
setUserConsent(true); // Zustimmung speichern
|
||||
loadPostwall(); // Nachträglich Posts laden
|
||||
},
|
||||
() => {
|
||||
setUserConsent(false); // Ablehnung speichern
|
||||
console.log('Consent abgelehnt');
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Zeitberechnung für Posts
|
||||
function getTimeAgo(date) {
|
||||
const now = new Date();
|
||||
|
@ -177,7 +122,7 @@ function getTimeAgo(date) {
|
|||
function addReadMoreButton() {
|
||||
const container = document.getElementById('postswall-container');
|
||||
const readMoreButton = document.createElement('a');
|
||||
readMoreButton.href = 'https://libori.social/tags/fedikirche';
|
||||
readMoreButton.href = 'https://kirche.social/tags/fedikirche';
|
||||
readMoreButton.target = '_blank';
|
||||
readMoreButton.rel = 'noopener noreferrer';
|
||||
readMoreButton.classList.add('read-more-button');
|
||||
|
|
14
src/main.js
14
src/main.js
|
@ -2,24 +2,10 @@ import { createStarterKitElement, enhanceStarterKits } from './utils/starterkit-
|
|||
import { seededShuffleChildren } from './utils/shuffle-utils.js';
|
||||
import { initializeCreateStarterKitPopup } from './utils/create-starterkit.js';
|
||||
import { loadPostwall } from './components/postwall.js';
|
||||
import { checkConsent, setUserConsent, showConsentPopup } from './components/consentManager.js';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async function () {
|
||||
// Starte sofort den Seitenaufbau
|
||||
initializeSite();
|
||||
|
||||
// Überprüfe parallel den Consent-Status
|
||||
const consent = checkConsent();
|
||||
if (!consent) {
|
||||
showConsentPopup(
|
||||
() => {
|
||||
setUserConsent(true);
|
||||
},
|
||||
() => {
|
||||
setUserConsent(false);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
async function initializeSite() {
|
||||
|
|
|
@ -10,7 +10,7 @@ export function getServerClass(instance) {
|
|||
|
||||
export function extractHostname(url) {
|
||||
try {
|
||||
const hostname = url.match(/^https?:\/\/([^\/]+)/i)[1]; // Regex: extrahiert den Hostnamen
|
||||
const hostname = url.split('@')[1];
|
||||
return hostname;
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Extrahieren des Hostnamens:', error, 'URL:', url);
|
||||
|
|
|
@ -1,37 +1,16 @@
|
|||
import { getServerClass } from './instances.js';
|
||||
|
||||
export async function fetchProfile(profileUrl, options = {}) {
|
||||
const { updateElement = null, createCard = false } = options;
|
||||
export async function fetchProfile(handle, options = {}) {
|
||||
const { returnData = null, createCard = false } = options;
|
||||
|
||||
try {
|
||||
const url = new URL(profileUrl);
|
||||
const data = await fetchProfileViaMastodon(handle);
|
||||
|
||||
// Schritt 1: Plattform-Erkennung
|
||||
const platform = await detectPlatform(url);
|
||||
|
||||
// Schritt 2: Profil-Daten abrufen
|
||||
let data;
|
||||
if (platform === 'mastodon') {
|
||||
data = await fetchMastodonProfile(url);
|
||||
} else if (platform === 'wordpress') {
|
||||
data = await fetchWordpressProfile(url);
|
||||
} else {
|
||||
throw new Error('Unbekannte Plattform');
|
||||
}
|
||||
|
||||
// Schritt 3: Ausgabe vorbereiten
|
||||
if (updateElement) {
|
||||
updateElement.textContent = data.display_name || data.name || data.username;
|
||||
|
||||
const avatarImage = document.createElement('img');
|
||||
avatarImage.classList.add('account-avatar');
|
||||
avatarImage.alt = data.display_name || data.name || 'Profilbild nicht verfügbar';
|
||||
avatarImage.src = data.avatar || data.icon?.url || '';
|
||||
|
||||
updateElement.prepend(avatarImage);
|
||||
if (returnData) {
|
||||
return data;
|
||||
} else if (createCard) {
|
||||
const card = createAccountCard(data, profileUrl, url.hostname);
|
||||
const url = new URL(data.url);
|
||||
const card = createAccountCard(data, data.url, url.hostname);
|
||||
return { card, data };
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -40,81 +19,14 @@ export async function fetchProfile(profileUrl, options = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function detectPlatform(url) {
|
||||
// Test auf Mastodon-API
|
||||
try {
|
||||
const mastodonTest = await fetch(`${url.origin}/api/v1/instance`);
|
||||
if (mastodonTest.ok) return 'mastodon';
|
||||
} catch (error) {
|
||||
console.warn('Fehler beim Mastodon-Test:', error);
|
||||
}
|
||||
|
||||
// Test auf WordPress-ActivityPub
|
||||
try {
|
||||
const wpTest = await fetch(`${url.origin}/wp-json/activitypub/1.0/actors/1`, {
|
||||
headers: { Accept: 'application/activity+json' }
|
||||
});
|
||||
if (wpTest.ok) return 'wordpress';
|
||||
} catch (error) {
|
||||
console.warn('Fehler beim WordPress-Test:', error);
|
||||
}
|
||||
|
||||
// Fallback, wenn kein Test erfolgreich war
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
async function fetchMastodonProfile(url) {
|
||||
const handle = url.pathname.split('/')[1].substring(1);
|
||||
const lookupUrl = `https://${url.hostname}/api/v1/accounts/lookup?acct=${handle}`;
|
||||
async function fetchProfileViaMastodon(handle) {
|
||||
const lookupUrl = `https://kirche.social/api/v1/accounts/lookup?acct=${handle}`;
|
||||
|
||||
const response = await fetch(lookupUrl);
|
||||
if (!response.ok) throw new Error('Mastodon-Profil nicht gefunden');
|
||||
if (!response.ok) throw new Error(`Mastodon-Profil ${handle} nicht gefunden`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
async function fetchWordpressProfile(url) {
|
||||
const actorId = url.pathname.split('/').pop(); // ID aus der URL extrahieren
|
||||
const lookupUrl = `${url.origin}/${actorId}`;
|
||||
|
||||
const response = await fetch(lookupUrl, {
|
||||
headers: { Accept: 'application/activity+json' }
|
||||
});
|
||||
if (!response.ok) throw new Error('WordPress-Profil nicht gefunden');
|
||||
const data = await response.json();
|
||||
|
||||
// Letzten Post aus der Outbox holen
|
||||
const lastPostDate = await fetchWordpressLastPost(data.outbox);
|
||||
|
||||
// Kompatibilität herstellen
|
||||
return {
|
||||
username: data.preferredUsername,
|
||||
display_name: data.name,
|
||||
avatar: data.icon?.url,
|
||||
note: data.summary,
|
||||
followers_count: data.followers ? data.followers.length : 0,
|
||||
last_status_at: lastPostDate || data.published,
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchWordpressLastPost(outboxUrl) {
|
||||
try {
|
||||
const response = await fetch(`${outboxUrl}?page=1`, {
|
||||
headers: { Accept: 'application/activity+json' }
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Outbox konnte nicht geladen werden');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.orderedItems && data.orderedItems.length > 0) {
|
||||
const latestPost = data.orderedItems[0];
|
||||
return latestPost.published || latestPost.object.published;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Fehler beim Abrufen des letzten Beitrags:', error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function createAccountCard(data, href, instance) {
|
||||
const serverClass = getServerClass(instance);
|
||||
const link = document.createElement('a');
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { fetchProfile } from './profile-utils.js';
|
||||
import { extractHostname, getServerClass } from './instances.js';
|
||||
import { checkConsent } from '../components/consentManager.js';
|
||||
|
||||
export function createRecommendationPopup(accounts, title, authors, description) {
|
||||
const template = document.getElementById('popup-template').content.cloneNode(true);
|
||||
|
@ -116,17 +115,17 @@ export function populateAuthorsContainer(authorsContainer, authors) {
|
|||
|
||||
authorsToShow.forEach(author => {
|
||||
const authorLink = document.createElement('a');
|
||||
authorLink.href = author;
|
||||
authorLink.classList.add('account');
|
||||
authorLink.target = '_blank'; // Link öffnet neues Fenster
|
||||
|
||||
// Consent prüfen
|
||||
if (checkConsent()) {
|
||||
// Consent erteilt - Profilbild laden
|
||||
fetchProfile(author, { updateElement: authorLink }).then(() => {
|
||||
const avatarImage = authorLink.querySelector('.account-avatar');
|
||||
if (avatarImage) {
|
||||
authorLink.textContent = '';
|
||||
fetchProfile(author, { returnData: true }).then((data) => {
|
||||
authorLink.href = data.url;
|
||||
|
||||
const avatarImage = document.createElement('img');
|
||||
avatarImage.classList.add('account-avatar');
|
||||
avatarImage.alt = data.display_name || data.name || 'Profilbild nicht verfügbar';
|
||||
avatarImage.src = data.avatar || '';
|
||||
|
||||
authorLink.appendChild(avatarImage);
|
||||
|
||||
// Server-Klasse für Avatar hinzufügen
|
||||
|
@ -135,14 +134,7 @@ export function populateAuthorsContainer(authorsContainer, authors) {
|
|||
if (serverClass) {
|
||||
avatarImage.classList.add(serverClass);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Kein Consent – Skeleton-Loader anzeigen
|
||||
const skeletonAvatar = document.createElement('div');
|
||||
skeletonAvatar.classList.add('skeleton', 'avatar-skeleton', 'account-avatar');
|
||||
authorLink.appendChild(skeletonAvatar);
|
||||
}
|
||||
|
||||
authorsContainer.appendChild(authorLink);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { createRecommendationPopup, populateAuthorsContainer } from './recommendations-utils.js';
|
||||
import { checkConsent, showConsentPopup, setUserConsent } from '../components/consentManager.js';
|
||||
|
||||
// StarterKit-Element erstellen
|
||||
export function createStarterKitElement(kit) {
|
||||
|
@ -23,6 +22,7 @@ export function createStarterKitElement(kit) {
|
|||
|
||||
populateAuthorsContainer(authorsContainer, kit.authors);
|
||||
kitElement.dataset.accounts = JSON.stringify(kit.accounts);
|
||||
kitElement.dataset.authors = JSON.stringify(kit.authors);
|
||||
|
||||
return kitElement;
|
||||
}
|
||||
|
@ -40,21 +40,7 @@ export function enhanceStarterKits() {
|
|||
|
||||
// StarterKit-Klick behandeln
|
||||
function handleStarterKitClick(kit) {
|
||||
if (checkConsent()) {
|
||||
// Zustimmung vorhanden – StarterKit-Popup öffnen
|
||||
loadStarterKitProfiles(kit);
|
||||
} else {
|
||||
// Keine Zustimmung – Consent-Popup anzeigen
|
||||
showConsentPopup(
|
||||
() => {
|
||||
setUserConsent(true); // Zustimmung speichern
|
||||
loadStarterKitProfiles(kit); // Nachträglich StarterKit-Popup öffnen
|
||||
},
|
||||
() => {
|
||||
console.log('Consent wurde abgelehnt. StarterKit-Popup wird nicht geöffnet.');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// StarterKit-Profile laden
|
||||
|
@ -62,7 +48,7 @@ function loadStarterKitProfiles(kit) {
|
|||
const title = kit.querySelector('h3').textContent;
|
||||
const description = kit.querySelector('p').textContent;
|
||||
const accounts = JSON.parse(kit.dataset.accounts || '[]');
|
||||
const authors = Array.from(kit.querySelectorAll('.authors-container .account')).map(author => author.href);
|
||||
const authors = JSON.parse(kit.dataset.authors || '[]');
|
||||
|
||||
const popup = createRecommendationPopup(accounts, title, authors, description);
|
||||
document.body.appendChild(popup);
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
"name": "100 Morgen Wald",
|
||||
"description": "Bildung, viel Bildung.\n",
|
||||
"authors": [
|
||||
"https://kirche.social/@frau_sanders"
|
||||
"frau_sanders@kirche.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://social.tchncs.de/@kuketzblog",
|
||||
"https://mastodon.social/@bahnkundenv",
|
||||
"https://sueden.social/@BlumeEvolution",
|
||||
"https://artikel91.eu/@fxneumann",
|
||||
"https://social.bund.de/@DLR",
|
||||
"https://mastodon.social/@sundogplanets",
|
||||
"https://linuxhotel.social/@linuxhotel",
|
||||
"https://mastodon.art/@Fuchskind",
|
||||
"https://chaos.social/@leah",
|
||||
"https://hostsharing.coop/@Pflege42",
|
||||
"https://chaos.social/@irgendwiejuna"
|
||||
"kuketzblog@social.tchncs.de",
|
||||
"bahnkundenv@mastodon.social",
|
||||
"BlumeEvolution@sueden.social",
|
||||
"fxneumann@artikel91.eu",
|
||||
"DLR@social.bund.de",
|
||||
"sundogplanets@mastodon.social",
|
||||
"linuxhotel@linuxhotel.social",
|
||||
"Fuchskind@mastodon.art",
|
||||
"leah@chaos.social",
|
||||
"Pflege42@hostsharing.coop",
|
||||
"irgendwiejuna@chaos.social"
|
||||
]
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
"name": "tägliche Impulse",
|
||||
"description": "Tägliche spirituelle Impulse – Inspiration und Besinnung für deinen Alltag.",
|
||||
"authors": [
|
||||
"https://kirche.social/@frau_sanders"
|
||||
"frau_sanders@kirche.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://kirche.social/@morgengebet",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Erzbistum Paderborn",
|
||||
"description": "Menschen, Institutionen und Initiativen aus dem Erzbistum Paderborn.",
|
||||
"authors": [
|
||||
"https://libori.social/@alex"
|
||||
"alex@libori.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://libori.social/@news_erzbistum_paderborn",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "#FediKirche",
|
||||
"description": "Accounts rund um #FediKirche – engagiert für die Stärkung der kirchlichen Community im Fediverse.",
|
||||
"authors": [
|
||||
"https://libori.social/@alex"
|
||||
"alex@libori.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://reliverse.social/@comenius",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Inklusion",
|
||||
"description": "Dickes Brett. Hier bohren schon einige.\nEs geht um Gerechtigkeit, Freiheit und Bildung. Es geht um Inklusion. Für alle.",
|
||||
"authors": [
|
||||
"https://kirche.social/@frau_sanders"
|
||||
"frau_sanders@kirche.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://mastodon.cloud/@RaulKrauthausen",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "katholisch",
|
||||
"description": "Eine vielseitige Auswahl aus dem katholischen Umfeld – von engagierten Gläubigen und theologischen Stimmen bis hin zu verschiedenen Bistümern, Institutionen und Einrichtungen.",
|
||||
"authors": [
|
||||
"https://libori.social/@alex"
|
||||
"alex@libori.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://libori.social/@news_erzbistum_paderborn",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Nachrichten, Meinungen & Analysen",
|
||||
"description": "Redaktionen mit eigenen Inhalten – von Nachrichten und Analysen bis hin zu Meinungsbeiträgen und Hintergrundberichten. Ideal für alle, die fundierte Informationen und journalistische Perspektiven aus erster Hand schätzen.",
|
||||
"authors": [
|
||||
"https://libori.social/@alex"
|
||||
"alex@libori.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://mastodon.social/@eulemagazin",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "religionsbezogene Bildung",
|
||||
"description": "Eine bunte Auswahl an Profilen zur religionsbezogenen Bildung – von pädagogischen Konzepten und theologischen Impulsen bis zu Projekten, die Dialog und Lernen über Religion fördern.",
|
||||
"authors": [
|
||||
"https://reliverse.social/@joerglohrer"
|
||||
"joerglohrer@reliverse.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://reliverse.social/@heller",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Vereine und Initiativen",
|
||||
"description": "Kirchliche Vereine und Initiativen – von Bibelprojekten und Gemeindegründungen bis hin zu ökumenischen Projekten und Linux in der Kirche. Entdecke Vielfalt und Engagement!",
|
||||
"authors": [
|
||||
"https://libori.social/@alex"
|
||||
"alex@libori.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://kirche.social/@offenebibel",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Evangelische Kirchengemeinden, Dekanate und Kirchspiele",
|
||||
"description": "Eine Liste von evangelischen Kirchengemeinden, Dekanaten und Kirchspielen.\nFehlt etwas? Wir sind für Info dankbar.",
|
||||
"authors": [
|
||||
"https://kirche.social/@onlinekirche"
|
||||
"onlinekirche@kirche.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://kirche.social/@campusgemeinde",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Gemeinden und so",
|
||||
"description": "Kirche auf Feldebene, katholisch und evangelisch: Pfarr-/Kirchengemeinden, Kirchspiele, Pastoralverbünde, pastorale Räume etc.",
|
||||
"authors": [
|
||||
"https://katholisch.social/@pvpv"
|
||||
"pvpv@katholisch.social"
|
||||
],
|
||||
"accounts": [
|
||||
"https://libori.social/@attendorn_katholisch",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue