|
1 | 1 | <script lang="ts"> |
2 | | - import type { FirstRunCredentials } from '$lib/server/auth'; |
3 | | - import api from '$endpoints'; |
4 | | - import Paper from '$components/Paper.svelte'; |
5 | | - import Background from '$components/Background.svelte'; |
6 | | - import Spinner from '$components/modals/Spinner.svelte'; |
7 | | - import Error from '$components/modals/Error.svelte'; |
8 | | - import Modal from '$components/modals/Modal.svelte'; |
9 | | - import { goto } from '$app/navigation'; |
10 | | - import Navbar from '$components/navbar'; |
11 | | - import blankConfig from '$lib/blankConfig'; |
12 | | - import CopyButton from '$components/CopyButton.svelte'; |
13 | | - import consts from '$lib/consts'; |
14 | | -
|
15 | | - let repoUrl = ''; |
16 | | - let repoBranch = ''; |
| 2 | + import { dev } from "$app/environment"; |
| 3 | + import type { FirstRunCredentials } from "$lib/server/auth"; |
| 4 | + import api from "$endpoints"; |
| 5 | + import Paper from "$components/Paper.svelte"; |
| 6 | + import Background from "$components/Background.svelte"; |
| 7 | + import Spinner from "$components/modals/Spinner.svelte"; |
| 8 | + import Error from "$components/modals/Error.svelte"; |
| 9 | + import Modal from "$components/modals/Modal.svelte"; |
| 10 | + import { goto } from "$app/navigation"; |
| 11 | + import Navbar from "$components/navbar"; |
| 12 | + import blankConfig from "$lib/blankConfig"; |
| 13 | + import CopyButton from "$components/CopyButton.svelte"; |
| 14 | + import consts from "$lib/consts"; |
| 15 | +
|
| 16 | + // In dev mode, use my portfolio data by default |
| 17 | + let repoUrl = dev ? "git@github.com:MaddyGuthridge/portfolio-data.git" : ""; |
| 18 | + let repoBranch = ""; |
17 | 19 | let credentials: FirstRunCredentials | undefined; |
18 | 20 |
|
19 | 21 | async function submitMain() { |
|
39 | 41 | async function onSubmit(e: SubmitEvent) { |
40 | 42 | const submitter = e.submitter?.id; |
41 | 43 | switch (submitter) { |
42 | | - case 'submit-main': |
| 44 | + case "submit-main": |
43 | 45 | await submitMain(); |
44 | 46 | break; |
45 | | - case 'submit-no-git': |
| 47 | + case "submit-no-git": |
46 | 48 | await submitNoGit(); |
47 | 49 | break; |
48 | 50 | default: |
49 | | - console.error('Submitter not recognised!'); |
| 51 | + console.error("Submitter not recognised!"); |
50 | 52 | } |
51 | 53 | } |
52 | 54 |
|
53 | 55 | let showLoading = false; |
54 | 56 |
|
55 | | - let errorText = ''; |
| 57 | + let errorText = ""; |
56 | 58 | </script> |
57 | 59 |
|
58 | 60 | <svelte:head> |
59 | 61 | <title>Setup - {consts.APP_NAME}</title> |
60 | | - <meta name="generator" content="{consts.APP_NAME}"> |
61 | | - <meta name="theme-color" content="#aa00aa"> |
| 62 | + <meta name="generator" content={consts.APP_NAME} /> |
| 63 | + <meta name="theme-color" content="#aa00aa" /> |
62 | 64 | <!-- |
63 | 65 | Prevent web crawlers from indexing the firstrun page. Of course, if someone |
64 | 66 | has an instance of this exposed to the open web without it being set up, |
65 | 67 | that's absolutely on them, but the least we can do is stop instances that |
66 | 68 | aren't set up from being easily searchable. |
67 | 69 | --> |
68 | | - <meta name="robots" content="noindex"> |
| 70 | + <meta name="robots" content="noindex" /> |
69 | 71 | </svelte:head> |
70 | 72 |
|
71 | 73 | <Background color="#aa00aa"></Background> |
|
76 | 78 | <Paper> |
77 | 79 | <main> |
78 | 80 | <div class="center"> |
79 | | - <h1 style="font-size: 3rem"> Welcome to your fancy new portfolio website! </h1> |
| 81 | + <h1 style="font-size: 3rem"> |
| 82 | + Welcome to your fancy new portfolio website! |
| 83 | + </h1> |
80 | 84 | <h2>Let's get set up!</h2> |
81 | 85 | </div> |
82 | 86 |
|
83 | 87 | <form on:submit={onSubmit}> |
84 | 88 | <h3>Data repository URL</h3> |
85 | | - <input type="text" id="repo-url" bind:value={repoUrl} placeholder="git@github.com:MaddyGuthridge/portfolio.git" /> |
| 89 | + <input |
| 90 | + type="text" |
| 91 | + id="repo-url" |
| 92 | + bind:value={repoUrl} |
| 93 | + placeholder="git@github.com:MaddyGuthridge/portfolio-data.git" |
| 94 | + /> |
86 | 95 | <p> |
87 | | - It's a good idea to set up a repository to back up your portfolio data. |
| 96 | + It's a good idea to set up a repository to back up your portfolio |
| 97 | + data. |
88 | 98 | <a |
89 | 99 | href="https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository" |
90 | | - target="_blank" |
91 | | - >Create an empty git repository</a> |
| 100 | + target="_blank">Create an empty git repository</a |
| 101 | + > |
92 | 102 | and enter the clone URL here. If you want to import existing data, enter |
93 | 103 | your existing repository URL here. |
94 | 104 | </p> |
95 | 105 |
|
96 | 106 | <h3>Repository branch</h3> |
97 | | - <input type="text" id="repo-branch" bind:value={repoBranch} placeholder="main" /> |
| 107 | + <input |
| 108 | + type="text" |
| 109 | + id="repo-branch" |
| 110 | + bind:value={repoBranch} |
| 111 | + placeholder="main" |
| 112 | + /> |
98 | 113 | <p>If you want to use a specific branch, you can enter it above.</p> |
99 | 114 |
|
100 | 115 | <h3>Ready to get started?</h3> |
101 | 116 | <input type="submit" id="submit-main" value="Let's go!" /> |
102 | 117 |
|
103 | 118 | <h3>Don't want to use a git repo?</h3> |
104 | 119 | <p> |
105 | | - Using a git repo is a great idea if you want your data to be safely |
| 120 | + Using a git repo is a great idea if you want your data to be safely |
106 | 121 | backed up. But if you're just testing {consts.APP_NAME}, it's much |
107 | 122 | quicker to get started without a git repo. |
108 | 123 | </p> |
109 | | - <input type="submit" id="submit-no-git" value="I don't want to use git" /> |
| 124 | + <input |
| 125 | + type="submit" |
| 126 | + id="submit-no-git" |
| 127 | + value="I don't want to use git" |
| 128 | + /> |
110 | 129 | </form> |
111 | 130 | </main> |
112 | 131 | </Paper> |
113 | 132 | </div> |
114 | 133 |
|
115 | 134 | <!-- Spinner shows while setting up data dir --> |
116 | | -<Spinner show={showLoading} header="Just a moment..." text="We're setting up your data" /> |
| 135 | +<Spinner |
| 136 | + show={showLoading} |
| 137 | + header="Just a moment..." |
| 138 | + text="We're setting up your data" |
| 139 | +/> |
117 | 140 |
|
118 | 141 | <!-- Error shows if error occurs with setup --> |
119 | | -<Error show={errorText !== ''} header="Oh no!" text={errorText} on:close={() => { errorText = ''; }} /> |
| 142 | +<Error |
| 143 | + show={errorText !== ""} |
| 144 | + header="Oh no!" |
| 145 | + text={errorText} |
| 146 | + on:close={() => { |
| 147 | + errorText = ""; |
| 148 | + }} |
| 149 | +/> |
120 | 150 |
|
121 | 151 | {#if credentials} |
122 | | - <Modal show={true} on:close={() => goto('/')}> |
| 152 | + <Modal show={true} on:close={() => goto("/")}> |
123 | 153 | <h1 slot="header">Your data is set up!</h1> |
124 | 154 | <p>This is your login information. Please ensure you do not lose it.</p> |
125 | 155 | <!-- TODO: Add copy buttons for convenience --> |
|
128 | 158 | </p> |
129 | 159 | <div class="horizontal"> |
130 | 160 | Password: <b>{credentials.password}</b> |
131 | | - <CopyButton text={credentials.password} hint='Copy password'>Copy</CopyButton> |
| 161 | + <CopyButton text={credentials.password} hint="Copy password" |
| 162 | + >Copy</CopyButton |
| 163 | + > |
132 | 164 | </div> |
133 | 165 | </Modal> |
134 | 166 | {/if} |
|
0 commit comments