Commit ee7ea45f authored by wycers's avatar wycers
Browse files

view submission

parent 585f0b2f
Loading
Loading
Loading
Loading

.prism-languages

0 → 100644
+99 −0
Original line number Diff line number Diff line
markup
css
clike
javascript
actionscript
ada
agda
antlr4
applescript
arduino
asciidoc
aspnet
autohotkey
bash
basic
batch
bbcode
bison
bnf
brainfuck
c
csharp
cpp
clojure
cmake
d
dart
diff
docker
ebnf
editorconfig
ejs
elixir
erlang
fsharp
fortran
git
go
graphql
groovy
haml
haskell
http
ini
java
jq
json
json5
julia
kotlin
latex
less
lisp
llvm
lua
makefile
markdown
matlab
monkey
nasm
nginx
nix
objectivec
ocaml
pascal
perl
php
powershell
protobuf
python
r
racket
jsx
tsx
reason
regex
ruby
rust
sass
scss
scala
scheme
smali
sparql
sql
stylus
swift
tcl
textile
toml
typescript
vala
vbnet
verilog
vhdl
vim
basic
wasm
yaml
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
		"@types/gravatar": "^1.8.6",
		"@types/lodash": "^4.14.202",
		"@types/node": "^20.11.24",
		"@types/prismjs": "^1.26.3",
		"@typescript-eslint/eslint-plugin": "^7.0.0",
		"@typescript-eslint/parser": "^7.0.0",
		"autoprefixer": "^10.4.16",
@@ -44,6 +45,7 @@
		"prettier-plugin-tailwindcss": "^0.5.9",
		"prism-themes": "^1.9.0",
		"prisma": "^5.11.0",
		"prismjs": "^1.29.0",
		"refractor": "^4.8.1",
		"sass": "^1.71.1",
		"svelte": "^4.2.7",
@@ -55,6 +57,7 @@
		"tslib": "^2.4.1",
		"typescript": "^5.3.3",
		"vite": "^5.0.3",
		"vite-plugin-prismjs": "^0.0.11",
		"vitest": "^1.2.0",
		"zod": "^3.22.4"
	},
+323 −4

File changed.

Preview size limit exceeded, changes collapsed.

+0 −1
Original line number Diff line number Diff line
@@ -195,7 +195,6 @@ model Problem {
model Submission {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  name String

+79 −0
Original line number Diff line number Diff line
<script lang="ts">
	import _ from 'lodash';
	import MonacoEditor from '../monaco/MonacoEditor.svelte';
	import { onMount } from 'svelte';
	import http from '$lib/shared/http';

	export let files: Array<{
		filename: string;
		content:
			| {
					url: string;
			  }
			| {
					text: string;
			  };
	}> = [];
	export let lang: 'cpp' | 'java' = 'cpp';

	let current = -1;
	let promise: Promise<string>;
	$: current = _.isEmpty(files) ? -1 : 0;
	$: if (current > -1) {
		const content = files[current].content;
		if ('url' in content) {
			promise = new Promise((res, rej) => {
				http
					.get(content.url)
					.then((resp) => res(resp.data))
					.catch(rej);
			});
		} else {
			promise = new Promise((res) => res(content.text));
		}
		lang = files[current].filename === 'main.cpp' ? 'cpp' : 'java';
	}

	onMount(() => {
		const updateHash = () => {
			current = _.findIndex(files, (file) => window.location.hash === '#' + file);
		};
		window.addEventListener('hashchange', updateHash);
		return () => window.removeEventListener('hashchange', updateHash);
	});
</script>

<div
	class="border-b border-gray-200 text-center text-sm font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"
>
	<ul class="-mb-px flex flex-wrap">
		{#each files as file, i}
			{@const filename = file.filename}
			{#if i == current}
				<li class="me-2">
					<a
						href={`#${filename}`}
						class="active inline-block rounded-t-lg border-b-2 border-blue-600 p-4 text-blue-600 dark:border-blue-500 dark:text-blue-500"
						aria-current="page">{filename}</a
					>
				</li>
			{:else}
				<li class="me-2">
					<a
						href={`#${filename}`}
						class="inline-block rounded-t-lg border-b-2 border-transparent p-4 hover:border-gray-300 hover:text-gray-600 dark:hover:text-gray-300"
						>{filename}</a
					>
				</li>
			{/if}
		{/each}
	</ul>
</div>

{#await promise}
	<p>...Loading</p>
{:then code}
	<MonacoEditor class="h-[400px]" readOnly={true} value={code} language={lang}></MonacoEditor>
{:catch error}
	<p style="color: red">{error.message}</p>
{/await}
Loading