Skip to content

Commit 409f7d1

Browse files
committed
Allow modifying website
1 parent 2774bb4 commit 409f7d1

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

flake.nix

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,32 @@
77

88
outputs = { self, nixpkgs }: let
99
pkgs = import nixpkgs {system = "x86_64-linux";};
10-
sdow-website = pkgs.buildNpmPackage {
11-
name = "sdow";
12-
buildInputs = with pkgs; [
13-
nodejs_latest
14-
];
15-
src = ./website;
16-
17-
npmDeps = pkgs.importNpmLock {
18-
npmRoot = ./website;
19-
};
10+
sdow-website = {lang ? null, wikipediaApiUrl ? null, sdowApiUrl ? null, sdowUserAgent ? null }:
11+
let extraArgs = {} //
12+
(if wikipediaApiUrl == null then {VITE_WIKIPEDIA_API_URL=wikipediaApiUrl;} else
13+
if lang == null then {VITE_WIKIPEDIA_API_URL="https://${lang}.wikipedia.org/w/api.php";} else {}) //
14+
(if sdowApiUrl == null then {VITE_SDOW_API_URL=sdowApiUrl;} else {}) //
15+
(if sdowUserAgent == null then {VITE_SDOW_USER_AGENT=sdowUserAgent;} else {});
16+
in pkgs.buildNpmPackage ({
17+
name = "sdow";
18+
buildInputs = with pkgs; [
19+
nodejs_latest
20+
];
21+
src = ./website;
22+
npmDeps = pkgs.importNpmLock {
23+
npmRoot = ./website;
24+
};
2025

21-
npmFlags = [ "--legacy-peer-deps" ];
26+
npmFlags = [ "--legacy-peer-deps" ];
2227

23-
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
28+
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
2429

25-
installPhase = ''
26-
cp -r ./dist/ $out
27-
'';
28-
};
30+
installPhase = ''
31+
cp -r ./dist/ $out
32+
'';
33+
} // extraArgs);
2934
sdow-http = pkgs.writeShellScript "sdow" ''
30-
${pkgs.simple-http-server}/bin/simple-http-server ${self.packages.x86_64-linux.sdow} "$@"
35+
${pkgs.simple-http-server}/bin/simple-http-server ${sdow-website {}} "$@"
3136
'';
3237
python-gunicorn = pkgs.python3.withPackages (pp: with pp;[
3338
flask
@@ -89,7 +94,8 @@
8994

9095
packages.x86_64-linux = {
9196
default = self.packages.x86_64-linux.sdow;
92-
sdow = sdow-website;
97+
sdow = sdow-website {};
98+
sdow-lang = sdow-website;
9399

94100
sdow-api = pkgs.stdenv.mkDerivation {
95101
name = "sdow-api";

website/src/resources/constants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const SDOW_API_URL_DEV = 'http://127.0.0.1:5000';
22
const SDOW_API_URL_PROD = 'https://api.sixdegreesofwikipedia.com';
33

4-
export const SDOW_API_URL =
5-
process.env.NODE_ENV === 'production' ? SDOW_API_URL_PROD : SDOW_API_URL_DEV;
4+
export const SDOW_API_URL = import.meta.env.VITE_SDOW_API_URL ??
5+
import.meta.env.NODE_ENV === 'production' ? SDOW_API_URL_PROD : SDOW_API_URL_DEV;
66

7-
export const WIKIPEDIA_API_URL = 'https://en.wikipedia.org/w/api.php';
7+
export const WIKIPEDIA_API_URL = import.meta.env.VITE_WIKIPEDIA_API_URL ?? 'https://en.wikipedia.org/w/api.php';
88

9-
export const SDOW_USER_AGENT =
9+
export const SDOW_USER_AGENT = import.meta.env.VITE_SDOW_USER_AGENT ??
1010
'Six Degrees of Wikipedia/1.0 (https://www.sixdegreesofwikipedia.com/; wenger.jacob@gmail.com)';

0 commit comments

Comments
 (0)