mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
281851f9a2 | ||
|
|
5a6214878f | ||
|
|
0c15769f63 | ||
|
|
70a81158ef | ||
|
|
084ab000bb | ||
|
|
d06664931a | ||
|
|
9d06ab96cc | ||
|
|
d8b471764c | ||
|
|
3f59fd4c58 | ||
|
|
20bcd84d7e | ||
|
|
09f1b1c533 | ||
|
|
f85a7b3023 | ||
|
|
f5125e11ba | ||
|
|
4afd58c24d | ||
|
|
c76c5cc0a3 | ||
|
|
c7f912947a | ||
|
|
33acb2578c | ||
|
|
c97347e760 | ||
|
|
fba3aef8aa | ||
|
|
2757ddb774 | ||
|
|
c6111fd247 |
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
run: |
|
||||
wait_for_postgres() {
|
||||
echo "Waiting for PostgreSQL to be ready..."
|
||||
while ! nix shell nixpkgs#postgresql_16 -c pg_isready -h 127.0.0.1 -p 15432 -U postgres; do
|
||||
while ! nix shell nixpkgs#postgresql -c pg_isready -h 127.0.0.1 -p 15432 -U postgres; do
|
||||
sleep 1
|
||||
done
|
||||
echo "PostgreSQL is ready."
|
||||
|
||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1735471104,
|
||||
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
|
||||
"lastModified": 1741379970,
|
||||
"narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
|
||||
"rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
'';
|
||||
};
|
||||
web = pkgs.mkShell {
|
||||
packages = with pkgs; [ nodejs_22 ];
|
||||
packages = with pkgs; [ nodejs ];
|
||||
shellHook = ''
|
||||
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
|
||||
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright.browsers}
|
||||
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{ pkgs, localArchtikaPackage, ... }:
|
||||
let
|
||||
domain = "demo.archtika.com";
|
||||
docsSubdomain = "docs.archtika.com";
|
||||
portfolioDomain = "thilohohlt.com";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
../shared.nix
|
||||
../../module.nix
|
||||
];
|
||||
|
||||
networking.hostName = "archtika-demo";
|
||||
@@ -25,10 +26,37 @@ in
|
||||
defaults.email = "thilo.hohlt@tutanota.com";
|
||||
certs."${domain}" = {
|
||||
inherit domain;
|
||||
extraDomainNames = [ "*.${domain}" ];
|
||||
extraDomainNames = [
|
||||
"*.${domain}"
|
||||
docsSubdomain
|
||||
];
|
||||
dnsProvider = "porkbun";
|
||||
environmentFile = /var/lib/porkbun.env;
|
||||
group = "nginx";
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."${docsSubdomain}" = {
|
||||
useACMEHost = domain;
|
||||
forceSSL = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
root = "/var/www/archtika-websites/archtika/archtika-documentation";
|
||||
index = "index.html";
|
||||
tryFiles = "$uri $uri/ $uri.html =404";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."${portfolioDomain}" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
root = "/var/www/archtika-websites/thiloho/thilo-hohlt";
|
||||
index = "index.html";
|
||||
tryFiles = "$uri $uri/ $uri.html =404";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ in
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
../shared.nix
|
||||
../../module.nix
|
||||
];
|
||||
|
||||
networking.hostName = "archtika-qs";
|
||||
|
||||
315
nix/module.nix
315
nix/module.nix
@@ -1,315 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkOption
|
||||
mkIf
|
||||
mkPackageOption
|
||||
types
|
||||
;
|
||||
cfg = config.services.archtika;
|
||||
in
|
||||
{
|
||||
options.services.archtika = {
|
||||
enable = mkEnableOption "Whether to enable the archtika service";
|
||||
|
||||
package = mkPackageOption pkgs "archtika" { };
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "archtika";
|
||||
description = "User account under which archtika runs.";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "archtika";
|
||||
description = "Group under which archtika runs.";
|
||||
};
|
||||
|
||||
databaseName = mkOption {
|
||||
type = types.str;
|
||||
default = "archtika";
|
||||
description = "Name of the PostgreSQL database for archtika.";
|
||||
};
|
||||
|
||||
apiPort = mkOption {
|
||||
type = types.port;
|
||||
default = 5000;
|
||||
description = "Port on which the API runs.";
|
||||
};
|
||||
|
||||
apiAdminPort = mkOption {
|
||||
type = types.port;
|
||||
default = 7500;
|
||||
description = "Port on which the API admin server runs.";
|
||||
};
|
||||
|
||||
webAppPort = mkOption {
|
||||
type = types.port;
|
||||
default = 10000;
|
||||
description = "Port on which the web application runs.";
|
||||
};
|
||||
|
||||
domain = mkOption {
|
||||
type = types.str;
|
||||
description = "Domain to use for the application.";
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
description = "Settings for the running archtika application.";
|
||||
type = types.submodule {
|
||||
options = {
|
||||
disableRegistration = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "By default any user can create an account. That behavior can be disabled by using this option.";
|
||||
};
|
||||
maxUserWebsites = mkOption {
|
||||
type = types.ints.positive;
|
||||
default = 2;
|
||||
description = "Maximum number of websites allowed per user by default.";
|
||||
};
|
||||
maxWebsiteStorageSize = mkOption {
|
||||
type = types.ints.positive;
|
||||
default = 50;
|
||||
description = "Maximum amount of disk space in MB allowed per user website by default.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
baseHardenedSystemdOptions = {
|
||||
CapabilityBoundingSet = "";
|
||||
LockPersonality = true;
|
||||
NoNewPrivileges = true;
|
||||
PrivateDevices = true;
|
||||
PrivateTmp = true;
|
||||
ProtectClock = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHome = true;
|
||||
ProtectHostname = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectSystem = "strict";
|
||||
RemoveIPC = true;
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [
|
||||
"@system-service"
|
||||
"~@privileged"
|
||||
"~@resources"
|
||||
];
|
||||
ReadWritePaths = [ "/var/www/archtika-websites" ];
|
||||
};
|
||||
in
|
||||
{
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
};
|
||||
|
||||
users.groups.${cfg.group} = {
|
||||
members = [
|
||||
"nginx"
|
||||
"postgres"
|
||||
];
|
||||
};
|
||||
|
||||
systemd.tmpfiles.settings = {
|
||||
"10-archtika" = {
|
||||
"/var/www" = {
|
||||
d = {
|
||||
mode = "0755";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
};
|
||||
"/var/www/archtika-websites" = {
|
||||
d = {
|
||||
mode = "0770";
|
||||
user = cfg.user;
|
||||
group = cfg.group;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.archtika-api = {
|
||||
description = "archtika API service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [
|
||||
"network.target"
|
||||
"postgresql.service"
|
||||
];
|
||||
|
||||
path = [ config.services.postgresql.package ];
|
||||
|
||||
serviceConfig = baseHardenedSystemdOptions // {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
Restart = "always";
|
||||
WorkingDirectory = "${cfg.package}/rest-api";
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
"AF_UNIX"
|
||||
];
|
||||
};
|
||||
|
||||
script =
|
||||
let
|
||||
dbUrl =
|
||||
user:
|
||||
"postgres://${user}@127.0.0.1:${toString config.services.postgresql.settings.port}/${cfg.databaseName}";
|
||||
in
|
||||
''
|
||||
JWT_SECRET=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c64)
|
||||
|
||||
psql ${dbUrl "postgres"} \
|
||||
-c "ALTER DATABASE ${cfg.databaseName} SET \"app.jwt_secret\" TO '$JWT_SECRET'" \
|
||||
-c "ALTER DATABASE ${cfg.databaseName} SET \"app.website_max_storage_size\" TO ${toString cfg.settings.maxWebsiteStorageSize}" \
|
||||
-c "ALTER DATABASE ${cfg.databaseName} SET \"app.website_max_number_user\" TO ${toString cfg.settings.maxUserWebsites}"
|
||||
|
||||
${pkgs.dbmate}/bin/dbmate --url ${dbUrl "postgres"}?sslmode=disable --migrations-dir ${cfg.package}/rest-api/db/migrations up
|
||||
|
||||
PGRST_SERVER_CORS_ALLOWED_ORIGINS="https://${cfg.domain}" \
|
||||
PGRST_ADMIN_SERVER_PORT=${toString cfg.apiAdminPort} \
|
||||
PGRST_SERVER_PORT=${toString cfg.apiPort} \
|
||||
PGRST_DB_SCHEMAS="api" \
|
||||
PGRST_DB_ANON_ROLE="anon" \
|
||||
PGRST_OPENAPI_MODE="ignore-privileges" \
|
||||
PGRST_DB_URI=${dbUrl "authenticator"} \
|
||||
PGRST_JWT_SECRET="$JWT_SECRET" \
|
||||
${pkgs.postgrest}/bin/postgrest
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services.archtika-web = {
|
||||
description = "archtika Web App service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = baseHardenedSystemdOptions // {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
Restart = "always";
|
||||
WorkingDirectory = "${cfg.package}/web-app";
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
];
|
||||
};
|
||||
|
||||
environment = {
|
||||
REGISTRATION_IS_DISABLED = toString cfg.settings.disableRegistration;
|
||||
BODY_SIZE_LIMIT = "10M";
|
||||
ORIGIN = "https://${cfg.domain}";
|
||||
PORT = toString cfg.webAppPort;
|
||||
};
|
||||
|
||||
script = "${pkgs.nodejs_22}/bin/node ${cfg.package}/web-app";
|
||||
};
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = [ cfg.databaseName ];
|
||||
authentication = lib.mkOverride 51 ''
|
||||
host all all 127.0.0.1/32 trust
|
||||
host all all ::1/128 trust
|
||||
local all all trust
|
||||
'';
|
||||
extensions = ps: with ps; [ pgjwt ];
|
||||
};
|
||||
|
||||
systemd.services.postgresql = {
|
||||
path = builtins.attrValues {
|
||||
inherit (pkgs) gnutar gzip;
|
||||
};
|
||||
serviceConfig = {
|
||||
ReadWritePaths = [ "/var/www/archtika-websites" ];
|
||||
SystemCallFilter = [ "@system-service" ];
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
recommendedProxySettings = true;
|
||||
recommendedTlsSettings = true;
|
||||
recommendedZstdSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
|
||||
appendHttpConfig = ''
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "accelerometer=(),autoplay=(),camera=(),cross-origin-isolated=(),display-capture=(),encrypted-media=(),fullscreen=(self),geolocation=(),gyroscope=(),keyboard-map=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(self),publickey-credentials-get=(),screen-wake-lock=(),sync-xhr=(self),usb=(),xr-spatial-tracking=(),clipboard-read=(self),clipboard-write=(self),gamepad=(),hid=(),idle-detection=(),interest-cohort=(),serial=(),unload=()" always;
|
||||
|
||||
map $http_cookie $auth_header {
|
||||
default "";
|
||||
"~*session_token=([^;]+)" "Bearer $1";
|
||||
}
|
||||
'';
|
||||
|
||||
virtualHosts = {
|
||||
"${cfg.domain}" = {
|
||||
useACMEHost = cfg.domain;
|
||||
forceSSL = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.webAppPort}";
|
||||
};
|
||||
"/previews/" = {
|
||||
alias = "/var/www/archtika-websites/previews/";
|
||||
index = "index.html";
|
||||
tryFiles = "$uri $uri/ $uri.html =404";
|
||||
};
|
||||
"/api/rpc/export_articles_zip" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.apiPort}/rpc/export_articles_zip";
|
||||
extraConfig = ''
|
||||
default_type application/json;
|
||||
proxy_set_header Authorization $auth_header;
|
||||
'';
|
||||
};
|
||||
"/api/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.apiPort}/";
|
||||
extraConfig = ''
|
||||
default_type application/json;
|
||||
'';
|
||||
};
|
||||
"/api/rpc/register" = mkIf cfg.settings.disableRegistration {
|
||||
extraConfig = ''
|
||||
deny all;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
"~^(?<subdomain>.+)\\.${cfg.domain}$" = {
|
||||
useACMEHost = cfg.domain;
|
||||
forceSSL = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
root = "/var/www/archtika-websites/$subdomain";
|
||||
index = "index.html";
|
||||
tryFiles = "$uri $uri/ $uri.html =404";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ let
|
||||
web = buildNpmPackage {
|
||||
name = "web-app";
|
||||
src = ../web-app;
|
||||
npmDepsHash = "sha256-RTyo7K/Hr1hBGtcBKynrziUInl91JqZl84NkJg16ufA=";
|
||||
npmDepsHash = "sha256-J58LwSEQa0p6J6h/wPhpGY/60n9a7TOV5WfNm4K1NH0=";
|
||||
npmFlags = [ "--legacy-peer-deps" ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/web-app
|
||||
|
||||
13
rest-api/db/migrations/20250323134405_username_blocklist.sql
Normal file
13
rest-api/db/migrations/20250323134405_username_blocklist.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- migrate:up
|
||||
ALTER TABLE internal.user
|
||||
DROP CONSTRAINT username_not_blocked;
|
||||
|
||||
ALTER TABLE internal.user
|
||||
ADD CONSTRAINT username_not_blocked CHECK (LOWER(username) NOT IN ('admin', 'administrator', 'api', 'auth', 'blog', 'cdn', 'docs', 'help', 'login', 'logout', 'profile', 'preview', 'previews', 'register', 'settings', 'setup', 'signin', 'signup', 'support', 'test', 'www'));
|
||||
|
||||
-- migrate:down
|
||||
ALTER TABLE internal.user
|
||||
DROP CONSTRAINT username_not_blocked;
|
||||
|
||||
ALTER TABLE internal.user
|
||||
ADD CONSTRAINT username_not_blocked CHECK (LOWER(username) NOT IN ('admin', 'administrator', 'api', 'auth', 'blog', 'cdn', 'docs', 'help', 'login', 'logout', 'profile', 'register', 'settings', 'setup', 'signin', 'signup', 'support', 'test', 'www'));
|
||||
2338
web-app/package-lock.json
generated
2338
web-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,35 +14,35 @@
|
||||
"gents": "pg-to-ts generate -c postgres://postgres@127.0.0.1:15432/archtika -o src/lib/db-schema.ts -s internal --datesAsStrings"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.47.0",
|
||||
"@sveltejs/adapter-auto": "3.2.5",
|
||||
"@sveltejs/adapter-node": "5.2.3",
|
||||
"@sveltejs/kit": "2.5.28",
|
||||
"@sveltejs/vite-plugin-svelte": "4.0.0-next.6",
|
||||
"@playwright/test": "1.50.1",
|
||||
"@sveltejs/adapter-auto": "5.0.0",
|
||||
"@sveltejs/adapter-node": "5.2.12",
|
||||
"@sveltejs/kit": "2.20.2",
|
||||
"@sveltejs/vite-plugin-svelte": "5.0.3",
|
||||
"@types/diff-match-patch": "1.0.36",
|
||||
"@types/eslint": "9.6.1",
|
||||
"@types/eslint__js": "8.42.3",
|
||||
"@types/eslint__js": "9.14.0",
|
||||
"@types/eslint-config-prettier": "6.11.3",
|
||||
"@types/node": "22.5.5",
|
||||
"eslint": "9.15.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-svelte": "2.44.0",
|
||||
"globals": "15.9.0",
|
||||
"@types/node": "22.13.11",
|
||||
"eslint": "9.23.0",
|
||||
"eslint-config-prettier": "10.1.1",
|
||||
"eslint-plugin-svelte": "3.3.3",
|
||||
"globals": "16.0.0",
|
||||
"pg-to-ts": "4.1.1",
|
||||
"prettier": "3.3.3",
|
||||
"prettier-plugin-svelte": "3.2.6",
|
||||
"svelte": "5.0.0-next.253",
|
||||
"svelte-check": "4.0.2",
|
||||
"typescript": "5.6.2",
|
||||
"typescript-eslint": "8.6.0",
|
||||
"vite": "5.4.6"
|
||||
"prettier": "3.5.3",
|
||||
"prettier-plugin-svelte": "3.3.3",
|
||||
"svelte": "5.25.3",
|
||||
"svelte-check": "4.1.5",
|
||||
"typescript": "5.8.2",
|
||||
"typescript-eslint": "8.27.0",
|
||||
"vite": "6.2.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"diff-match-patch": "1.0.5",
|
||||
"highlight.js": "11.10.0",
|
||||
"isomorphic-dompurify": "2.15.0",
|
||||
"marked": "14.1.2",
|
||||
"marked-highlight": "2.1.4"
|
||||
"highlight.js": "11.11.1",
|
||||
"isomorphic-dompurify": "2.22.0",
|
||||
"marked": "15.0.7",
|
||||
"marked-highlight": "2.2.1"
|
||||
},
|
||||
"overrides": {
|
||||
"cookie": "0.7.0"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<div class="pagination">
|
||||
{#snippet commonFilterInputs()}
|
||||
{#each commonFilters as filter}
|
||||
{#each commonFilters as filter (filter)}
|
||||
<input type="hidden" name={filter} value={$page.url.searchParams.get(filter)} />
|
||||
{/each}
|
||||
{/snippet}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { md } from "$lib/utils";
|
||||
import { page } from "$app/stores";
|
||||
import { previewContent, textareaScrollTop } from "$lib/runes.svelte";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
const {
|
||||
id,
|
||||
@@ -38,7 +39,7 @@
|
||||
|
||||
<nav class="operations__nav">
|
||||
<ul class="unpadded">
|
||||
{#each tabs.filter((tab) => (tab !== "categories" && contentType === "Blog") || contentType === "Docs") as tab}
|
||||
{#each tabs.filter((tab) => (tab !== "categories" && contentType === "Blog") || contentType === "Docs") as tab (tab)}
|
||||
<li>
|
||||
<a
|
||||
href="/website/{id}{tab === 'settings' ? '' : `/${tab}`}"
|
||||
@@ -57,14 +58,14 @@
|
||||
|
||||
<div class="preview" bind:this={previewElement}>
|
||||
{#if fullPreview}
|
||||
{#if !iframeLoaded}
|
||||
{#if !iframeLoaded && browser}
|
||||
<p>Loading preview...</p>
|
||||
{/if}
|
||||
<iframe
|
||||
src={previewContent.value}
|
||||
title="Preview"
|
||||
onload={() => (iframeLoaded = true)}
|
||||
style:display={iframeLoaded ? "block" : "none"}
|
||||
style:display={!browser || iframeLoaded ? "block" : "none"}
|
||||
></iframe>
|
||||
{:else}
|
||||
{@html md(
|
||||
@@ -131,6 +132,9 @@
|
||||
|
||||
.operations {
|
||||
padding-block-start: var(--space-s);
|
||||
resize: horizontal;
|
||||
min-inline-size: 100%;
|
||||
max-inline-size: calc(1536px - 320px);
|
||||
}
|
||||
|
||||
.preview {
|
||||
|
||||
@@ -16,6 +16,7 @@ export const apiRequest = async (
|
||||
method: "HEAD" | "GET" | "POST" | "PATCH" | "DELETE",
|
||||
options: {
|
||||
headers?: Record<string, string>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
body?: any;
|
||||
successMessage?: string;
|
||||
returnData?: boolean;
|
||||
|
||||
@@ -54,18 +54,18 @@
|
||||
</h2>
|
||||
|
||||
<ul class="unpadded">
|
||||
{#each sortedArticles as article}
|
||||
{#each sortedArticles as { id, publication_date, slug, title, meta_description } (id)}
|
||||
<li>
|
||||
{#if article.publication_date}
|
||||
<p>{article.publication_date}</p>
|
||||
{#if publication_date}
|
||||
<p>{publication_date}</p>
|
||||
{/if}
|
||||
<p>
|
||||
<strong>
|
||||
<a href="./articles/{article.slug}">{article.title}</a>
|
||||
<a href="./articles/{slug}">{title}</a>
|
||||
</strong>
|
||||
</p>
|
||||
{#if article.meta_description}
|
||||
<p>{article.meta_description}</p>
|
||||
{#if meta_description}
|
||||
<p>{meta_description}</p>
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
|
||||
@@ -55,11 +55,11 @@
|
||||
|
||||
<section id="docs-navigation" class="docs-navigation">
|
||||
<ul>
|
||||
{#each Object.keys(categorizedArticles) as key}
|
||||
{#each Object.keys(categorizedArticles) as key (key)}
|
||||
<li>
|
||||
<strong>{key}</strong>
|
||||
<ul>
|
||||
{#each categorizedArticles[key] as { title, slug }}
|
||||
{#each categorizedArticles[key] as { title, slug } (slug)}
|
||||
<li>
|
||||
<a href="{isIndexPage ? './articles' : '.'}/{slug}">{title}</a>
|
||||
</li>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<a href="#storage">Storage</a>
|
||||
</h2>
|
||||
<ul class="unpadded storage-grid">
|
||||
{#each data.storageSizes.data as { website_title, storage_size_bytes, max_storage_bytes, max_storage_pretty, diff_storage_pretty }}
|
||||
{#each data.storageSizes.data as { website_id, website_title, storage_size_bytes, max_storage_bytes, max_storage_pretty, diff_storage_pretty } (website_id)}
|
||||
<li>
|
||||
<strong>{website_title}</strong>
|
||||
<label>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<label>
|
||||
Category:
|
||||
<select name="category">
|
||||
{#each data.categories as { id, category_name }}
|
||||
{#each data.categories as { id, category_name } (id)}
|
||||
<option value={id} selected={id === data.article.category}>{category_name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
@@ -80,17 +80,18 @@ export const actions: Actions = {
|
||||
|
||||
const htmlDiff = (oldValue: string, newValue: string) => {
|
||||
const diff = dmp.diff_main(oldValue, newValue);
|
||||
dmp.diff_cleanupSemantic(diff);
|
||||
|
||||
return diff
|
||||
.map(([op, text]) => {
|
||||
const escapedText = text.replace(/</g, "<").replace(/>/g, ">");
|
||||
|
||||
switch (op) {
|
||||
case 1:
|
||||
return `<ins>${text}</ins>`;
|
||||
return `<ins>${escapedText}</ins>`;
|
||||
case -1:
|
||||
return `<del>${text}</del>`;
|
||||
return `<del>${escapedText}</del>`;
|
||||
default:
|
||||
return text;
|
||||
return escapedText;
|
||||
}
|
||||
})
|
||||
.join("");
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
/>
|
||||
<datalist id="users-{data.website.id}">
|
||||
<option value={data.website.user.username}></option>
|
||||
{#each data.collaborators as { user: { username } }}
|
||||
{#each data.collaborators as { user: { username } } (username)}
|
||||
<option value={username}></option>
|
||||
{/each}
|
||||
</datalist>
|
||||
@@ -72,7 +72,7 @@
|
||||
Resource:
|
||||
<select name="resource">
|
||||
<option value="all">Show all</option>
|
||||
{#each Object.keys(resources) as resource}
|
||||
{#each Object.keys(resources) as resource (resource)}
|
||||
<option
|
||||
value={resource}
|
||||
selected={resource === $page.url.searchParams.get("resource")}>{resource}</option
|
||||
@@ -141,20 +141,20 @@
|
||||
<button type="submit">Compute diff</button>
|
||||
</form>
|
||||
{#if form?.logId === id && form?.currentDiff}
|
||||
<pre>{@html DOMPurify.sanitize(form.currentDiff, {
|
||||
ALLOWED_TAGS: ["ins", "del"]
|
||||
})}</pre>
|
||||
<pre>{@html form.currentDiff
|
||||
.replace(/\\\"/g, '"')
|
||||
.replace(/\\r\\n|\\n|\\r/g, "\n")}</pre>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if new_value && !old_value}
|
||||
<h4>New value</h4>
|
||||
<pre>{DOMPurify.sanitize(newValue)}</pre>
|
||||
<pre>{newValue.replace(/\\\"/g, '"').replace(/\\r\\n|\\n|\\r/g, "\n")}</pre>
|
||||
{/if}
|
||||
|
||||
{#if old_value && !new_value}
|
||||
<h4>Old value</h4>
|
||||
<pre>{DOMPurify.sanitize(oldValue)}</pre>
|
||||
<pre>{oldValue.replace(/\\\"/g, '"').replace(/\\r\\n|\\n|\\r/g, "\n")}</pre>
|
||||
{/if}
|
||||
</Modal>
|
||||
</td>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<p class="mt-2 text-xl text-neutral-700 sm:text-2xl">FLOSS, modern, performant, lightweight and self‑hosted CMS</p>
|
||||
<div class="mt-8 flex flex-wrap gap-6 sm:justify-end">
|
||||
<a href="https://github.com/archtika/archtika" class="text-neutral-900 rounded-full bg-neutral-200 px-4 py-2 outline outline-1 outline-offset-4 outline-neutral-300 hover:bg-neutral-300 hover:underline focus:outline-2 focus:outline-neutral-900">GitHub</a>
|
||||
<a href="https://archtika.demo.archtika.com/archtika-documentation" class="text-neutral-900 rounded-full bg-neutral-200 px-4 py-2 outline outline-1 outline-offset-4 outline-neutral-300 hover:bg-neutral-300 hover:underline focus:outline-2 focus:outline-neutral-900">Documentation</a>
|
||||
<a href="https://docs.archtika.com" class="text-neutral-900 rounded-full bg-neutral-200 px-4 py-2 outline outline-1 outline-offset-4 outline-neutral-300 hover:bg-neutral-300 hover:underline focus:outline-2 focus:outline-neutral-900">Documentation</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user