From d8748bba77cede53694519c75786701f9a9783d5 Mon Sep 17 00:00:00 2001 From: Sudo-Ivan Date: Sat, 27 Dec 2025 19:08:36 -0600 Subject: [PATCH] Update asset caching and documentation features - Updated the API server to support asset caching with a new flag for enabling/disabling caching. - Implemented asset caching logic in the DownloadProxyHandler to store and retrieve assets efficiently. - Added tests for asset caching functionality, ensuring proper behavior for cache hits and misses. - Introduced new documentation files for software, including multi-language support. - Enhanced the SoftwareCard component to display documentation links for software with available docs. - Updated the Software model to include a flag indicating the presence of documentation. - Improved the user interface for documentation navigation and search functionality. --- README.md | 30 +-- .../src/lib/components/SoftwareCard.svelte | 29 ++- .../src/lib/components/icons/BrandIcon.svelte | 3 + frontend/src/lib/docs/software/webnews.de.md | 33 +++ frontend/src/lib/docs/software/webnews.it.md | 33 +++ frontend/src/lib/docs/software/webnews.md | 33 +++ frontend/src/lib/docs/software/webnews.ru.md | 33 +++ frontend/src/lib/docs/verification.de.svx | 204 ++++++++++++++++++ frontend/src/lib/docs/verification.it.svx | 204 ++++++++++++++++++ frontend/src/lib/docs/verification.ru.svx | 204 ++++++++++++++++++ frontend/src/lib/i18n/index.ts | 22 +- frontend/src/lib/types.ts | 1 + frontend/src/routes/docs/+layout.svelte | 154 ++++++++++--- frontend/src/routes/docs/+page.svelte | 106 ++++++++- .../docs/{[slug] => [...slug]}/+page.svelte | 7 +- frontend/src/routes/docs/[...slug]/+page.ts | 52 +++++ frontend/src/routes/docs/[slug]/+page.ts | 14 -- frontend/src/routes/legal/[doc]/+page.svelte | 7 +- frontend/static/verifier/verifier.wasm | Bin 2725477 -> 2725477 bytes internal/api/constants.go | 5 + internal/api/handlers.go | 91 +++++++- internal/api/handlers_test.go | 76 ++++++- internal/config/config.go | 9 + internal/gitea/client.go | 32 +++ internal/models/models.go | 1 + legal/disclaimer.de.txt | 10 + legal/privacy.de.txt | 32 +++ legal/terms.de.txt | 14 ++ main.go | 7 +- main_test.go | 39 +++- 30 files changed, 1392 insertions(+), 93 deletions(-) create mode 100644 frontend/src/lib/docs/software/webnews.de.md create mode 100644 frontend/src/lib/docs/software/webnews.it.md create mode 100644 frontend/src/lib/docs/software/webnews.md create mode 100644 frontend/src/lib/docs/software/webnews.ru.md create mode 100644 frontend/src/lib/docs/verification.de.svx create mode 100644 frontend/src/lib/docs/verification.it.svx create mode 100644 frontend/src/lib/docs/verification.ru.svx rename frontend/src/routes/docs/{[slug] => [...slug]}/+page.svelte (62%) create mode 100644 frontend/src/routes/docs/[...slug]/+page.ts delete mode 100644 frontend/src/routes/docs/[slug]/+page.ts create mode 100644 legal/disclaimer.de.txt create mode 100644 legal/privacy.de.txt create mode 100644 legal/terms.de.txt diff --git a/README.md b/README.md index a2f8cd3..a41192b 100644 --- a/README.md +++ b/README.md @@ -15,25 +15,27 @@ A software distribution platform for assets built and hosted on Gitea. Built wit - **Throttling**: Tiered download speed limits and global API rate limiting. - **RSS Feed**: XML feed for tracking new software releases. - **i18n**: Support for English, German, Italian, and Russian. +- **Documentation**: Support for documentation for software station and each software project in `.svx` and `.md` files. ## Upcoming -- S3, SFTP, WebDAV for software assets. +- Admin panel. +- Authentication for certain software and containers. +- Automatic torrent generation and seeding for software assets. +- CDN support. +- Container scanning. - Gitea Packages support (containers, npm, etc.). -- ISOs support (Linux distributions) -- Automatic Torrent generation and seeding for software assets. -- Software dependencies page and licenses information. -- SBOM and SPDX viewer. -- CDN support -- OSV integration for vulnerability scanning. -- Container scanning -- Authentication for certain software/containers -- Admin panel +- GPG and SBOM client-side verification via WASM. - Infisical support for secrets management. -- Sqlite for database -- Webhook support to force refresh of specific software/containers or add a new software/container. -- Reticulum Network Stack support -- GPG, SBOM client-side verification via WASM. +- ISOs support (Linux distributions). +- OSV integration for vulnerability scanning. +- Reticulum Network Stack support. +- S3, SFTP, and WebDAV support for software assets. +- SBOM and SPDX viewer. +- Software dependencies page and license information. +- Sqlite database support. +- Webhook support to force refresh or add specific software/containers. +- Software caching for popular assets. ## Getting Started diff --git a/frontend/src/lib/components/SoftwareCard.svelte b/frontend/src/lib/components/SoftwareCard.svelte index 2890161..fed5089 100644 --- a/frontend/src/lib/components/SoftwareCard.svelte +++ b/frontend/src/lib/components/SoftwareCard.svelte @@ -21,6 +21,7 @@ Copy, Check, Calendar, + BookOpen, } from 'lucide-svelte'; import type { Software, Asset } from '$lib/types'; import VerificationModal from './VerificationModal.svelte'; @@ -94,7 +95,20 @@ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; } - function getOSIcon(os: string) { + function getOSIcon(os: string, assetName?: string) { + if (assetName) { + const lowerName = assetName.toLowerCase(); + if (lowerName.endsWith('.whl')) { + return 'python'; + } + if ( + lowerName.endsWith('.zip') || + lowerName.endsWith('.tar.gz') || + lowerName.endsWith('.tgz') + ) { + return 'zip'; + } + } switch (os.toLowerCase()) { case 'macos': return 'apple'; @@ -216,6 +230,15 @@ /> {/if} + {#if software.has_docs} + + + + {/if}
@@ -328,7 +351,7 @@
{#each filteredAssets as asset} - {@const brand = getOSIcon(asset.os)} + {@const brand = getOSIcon(asset.os, asset.name)} {@const FallbackIcon = getFallbackIcon(asset.os)}
{#if filteredLatestAssets.length > 0} {#each filteredLatestAssets as asset} - {@const brand = getOSIcon(asset.os)} + {@const brand = getOSIcon(asset.os, asset.name)} {@const FallbackIcon = getFallbackIcon(asset.os)}
diff --git a/frontend/src/lib/docs/software/webnews.de.md b/frontend/src/lib/docs/software/webnews.de.md new file mode 100644 index 0000000..615f607 --- /dev/null +++ b/frontend/src/lib/docs/software/webnews.de.md @@ -0,0 +1,33 @@ +# WebNews + +WebNews ist ein leistungsstarker terminalbasierter Newsreader, der auf Einfachheit und Geschwindigkeit ausgelegt ist. + +## Funktionen + +- **Blitzschnell**: In Go geschrieben für optimale Performance. +- **Vim-ähnliche Tastenkombinationen**: Vertraute Steuerung für Terminal-Power-User. +- **Offline-Unterstützung**: Artikel für das Lesen ohne Internetverbindung zwischenspeichern. +- **Anpassbare Themes**: Unterstützung für helle und dunkle Terminal-Farbschemata. + +## Installation + +Sie können die neueste Binärdatei für Ihr Betriebssystem von der Hauptseite herunterladen. + +```bash +# Beispielnutzung +webnews --sync +``` + +## Konfiguration + +Die Konfiguration wird standardmäßig in `~/.config/webnews/config.yaml` gespeichert. + +```yaml +sources: + - https://hnrss.org/frontpage + - https://lobste.rs/rss +``` + +--- + +_Dies ist eine Test-Dokumentationsdatei, die aus Markdown gerendert wurde._ diff --git a/frontend/src/lib/docs/software/webnews.it.md b/frontend/src/lib/docs/software/webnews.it.md new file mode 100644 index 0000000..b1aedc1 --- /dev/null +++ b/frontend/src/lib/docs/software/webnews.it.md @@ -0,0 +1,33 @@ +# WebNews + +WebNews è un lettore di notizie basato su terminale ad alte prestazioni, progettato per semplicità e velocità. + +## Caratteristiche + +- **Velocissimo**: Scritto in Go per prestazioni ottimali. +- **Scorciatoie in stile Vim**: Controlli familiari per gli utenti esperti del terminale. +- **Supporto Offline**: Memorizza gli articoli nella cache per la lettura senza connessione internet. +- **Temi Personalizzabili**: Supporto per schemi di colori del terminale sia chiari che scuri. + +## Installazione + +Puoi scaricare l'ultimo binario per il tuo sistema operativo dalla pagina principale. + +```bash +# Esempio di utilizzo +webnews --sync +``` + +## Configurazione + +La configurazione è memorizzata in `~/.config/webnews/config.yaml` per impostazione predefinita. + +```yaml +sources: + - https://hnrss.org/frontpage + - https://lobste.rs/rss +``` + +--- + +_Questo è un file di documentazione di test renderizzato da Markdown._ diff --git a/frontend/src/lib/docs/software/webnews.md b/frontend/src/lib/docs/software/webnews.md new file mode 100644 index 0000000..d5451be --- /dev/null +++ b/frontend/src/lib/docs/software/webnews.md @@ -0,0 +1,33 @@ +# WebNews + +WebNews is a high-performance terminal-based news reader designed for simplicity and speed. + +## Features + +- **Blazing Fast**: Written in Go for optimal performance. +- **Vim-like Keybindings**: Familiar controls for terminal power users. +- **Offline Support**: Cache articles for reading without an internet connection. +- **Customizable Themes**: Support for both light and dark terminal schemes. + +## Installation + +You can download the latest binary for your operating system from the main page. + +```bash +# Example usage +webnews --sync +``` + +## Configuration + +Configuration is stored in `~/.config/webnews/config.yaml` by default. + +```yaml +sources: + - https://hnrss.org/frontpage + - https://lobste.rs/rss +``` + +--- + +_This is a test documentation file rendered from Markdown._ diff --git a/frontend/src/lib/docs/software/webnews.ru.md b/frontend/src/lib/docs/software/webnews.ru.md new file mode 100644 index 0000000..3347a97 --- /dev/null +++ b/frontend/src/lib/docs/software/webnews.ru.md @@ -0,0 +1,33 @@ +# WebNews + +WebNews — это высокопроизводительный терминальный агрегатор новостей, разработанный для простоты и скорости. + +## Особенности + +- **Невероятно быстрый**: Написан на Go для оптимальной производительности. +- **Vim-подобные горячие клавиши**: Привычное управление для продвинутых пользователей терминала. +- **Автономный режим**: Кэширование статей для чтения без подключения к интернету. +- **Настраиваемые темы**: Поддержка светлых и темных схем терминала. + +## Установка + +Вы можете скачать последнюю версию бинарного файла для вашей операционной системы на главной странице. + +```bash +# Пример использования +webnews --sync +``` + +## Конфигурация + +Конфигурация по умолчанию хранится в `~/.config/webnews/config.yaml`. + +```yaml +sources: + - https://hnrss.org/frontpage + - https://lobste.rs/rss +``` + +--- + +_Это тестовый файл документации, отрисованный из Markdown._ diff --git a/frontend/src/lib/docs/verification.de.svx b/frontend/src/lib/docs/verification.de.svx new file mode 100644 index 0000000..b4a855e --- /dev/null +++ b/frontend/src/lib/docs/verification.de.svx @@ -0,0 +1,204 @@ + + +
+ +
+
+ + Dokumentation +
+

Wie die Verifizierung funktioniert

+

+ Software Station nutzt modernste Browser-Technologie, um sicherzustellen, dass Ihre Downloads zu 100 % authentisch und unverfälscht sind. +

+
+ + +
+
+
+ +
+

Die einfache Erklärung

+
+ +
+
+
+ +
+

Es ist ein digitales Schloss

+

+ Jede Datei hat einen einzigartigen „digitalen Fingerabdruck“ (SHA256). Bevor Sie eine Datei speichern, berechnet unser Verifizierer diesen Fingerabdruck in Ihrem Browser neu, um sicherzustellen, dass er mit der Originalversion des Entwicklers übereinstimmt. +

+
+ +
+
+ +
+

Läuft in einer Sandbox

+

+ Die Verifizierung erfolgt in einer „Sandbox“ – einem sicheren, isolierten Bereich in Ihrem Browser. Das bedeutet, dass die Datei auf Sicherheit geprüft wird, bevor sie jemals den permanenten Speicher Ihres Computers berührt. +

+
+ +
+
+ +
+

Quellen-Verifizierung

+

+ Wir verifizieren die Verbindung zur Quelle mit industrieller Sicherheit (TLS). Dies stellt sicher, dass Sie direkt mit dem echten Repository kommunizieren und nicht mit einem Betrüger. +

+
+ +
+
+ +
+

Kennen Sie die Autoren

+

+ Jede Veröffentlichung zeigt die tatsächlichen Mitwirkenden aus dem Gitea-Repository. Sie können genau sehen, wer den Code geschrieben hat, den Sie gerade herunterladen möchten. +

+
+
+
+ + +
+
+
+ +
+

Technische Details

+
+ +
+
+

+ + WebAssembly (WASM) Engine +

+

+ Der Verifizierer ist in **Go** geschrieben und zu **WebAssembly** kompiliert. Durch die Verwendung von WASM anstelle von Standard-JavaScript nutzen wir die crypto/sha256-Implementierung der Go-Standardbibliothek, was hochperformante kryptografische Operationen ermöglicht, die resistent gegen Prototyp-Pollution auf JS-Ebene oder Umgebungsmanipulationen sind. +

+
+ +
+

+ + Zero-Trust-Architektur +

+

+ Software Station arbeitet nach einem Zero-Trust-Modell in Bezug auf die Antwort des Servers. Der Browser ruft den rohen Binärstream in ein Uint8Array ab. Dieser Puffer wird dann direkt in den WASM-Speicherbereich übergeben. Die Hash-Berechnung erfolgt **clientseitig**, was bedeutet, dass selbst wenn der Server kompromittiert wäre und bösartige Binärdateien ausliefern würde, der Verifizierer die Hash-Abweichung sofort erkennen würde. +

+
+ +
+

+ + Verifizierungs-Pipeline +

+
+
+
+ 1 +
+

+ Die Binärdatei wird über einen sicheren TLS-Tunnel von der Quelle (Gitea/S3) gestreamt. +

+
+
+
+ 2 +
+

+ Die WASM-Engine liest den Byte-Stream und berechnet den SHA256-Digest lokal. +

+
+
+
+ 3 +
+

+ Der berechnete Digest wird mit dem kryptografisch signierten Manifest verglichen. +

+
+
+
+ 4 +
+

+ Nur bei erfolgreicher Übereinstimmung wird das Blob-Objekt erstellt und der Download ausgelöst. +

+
+
+
+
+
+ + +
+

+ + Demnächst verfügbar +

+

+ Wir arbeiten ständig daran, die Transparenz zu verbessern. Unsere nächsten Meilensteine umfassen: +

+
+
+ + Automatische SBOM-Generierung +
+
+ + S3-Speicher-Verifizierung +
+
+ + Multi-Signatur-Verifizierung +
+
+ + Überprüfung reproduzierbarer Builds +
+
+
+
+ diff --git a/frontend/src/lib/docs/verification.it.svx b/frontend/src/lib/docs/verification.it.svx new file mode 100644 index 0000000..805d975 --- /dev/null +++ b/frontend/src/lib/docs/verification.it.svx @@ -0,0 +1,204 @@ + + +
+ +
+
+ + Documentazione +
+

Come funziona la verifica

+

+ Software Station utilizza una tecnologia browser all'avanguardia per garantire che i tuoi download siano autentici al 100% e non manomessi. +

+
+ + +
+
+
+ +
+

La spiegazione semplice

+
+ +
+
+
+ +
+

È una serratura digitale

+

+ Ogni file ha un'impronta digitale unica (SHA256). Prima di salvare un file, il nostro verificatore ricalcola quell'impronta all'interno del tuo browser per assicurarsi che corrisponda alla versione originale dello sviluppatore. +

+
+ +
+
+ +
+

Esecuzione in Sandbox

+

+ La verifica avviene in una "sandbox", un'area sicura e isolata nel tuo browser. Ciò significa che il file viene controllato prima ancora di toccare la memoria permanente del tuo computer. +

+
+ +
+
+ +
+

Verifica della fonte

+

+ Verifichiamo la connessione alla sorgente utilizzando una sicurezza di livello industriale (TLS). Questo assicura che tu stia parlando direttamente con il vero repository e non con un impostore. +

+
+ +
+
+ +
+

Conosci gli autori

+

+ Ogni rilascio mostra i collaboratori effettivi dal repository Gitea. Puoi vedere esattamente chi ha scritto il codice che stai per scaricare. +

+
+
+
+ + +
+
+
+ +
+

Approfondimento tecnico

+
+ +
+
+

+ + Motore WebAssembly (WASM) +

+

+ Il verificatore è scritto in **Go** e compilato in **WebAssembly**. Utilizzando WASM invece del JavaScript standard, sfruttiamo l'implementazione crypto/sha256 della libreria standard di Go, garantendo operazioni crittografiche ad alte prestazioni resistenti all'inquinamento dei prototipi a livello JS o alla manipolazione dell'ambiente. +

+
+ +
+

+ + Architettura Zero-Trust +

+

+ Software Station opera su un modello zero-trust per quanto riguarda la risposta del server. Il browser recupera il flusso binario grezzo in un Uint8Array. Questo buffer viene poi passato direttamente nello spazio di memoria WASM. Il calcolo dell'hash viene eseguito **lato client**, il che significa che anche se il server fosse compromesso e servisse binari dannosi, il verificatore rileverebbe immediatamente la mancata corrispondenza dell'hash. +

+
+ +
+

+ + Pipeline di verifica +

+
+
+
+ 1 +
+

+ Il binario viene trasmesso in streaming dalla sorgente (Gitea/S3) tramite un tunnel TLS sicuro. +

+
+
+
+ 2 +
+

+ Il motore WASM legge il flusso di byte e calcola localmente l'hash SHA256. +

+
+
+
+ 3 +
+

+ L'hash calcolato viene confrontato con il manifesto firmato crittograficamente. +

+
+
+
+ 4 +
+

+ Solo in caso di corrispondenza positiva viene creato l'oggetto Blob e attivato il download. +

+
+
+
+
+
+ + +
+

+ + Prossimamente +

+

+ Lavoriamo costantemente per migliorare la trasparenza. I nostri prossimi traguardi includono: +

+
+
+ + Generazione automatica SBOM +
+
+ + Verifica dello storage S3 +
+
+ + Verifica Multi-Firma +
+
+ + Controlli delle build riproducibili +
+
+
+
+ diff --git a/frontend/src/lib/docs/verification.ru.svx b/frontend/src/lib/docs/verification.ru.svx new file mode 100644 index 0000000..5bb714b --- /dev/null +++ b/frontend/src/lib/docs/verification.ru.svx @@ -0,0 +1,204 @@ + + +
+ +
+
+ + Документация +
+

Как работает верификация

+

+ Software Station использует передовые технологии браузера, чтобы гарантировать 100% подлинность ваших загрузок. +

+
+ + +
+
+
+ +
+

Простое объяснение

+
+ +
+
+
+ +
+

Цифровой замок

+

+ У каждого файла есть уникальный «цифровой отпечаток» (SHA256). Перед тем как сохранить файл, наш верификатор заново вычисляет этот отпечаток в вашем браузере, чтобы убедиться, что он совпадает с оригинальной версией разработчика. +

+
+ +
+
+ +
+

Работа в песочнице

+

+ Верификация происходит в «песочнице» — безопасной изолированной области вашего браузера. Это означает, что файл проверяется на безопасность еще до того, как он попадет в постоянное хранилище вашего компьютера. +

+
+ +
+
+ +
+

Проверка источника

+

+ Мы проверяем соединение с источником, используя защиту промышленного класса (TLS). Это гарантирует, что вы общаетесь напрямую с реальным репозиторием, а не с самозванцем. +

+
+ +
+
+ +
+

Знайте авторов

+

+ В каждом релизе указаны реальные контрибьюторы из репозитория Gitea. Вы можете точно видеть, кто написал код, который вы собираетесь скачать. +

+
+
+
+ + +
+
+
+ +
+

Технические детали

+
+ +
+
+

+ + Движок WebAssembly (WASM) +

+

+ Верификатор написан на **Go** и скомпилирован в **WebAssembly**. Используя WASM вместо стандартного JavaScript, мы задействуем реализацию crypto/sha256 из стандартной библиотеки Go, обеспечивая высокую производительность криптографических операций, устойчивых к загрязнению прототипов на уровне JS или манипуляциям с окружением. +

+
+ +
+

+ + Архитектура Zero-Trust +

+

+ Software Station работает по модели «нулевого доверия» в отношении ответов сервера. Браузер загружает необработанный двоичный поток в Uint8Array. Затем этот буфер передается напрямую в пространство памяти WASM. Расчет хэша выполняется на **стороне клиента**, что означает, что даже если сервер будет взломан и начнет выдавать вредоносные файлы, верификатор немедленно обнаружит несовпадение хэша. +

+
+ +
+

+ + Конвейер верификации +

+
+
+
+ 1 +
+

+ Бинарный файл передается из источника (Gitea/S3) через защищенный TLS-туннель. +

+
+
+
+ 2 +
+

+ Движок WASM считывает поток байтов и локально вычисляет дайджест SHA256. +

+
+
+
+ 3 +
+

+ Вычисленный дайджест сравнивается с манифестом, подписанным криптографически. +

+
+
+
+ 4 +
+

+ Только при успешном совпадении создается объект Blob и инициируется загрузка. +

+
+
+
+
+
+ + +
+

+ + Скоро в проекте +

+

+ Мы постоянно работаем над улучшением прозрачности. Наши следующие вехи включают: +

+
+
+ + Автоматическая генерация SBOM +
+
+ + Верификация хранилища S3 +
+
+ + Верификация с несколькими подписями +
+
+ + Проверка воспроизводимости сборок +
+
+
+
+ diff --git a/frontend/src/lib/i18n/index.ts b/frontend/src/lib/i18n/index.ts index be093b2..4ea5246 100644 --- a/frontend/src/lib/i18n/index.ts +++ b/frontend/src/lib/i18n/index.ts @@ -1,4 +1,6 @@ -import { init, register, getLocaleFromNavigator } from 'svelte-i18n'; +import { init, register, getLocaleFromNavigator, locale } from 'svelte-i18n'; +import { browser } from '$app/environment'; +import { invalidate } from '$app/navigation'; const defaultLocale = 'en'; @@ -7,7 +9,23 @@ register('de', () => import('./locales/de.json')); register('ru', () => import('./locales/ru.json')); register('it', () => import('./locales/it.json')); +const storedLocale = typeof window !== 'undefined' ? localStorage.getItem('locale') : null; +const initialLocale = storedLocale || getLocaleFromNavigator() || defaultLocale; + init({ fallbackLocale: defaultLocale, - initialLocale: getLocaleFromNavigator() || defaultLocale, + initialLocale: initialLocale, }); + +let currentLocaleValue = ''; + +if (browser) { + locale.subscribe((value) => { + if (value && value !== currentLocaleValue) { + currentLocaleValue = value; + localStorage.setItem('locale', value); + document.cookie = `locale=${value}; path=/; max-age=31536000`; + invalidate('app:locale'); + } + }); +} diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index dae3d2b..38184f5 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -49,4 +49,5 @@ export interface Software { license?: string; is_private: boolean; avatar_url?: string; + has_docs: boolean; } diff --git a/frontend/src/routes/docs/+layout.svelte b/frontend/src/routes/docs/+layout.svelte index fa0bd37..4ac3545 100644 --- a/frontend/src/routes/docs/+layout.svelte +++ b/frontend/src/routes/docs/+layout.svelte @@ -1,12 +1,14 @@ -
-
Loading documentation...
+
+
+
+ + Welcome +
+

Knowledge Base

+

+ Everything you need to know about Software Station, from verification internals to API + integration. +

+
+ +
+ +
+
+
+ +
+

Project Overview

+
+
+

+ Software Station is a specialized platform designed for the secure distribution + of software binaries. In an era where supply chain attacks are increasing, we provide a + Zero-Trust architecture that shifts the responsibility of verification to the + client browser. +

+

+ Our core philosophy is that the server serving the software should not be the sole authority + on its integrity. By leveraging WebAssembly and + SHA256 cryptography, we ensure that every byte you download matches the + original manifest signed by the developers. +

+
+
diff --git a/frontend/src/routes/docs/[slug]/+page.svelte b/frontend/src/routes/docs/[...slug]/+page.svelte similarity index 62% rename from frontend/src/routes/docs/[slug]/+page.svelte rename to frontend/src/routes/docs/[...slug]/+page.svelte index b4e4813..6c56139 100644 --- a/frontend/src/routes/docs/[slug]/+page.svelte +++ b/frontend/src/routes/docs/[...slug]/+page.svelte @@ -1,10 +1,11 @@
- {#if Content} - + {#if data.content} + {#key data.content} + + {/key} {/if}
diff --git a/frontend/src/routes/docs/[...slug]/+page.ts b/frontend/src/routes/docs/[...slug]/+page.ts new file mode 100644 index 0000000..04e2b87 --- /dev/null +++ b/frontend/src/routes/docs/[...slug]/+page.ts @@ -0,0 +1,52 @@ +import { error } from '@sveltejs/kit'; +import { browser } from '$app/environment'; +import { get } from 'svelte/store'; +import { locale } from 'svelte-i18n'; + +export const load = async ({ params, depends }) => { + const { slug } = params; + + depends('app:locale'); + + const currentLocale = (browser ? localStorage.getItem('locale') : null) || get(locale) || 'en'; + + const cleanSlug = slug.endsWith('/') ? slug.slice(0, -1) : slug; + + const modules = import.meta.glob('../../../lib/docs/**/*.{svx,md}'); + + let match: (() => Promise) | undefined; + + const localeSpecificPaths = [ + `../../../lib/docs/${cleanSlug}.${currentLocale}.svx`, + `../../../lib/docs/${cleanSlug}.${currentLocale}.md`, + ]; + + for (const path of localeSpecificPaths) { + if (modules[path]) { + match = modules[path]; + break; + } + } + + if (!match) { + match = modules[`../../../lib/docs/${cleanSlug}.svx`]; + if (!match) { + match = modules[`../../../lib/docs/${cleanSlug}.md`]; + } + } + + if (!match) { + throw error(404, 'Documentation not found'); + } + + try { + const doc = (await match()) as any; + return { + content: doc.default, + metadata: doc.metadata, + }; + } catch (e) { + console.error('Error loading doc:', e); + throw error(500, 'Error loading documentation content'); + } +}; diff --git a/frontend/src/routes/docs/[slug]/+page.ts b/frontend/src/routes/docs/[slug]/+page.ts deleted file mode 100644 index 692a153..0000000 --- a/frontend/src/routes/docs/[slug]/+page.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { error } from '@sveltejs/kit'; - -export const load = async ({ params }) => { - try { - const doc = await import(`../../../lib/docs/${params.slug}.svx`); - - return { - content: doc.default, - metadata: doc.metadata, - }; - } catch { - throw error(404, 'Documentation not found'); - } -}; diff --git a/frontend/src/routes/legal/[doc]/+page.svelte b/frontend/src/routes/legal/[doc]/+page.svelte index 1371c47..3b1af8e 100644 --- a/frontend/src/routes/legal/[doc]/+page.svelte +++ b/frontend/src/routes/legal/[doc]/+page.svelte @@ -1,6 +1,6 @@ "}} testStatsService := stats.NewService("test-hashes.json") - srv := api.NewServer("", malicious, testStatsService) + srv := api.NewServer("", malicious, testStatsService, true) req := httptest.NewRequest("GET", "/api/software", nil) rr := httptest.NewRecorder() srv.APISoftwareHandler(rr, req)