mirror of
https://github.com/ProjectSegfault/website.git
synced 2025-05-31 14:12:04 +05:30
migrate to segfaultapi
This commit is contained in:
@@ -1,124 +0,0 @@
|
||||
<script lang="ts">
|
||||
import fetchState from "$lib/fetchState";
|
||||
|
||||
import Note from "$lib/Form/Note.svelte";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
let announcements: any = [];
|
||||
async function fetchAnnouncements() {
|
||||
const url = `https://segfautils.projectsegfau.lt/api/announcements`;
|
||||
const response = await fetch(url);
|
||||
announcements = await response.json();
|
||||
return announcements;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#await fetchState("announcements") then state}
|
||||
{#if state.enabled === "true"}
|
||||
<div class="announcements">
|
||||
{#await fetchAnnouncements() then announcements}
|
||||
<div class="announcement-container">
|
||||
<div class="announcement">
|
||||
<div class="general">
|
||||
{#if announcements.severity === "info"}
|
||||
<div class="i-fa6-solid:circle-info" />
|
||||
{:else}
|
||||
<div class="i-fa6-solid:triangle-exclamation" />
|
||||
{/if}
|
||||
<span>
|
||||
{dayjs
|
||||
.unix(announcements.created)
|
||||
.format("DD/MM/YYYY HH:mm")}
|
||||
</span>
|
||||
</div>
|
||||
<div class="title">
|
||||
<span class="text-xl font-semibold">{announcements.title}</span>
|
||||
</div>
|
||||
|
||||
{#if announcements.link}
|
||||
<div class="read-more">
|
||||
<a href={announcements.link}>Read more...</a>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/await}
|
||||
</div>
|
||||
|
||||
<noscript>
|
||||
<div class="no-js">
|
||||
<Note
|
||||
content="Announcements do not work without JavaScript enabled."
|
||||
/>
|
||||
</div>
|
||||
<style>
|
||||
.announcements {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</noscript>
|
||||
|
||||
{#if announcements.severity === "info"}
|
||||
<style>
|
||||
.announcement {
|
||||
background-color: #8caaee;
|
||||
}
|
||||
</style>
|
||||
{:else if announcements.severity === "low"}
|
||||
<style>
|
||||
.announcement {
|
||||
background-color: #a6d189;
|
||||
}
|
||||
</style>
|
||||
{:else if announcements.severity === "medium"}
|
||||
<style>
|
||||
.announcement {
|
||||
background-color: #e5c890;
|
||||
}
|
||||
</style>
|
||||
{:else if announcements.severity === "high"}
|
||||
<style>
|
||||
.announcement {
|
||||
background-color: #e78284;
|
||||
}
|
||||
</style>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.announcement-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 4rem;
|
||||
}
|
||||
|
||||
.announcement {
|
||||
color: #252525 !important;
|
||||
padding: 2rem 1rem;
|
||||
border-radius: 10px;
|
||||
width: fit-content;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.announcement a {
|
||||
color: #252525;
|
||||
}
|
||||
|
||||
.announcement .general {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.no-js {
|
||||
@apply flex justify-center text-center text-red;
|
||||
}
|
||||
</style>
|
||||
{:else}
|
||||
<div class="flex items-center gap-1 text-center justify-center mt-16">
|
||||
<div class="i-fa6-solid:circle-info" />
|
||||
<span>Announcements are currently disabled.</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
@@ -3,6 +3,7 @@
|
||||
export let position: any;
|
||||
export let description: any;
|
||||
export let icon: any;
|
||||
export let positionStyles: any;
|
||||
</script>
|
||||
|
||||
<div class="card-inner">
|
||||
@@ -17,7 +18,8 @@
|
||||
{title}
|
||||
|
||||
{#if position}
|
||||
- {position}
|
||||
<span>- </span>
|
||||
<span style={positionStyles}>{position}</span>
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Note, Captcha, Form, Meta, TextArea } from "$lib/Form";
|
||||
import fetchState from "$lib/fetchState";
|
||||
|
||||
const promise = fetchState("form");
|
||||
</script>
|
||||
|
||||
{#await promise}
|
||||
<span />
|
||||
{:then state}
|
||||
{#if state.enabled === "true"}
|
||||
<Form
|
||||
action="https://segfautils.projectsegfau.lt/api/form"
|
||||
method="POST"
|
||||
id="contact-form"
|
||||
>
|
||||
<Note
|
||||
content="Your IP will be logged for anti-abuse measures."
|
||||
icon="i-fa6-solid:lock"
|
||||
/>
|
||||
<Meta
|
||||
inputType="email"
|
||||
inputPlaceholder="Your email"
|
||||
selectType="commentType"
|
||||
>
|
||||
<option value="" selected disabled
|
||||
>Select a type of comment</option
|
||||
>
|
||||
<option value="Feedback">Feedback</option>
|
||||
<option value="Suggestion">Suggestion</option>
|
||||
<option value="Question">Question</option>
|
||||
<option value="Bug">Bug</option>
|
||||
</Meta>
|
||||
<TextArea id="comment" name="message" placeholder="Your message" />
|
||||
<Captcha />
|
||||
</Form>
|
||||
{:else}
|
||||
<div class="flex items-center gap-1">
|
||||
<div class="i-fa6-solid:circle-info" />
|
||||
<span>The contact form is currently disabled.</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
@@ -1,90 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "Invidious",
|
||||
"description": "A frontend for YouTube.",
|
||||
"website": "https://invidious.projectsegfau.lt/",
|
||||
"icon": "https://github.com/iv-org/invidious/raw/master/assets/invidious-colored-vector.svg",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://invidious.io/"
|
||||
},
|
||||
{
|
||||
"name": "Librarian",
|
||||
"description": "A frontend for Odysee.",
|
||||
"website": "https://lbry.projectsegfau.lt/",
|
||||
"icon": "https://codeberg.org/avatars/dd785d92b4d4df06d448db075cd29274",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://codeberg.org/librarian/librarian"
|
||||
},
|
||||
{
|
||||
"name": "Libreddit",
|
||||
"description": "A frontend for Reddit.",
|
||||
"website": "https://libreddit.projectsegfau.lt/",
|
||||
"icon": "https://github.com/spikecodes/libreddit/raw/master/static/logo.png",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://github.com/spikecodes/libreddit"
|
||||
},
|
||||
{
|
||||
"name": "Nitter",
|
||||
"description": "A frontend for Twitter.",
|
||||
"website": "https://nitter.projectsegfau.lt/",
|
||||
"icon": "https://github.com/zedeus/nitter/raw/master/public/logo.png",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://github.com/zedeus/nitter"
|
||||
},
|
||||
{
|
||||
"name": "Element",
|
||||
"description": "An open source and decentralized chat application.",
|
||||
"website": "https://chat.projectsegfau.lt/",
|
||||
"icon": "https://element.io/images/logo-mark-primary.svg",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://element.io/"
|
||||
},
|
||||
{
|
||||
"name": "Piped",
|
||||
"description": "Another frontend for YouTube.",
|
||||
"website": "https://piped.projectsegfau.lt/",
|
||||
"icon": "https://github.com/TeamPiped/Piped/raw/master/public/img/icons/logo.svg",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://github.com/TeamPiped/Piped"
|
||||
},
|
||||
{
|
||||
"name": "SearXNG",
|
||||
"description": "A private meta-search engine.",
|
||||
"website": "https://search.projectsegfau.lt/search",
|
||||
"icon": "https://docs.searxng.org/_static/searxng-wordmark.svg",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://searxng.org/"
|
||||
},
|
||||
{
|
||||
"name": "Gitea",
|
||||
"description": "A web interface for Git, alternative to GitHub.",
|
||||
"website": "https://git.projectsegfau.lt",
|
||||
"icon": "https://gitea.io/images/gitea.png",
|
||||
"category": "General",
|
||||
"projectWebsite": "https://gitea.io/"
|
||||
},
|
||||
{
|
||||
"name": "Portainer",
|
||||
"description": "Portainer instance for Soleil Levant.",
|
||||
"website": "https://portainer.soleil-levant.projectsegfau.lt/",
|
||||
"icon": "https://avatars.githubusercontent.com/u/22225832",
|
||||
"category": "Internal",
|
||||
"projectWebsite": "https://www.portainer.io/"
|
||||
},
|
||||
{
|
||||
"name": "mailcow",
|
||||
"description": "Our mail server and webmail.",
|
||||
"website": "https://mail.projectsegfau.lt/",
|
||||
"icon": "https://mailcow.email/images/cow_mailcow.svg",
|
||||
"category": "Internal",
|
||||
"projectWebsite": "https://mailcow.email/"
|
||||
},
|
||||
{
|
||||
"name": "Plausible analytics",
|
||||
"description": "Analytics for our website.",
|
||||
"website": "https://analytics.projectsegfau.lt/projectsegfau.lt",
|
||||
"icon": "https://avatars.githubusercontent.com/u/54802774",
|
||||
"category": "Internal",
|
||||
"projectWebsite": "https://plausible.io/"
|
||||
}
|
||||
]
|
||||
@@ -1,7 +0,0 @@
|
||||
let state: any = [];
|
||||
export default async function fetchState(module: "announcements" | "form") {
|
||||
const url = `https://segfautils.projectsegfau.lt/api/set/${module}`;
|
||||
const response = await fetch(url);
|
||||
state = await response.json();
|
||||
return state;
|
||||
}
|
||||
Reference in New Issue
Block a user