Compare commits

..

No commits in common. "aa69525912434baf1d88b8fc2779e1f8ce3ede5d" and "84e477b23e5847f1a69efa1669abd715bac968a5" have entirely different histories.

15 changed files with 30 additions and 62 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "website", "name": "website",
"version": "6.2", "version": "6.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",

View File

@ -1,9 +1,9 @@
import { urljoin, env_url } from "$lib/util.js"; import { urljoin } from "$lib/util.js";
const api_version = "v1"; const api_version = "v1";
const api_url = urljoin(import.meta.env.WEBSITE_API_URL, api_version);
function api_urljoin(path = null, query = {}) { function api_urljoin(path = null, query = {}) {
let api_url = urljoin(env_url("API"), api_version);
return urljoin(api_url, path, query); return urljoin(api_url, path, query);
} }

View File

@ -1,4 +1,4 @@
import { urljoin, env_url } from "$lib/util.js"; import { urljoin } from "$lib/util.js";
function doc_urljoin(path = null, query = {}) { function doc_urljoin(path = null, query = {}) {
return urljoin(import.meta.env.WEBSITE_DOC_URL, path, query); return urljoin(import.meta.env.WEBSITE_DOC_URL, path, query);

View File

@ -1,5 +1,5 @@
<script> <script>
import { app_url, color, date_from_ts } from "$lib/util.js"; import { urljoin, color, date_from_ts } from "$lib/util.js";
import { api_get_metrics } from "$lib/api.js"; import { api_get_metrics } from "$lib/api.js";
import Link from "$lib/link.svelte"; import Link from "$lib/link.svelte";
@ -20,11 +20,15 @@
</span> </span>
<span>/</span> <span>/</span>
<span> <span>
<Link link={app_url("/doc/license")} bold={true}>{$_("footer.license")}</Link> <Link link={urljoin(import.meta.env.WEBSITE_APP_URL, "doc/license")} bold={true}
>{$_("footer.license")}</Link
>
</span> </span>
<span>/</span> <span>/</span>
<span> <span>
<Link link={app_url("/doc/privacy")} bold={true}>{$_("footer.privacy")}</Link> <Link link={urljoin(import.meta.env.WEBSITE_APP_URL, "doc/privacy")} bold={true}
>{$_("footer.privacy")}</Link
>
</span> </span>
</div> </div>
<span class="counter"> <span class="counter">

View File

@ -1,6 +1,4 @@
import { locale_from_browser } from "$lib/locale.js"; import { locale_from_browser } from "$lib/locale.js";
import { browser } from "$app/environment";
import { page } from "$app/state";
const colors = [ const colors = [
"yellow", "yellow",
@ -21,7 +19,7 @@ function color() {
} }
function click() { function click() {
let audio = new Audio("/assets/click.wav"); let audio = new Audio("/click.wav");
audio.play(); audio.play();
} }
@ -41,18 +39,8 @@ function urljoin(url, path = null, query = {}) {
return url.href; return url.href;
} }
function env_url(prefix) {
let host = "";
if (browser) host = window.location.hostname;
if (host.endsWith(".onion")) return import.meta.env["WEBSITE_" + prefix + "_URL_ONION"];
else if (host.endsWith(".i2p")) return import.meta.env["WEBSITE_" + prefix + "_URL_I2P"];
else return import.meta.env["WEBSITE_" + prefix + "_URL_CLEAR"];
}
function app_url(path = null, query = {}) { function app_url(path = null, query = {}) {
return urljoin(env_url("APP"), path, query); return urljoin(import.meta.env.WEBSITE_APP_URL, path, query);
} }
function time_from_ts(ts) { function time_from_ts(ts) {
@ -80,4 +68,4 @@ function date_from_ts(ts) {
}).format(new Date(ts * 1000)); }).format(new Date(ts * 1000));
} }
export { color, click, urljoin, env_url, app_url, time_from_ts, date_from_ts }; export { color, click, urljoin, app_url, time_from_ts, date_from_ts };

View File

@ -21,7 +21,7 @@
</main> </main>
<style> <style>
@import "/css/global.css"; @import "/global.css";
main { main {
display: flex; display: flex;

View File

@ -37,7 +37,7 @@
{/if} {/if}
<style> <style>
@import "/css/markdown.css"; @import "/markdown.css";
main { main {
padding: 50px; padding: 50px;

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -6,5 +6,5 @@
font-style: normal; font-style: normal;
font-weight: 300; font-weight: 300;
font-display: swap; font-display: swap;
src: url("/assets/ubuntu.woff2") format("woff2"); src: url("/ubuntu.woff2") format("woff2");
} }

View File

@ -31,8 +31,7 @@
rgba(20, 20, 20, 0.3) 0px 18px 36px -18px inset; rgba(20, 20, 20, 0.3) 0px 18px 36px -18px inset;
--text-shadow: 3px 2px 8px rgba(50, 50, 50, 0.8); --text-shadow: 3px 2px 8px rgba(50, 50, 50, 0.8);
--background: linear-gradient(rgba(11, 11, 11, 0.808), rgba(1, 1, 1, 0.96)), --background: linear-gradient(rgba(11, 11, 11, 0.808), rgba(1, 1, 1, 0.96)), url("/banner.png");
url("/assets/banner.png");
--profile-size: 220px; --profile-size: 220px;
} }

View File

@ -3,44 +3,21 @@ import { defineConfig } from "vite";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
function env_from(prefix, object) {
for (const [key, value] of Object.entries(object)) {
let type = typeof value;
let name = prefix + "_" + key.toUpperCase();
switch (type) {
case "object":
env_from(name, value);
break;
case "string":
if (process.env[name] === undefined) process.env[name] = value;
break;
}
}
}
const default_env = { const default_env = {
source_url: "https://git.ngn.tf/ngn/website", REPORT_URL: "https://github.com/ngn13/website/issues",
report_url: "https://git.ngn.tf/ngn/website/issues", SOURCE_URL: "https://github.com/ngn13/website",
doc_url: "http://localhost:7003", APP_URL: "http://localhost:7001",
app_url: { API_URL: "http://localhost:7002",
clear: "http://localhost:7001", DOC_URL: "http://localhost:7003",
onion: "",
i2p: "",
},
api_url: {
clear: "http://localhost:7002",
onion: "",
i2p: "",
},
}; };
const package_file = fileURLToPath(new URL("package.json", import.meta.url)); const file = fileURLToPath(new URL("package.json", import.meta.url));
const package_json = readFileSync(package_file, "utf8"); const json = readFileSync(file, "utf8");
const package_data = JSON.parse(package_json); const pkg = JSON.parse(json);
env_from("WEBSITE", default_env); for (let env in default_env) {
if (process.env["WEBSITE_" + env] === undefined) process.env["WEBSITE_" + env] = default_env[env];
}
export default defineConfig({ export default defineConfig({
plugins: [sveltekit()], plugins: [sveltekit()],
@ -54,6 +31,6 @@ export default defineConfig({
strictPort: true, strictPort: true,
}, },
define: { define: {
pkg: package_data, pkg: pkg,
}, },
}); });