changes
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
|
||||
export let gamemode: string;
|
||||
|
||||
export let topFive: boolean = false;
|
||||
|
||||
let request = getRequest();
|
||||
|
||||
function getRequest() {
|
||||
@@ -33,6 +35,7 @@
|
||||
{#await request}
|
||||
<p>Loading...</p>
|
||||
{:then data}
|
||||
{@const topFiveData = data.slice(0, 5)}
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -43,7 +46,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each data as player, i (player.name)}
|
||||
{#each (topFive ? topFiveData : data) as player, i (player.name)}
|
||||
<tr>
|
||||
<td>{`${i + 1}.`}</td>
|
||||
<td>{player.name}</td>
|
||||
|
||||
@@ -42,20 +42,31 @@
|
||||
value: branch
|
||||
}));
|
||||
|
||||
async function createBranch() {
|
||||
const name = prompt("Branch name:");
|
||||
if (name) {
|
||||
selected = null;
|
||||
await $pageRepo.createBranch(name);
|
||||
let inter = setInterval(() => {
|
||||
branches.reload();
|
||||
if ($branches.includes(name)) {
|
||||
selectedBranch = name;
|
||||
searchValue = "";
|
||||
clearInterval(inter);
|
||||
async function createBranch(name: string | null = null): Promise<string> {
|
||||
return new Promise(async (resolve) => {
|
||||
if (!name) {
|
||||
name = prompt("Branch name:");
|
||||
|
||||
if (!name) {
|
||||
resolve("");
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
if (name) {
|
||||
selected = null;
|
||||
await $pageRepo.createBranch(name);
|
||||
let inter = setInterval(() => {
|
||||
branches.reload();
|
||||
if ($branches.includes(name!)) {
|
||||
selectedBranch = name!;
|
||||
searchValue = "";
|
||||
clearInterval(inter);
|
||||
|
||||
resolve(name!);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function changePage(id: number) {
|
||||
@@ -101,6 +112,33 @@
|
||||
selectedBranch = "###!";
|
||||
selectedBranch = w;
|
||||
}
|
||||
|
||||
async function newAnnouncement() {
|
||||
const title = prompt("Title: ");
|
||||
|
||||
if (!title) {
|
||||
return;
|
||||
}
|
||||
|
||||
const slug = title.toLowerCase().replace(/ /g, "-");
|
||||
|
||||
const branch = await createBranch(slug)
|
||||
|
||||
selectedPath = "announcements/de/"
|
||||
|
||||
await $pageRepo.createFile(`${selectedPath}${slug}.md`, branch, slug, title);
|
||||
reload();
|
||||
|
||||
const pages = await $pageRepo.listPages(branch);
|
||||
|
||||
const page = pages.find(page => page.path === `${selectedPath}${slug}.md`);
|
||||
|
||||
if (page) {
|
||||
changePage(page.id);
|
||||
} else {
|
||||
alert("Error creating page");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col h-screen overflow-scroll">
|
||||
@@ -139,10 +177,6 @@
|
||||
<ul>
|
||||
{#if (selectedPath)}
|
||||
{@const value = pagesMap.get(selectedPath) || []}
|
||||
{#if value.length === 0}
|
||||
<li class="p-4">No pages found</li>
|
||||
<li class="p-4">Select a path on the top</li>
|
||||
{/if}
|
||||
{#each value as page}
|
||||
{@const nameRegexExec = nameRegex.exec(page.path)}
|
||||
{@const match = nameRegexExec ? nameRegexExec[0] : ""}
|
||||
@@ -156,6 +190,8 @@
|
||||
class:text-orange-600={selected === page.id}>{page.path.substring(endIndex, page.path.length)}</span>
|
||||
</li>
|
||||
{/each}
|
||||
{:else}
|
||||
<Button on:click={newAnnouncement}>Neue Ankündigung</Button>
|
||||
{/if}
|
||||
</ul>
|
||||
{:catch error}
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
</ToolbarGroup>
|
||||
</Toolbar>
|
||||
</div>
|
||||
{#if page?.name.endsWith("md")}
|
||||
{#if page?.name.endsWith("md") || page?.name.endsWith("mdx")}
|
||||
<MDEMarkdownEditor bind:value={pageContent} bind:dirty/>
|
||||
{:else}
|
||||
<CodeMirror bind:value={pageContent} lang={json()} theme={materialDark} on:change={() => dirty = true}/>
|
||||
|
||||
@@ -57,4 +57,8 @@
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
||||
:global(.CodeMirror) {
|
||||
font-family: monospace !important;
|
||||
}
|
||||
</style>
|
||||
@@ -65,8 +65,8 @@ export class PageRepo {
|
||||
await fetchWithToken(this.token, "/page/branch", {method: "DELETE", body: JSON.stringify({branch})});
|
||||
}
|
||||
|
||||
public async createFile(path: string, branch: string = "master"): Promise<void> {
|
||||
await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path})});
|
||||
public async createFile(path: string, branch: string = "master", slug: string | null = null, title: string | null = null): Promise<void> {
|
||||
await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path, slug, title})});
|
||||
}
|
||||
|
||||
public async merge(branch: string, message: string): Promise<void> {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import type {SchematicInfo, SchematicList} from "@type/schem.ts";
|
||||
import {type Schematic, type SchematicInfo, type SchematicList, SchematicSchema} from "@type/schem.ts";
|
||||
import {SchematicInfoSchema, SchematicListSchema} from "@type/schem.ts";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
@@ -38,6 +38,14 @@ export class SchematicRepo {
|
||||
return await fetchWithToken(this.token, `/schem/${id}`).then(value => value.json()).then(SchematicInfoSchema.parse);
|
||||
}
|
||||
|
||||
public async getSchematicCodeInfo(code: string): Promise<Schematic> {
|
||||
return await fetchWithToken(this.token, `/schem/download/${code}/info`).then(value => value.json()).then(SchematicSchema.parse);
|
||||
}
|
||||
|
||||
public getSchematicDownloadUrl(code: string): string {
|
||||
return `/schem/download/${code}`;
|
||||
}
|
||||
|
||||
public async uploadSchematic(name: string, content: string) {
|
||||
return await fetchWithToken(this.token, "/schem", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user