Skip to content

Commit 6b576ee

Browse files
Merge pull request #16 from MaddyGuthridge/maddy-dev-qol
Quality-of-life improvements
2 parents c52fd1d + bd04d8e commit 6b576ee

File tree

5 files changed

+101
-45
lines changed

5 files changed

+101
-45
lines changed

src/components/markdown/Markdown.svelte

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<script lang="ts">
2-
import { marked } from 'marked';
3-
import hljs from 'highlight.js';
4-
import 'highlight.js/styles/stackoverflow-light.css';
2+
import { marked } from "marked";
3+
import hljs from "highlight.js";
4+
import "highlight.js/styles/stackoverflow-light.css";
55
66
export let source: string;
77
88
// https://github.com/markedjs/marked/discussions/2982#discussioncomment-6979586
99
const renderer = {
1010
link(href: string, title: string | null | undefined, text: string) {
1111
const link = marked.Renderer.prototype.link.call(this, href, title, text);
12-
return link.replace('<a', "<a target='_blank' rel='noreferrer' ");
13-
}
12+
return link.replace("<a", "<a target='_blank' rel='noreferrer' ");
13+
},
1414
};
1515
marked.use({ renderer });
1616
@@ -31,7 +31,7 @@
3131
// function when we just subscribe to what their contents are supposed to
3232
// be
3333
setTimeout(() => {
34-
renderElement.querySelectorAll('pre code').forEach((el) => {
34+
renderElement.querySelectorAll("pre code").forEach((el) => {
3535
hljs.highlightElement(el as HTMLElement);
3636
});
3737
});
@@ -48,7 +48,8 @@
4848
</div>
4949

5050
<style>
51-
.markdown-render :global(p > code), .markdown-render :global(pre) {
51+
.markdown-render :global(p > code),
52+
.markdown-render :global(pre) {
5253
background-color: rgb(245, 245, 245);
5354
padding: 2px 5px;
5455
border-radius: 3px;
@@ -67,6 +68,28 @@
6768
padding: 1em;
6869
}
6970
71+
/*
72+
Pretty block-quotes
73+
Source: https://css-tricks.com/snippets/css/simple-and-nice-blockquote-styling/
74+
*/
75+
.markdown-render :global(blockquote) {
76+
background: #f9f9f973;
77+
border-left: 5px solid #ccccccc2;
78+
margin: 1.5em 10px;
79+
padding: 0.5em 10px;
80+
}
81+
.markdown-render :global(blockquote:before) {
82+
color: #ccccccc2;
83+
content: "\201C";
84+
font-size: 4em;
85+
line-height: 0.1em;
86+
margin-right: 0.25em;
87+
vertical-align: -0.4em;
88+
}
89+
.markdown-render :global(blockquote p) {
90+
display: inline;
91+
}
92+
7093
.markdown-render :global(a) {
7194
text-decoration: none;
7295
}

src/routes/[group]/+page.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
async function finishEditing(save: boolean) {
5555
if (save) {
5656
// Update readme
57+
console.log(readme);
5758
groupData.readme = readme;
5859
await api().group.withId(data.groupId).readme.set(readme);
5960
groupData.info.listedItems = [...shownItems];
@@ -117,7 +118,7 @@
117118
<div id="readme">
118119
<div id="info-container">
119120
<EditableMarkdown
120-
source={groupData.readme}
121+
bind:source={readme}
121122
editing={editing}
122123
/>
123124
</div>

src/routes/[group]/[item]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
{/if}
113113
<div id="info-container">
114114
<EditableMarkdown
115-
source={readme}
115+
bind:source={readme}
116116
{editing}
117117
/>
118118
<!-- Display linked items as chips -->

src/routes/admin/GitSettings.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
<!-- Push/pull -->
3636
{#if data.repo.behind}
37-
<button on:click={() => api().admin.git.push()}>Push</button>
38-
{:else if data.repo.ahead}
3937
<button on:click={() => api().admin.git.pull()}>Pull</button>
38+
{:else if data.repo.ahead}
39+
<button on:click={() => api().admin.git.push()}>Push</button>
4040
{/if}
4141

4242
<!-- Commit -->

src/routes/admin/firstrun/+page.svelte

Lines changed: 66 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<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 = "";
1719
let credentials: FirstRunCredentials | undefined;
1820
1921
async function submitMain() {
@@ -39,33 +41,33 @@
3941
async function onSubmit(e: SubmitEvent) {
4042
const submitter = e.submitter?.id;
4143
switch (submitter) {
42-
case 'submit-main':
44+
case "submit-main":
4345
await submitMain();
4446
break;
45-
case 'submit-no-git':
47+
case "submit-no-git":
4648
await submitNoGit();
4749
break;
4850
default:
49-
console.error('Submitter not recognised!');
51+
console.error("Submitter not recognised!");
5052
}
5153
}
5254
5355
let showLoading = false;
5456
55-
let errorText = '';
57+
let errorText = "";
5658
</script>
5759

5860
<svelte:head>
5961
<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" />
6264
<!--
6365
Prevent web crawlers from indexing the firstrun page. Of course, if someone
6466
has an instance of this exposed to the open web without it being set up,
6567
that's absolutely on them, but the least we can do is stop instances that
6668
aren't set up from being easily searchable.
6769
-->
68-
<meta name="robots" content="noindex">
70+
<meta name="robots" content="noindex" />
6971
</svelte:head>
7072

7173
<Background color="#aa00aa"></Background>
@@ -76,50 +78,78 @@
7678
<Paper>
7779
<main>
7880
<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>
8084
<h2>Let's get set up!</h2>
8185
</div>
8286

8387
<form on:submit={onSubmit}>
8488
<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+
/>
8695
<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.
8898
<a
8999
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+
>
92102
and enter the clone URL here. If you want to import existing data, enter
93103
your existing repository URL here.
94104
</p>
95105

96106
<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+
/>
98113
<p>If you want to use a specific branch, you can enter it above.</p>
99114

100115
<h3>Ready to get started?</h3>
101116
<input type="submit" id="submit-main" value="Let's go!" />
102117

103118
<h3>Don't want to use a git repo?</h3>
104119
<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
106121
backed up. But if you're just testing {consts.APP_NAME}, it's much
107122
quicker to get started without a git repo.
108123
</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+
/>
110129
</form>
111130
</main>
112131
</Paper>
113132
</div>
114133

115134
<!-- 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+
/>
117140

118141
<!-- 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+
/>
120150

121151
{#if credentials}
122-
<Modal show={true} on:close={() => goto('/')}>
152+
<Modal show={true} on:close={() => goto("/")}>
123153
<h1 slot="header">Your data is set up!</h1>
124154
<p>This is your login information. Please ensure you do not lose it.</p>
125155
<!-- TODO: Add copy buttons for convenience -->
@@ -128,7 +158,9 @@
128158
</p>
129159
<div class="horizontal">
130160
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+
>
132164
</div>
133165
</Modal>
134166
{/if}

0 commit comments

Comments
 (0)