-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added description display (#151)
- Loading branch information
Showing
13 changed files
with
841 additions
and
24 deletions.
There are no files selected for viewing
Submodule TasksTemplate
updated
2 files
+5 −0 | tasks/simple-task-example/description.md | |
+6 −0 | toolbox/commands/verify.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::routes::task::TaskError; | ||
use crate::utils::app_state::AppState; | ||
use crate::utils::error::Error; | ||
use actix_web::web::{Data, Path}; | ||
use actix_web::{get, HttpResponse}; | ||
|
||
#[utoipa::path( | ||
responses( | ||
(status = 200, description = "Correctly returned task description", body = String), | ||
(status = 400, description = "Invalid task id."), | ||
(status = 404, description = "Task not found."), | ||
(status = 500, description = "Internal server error.") | ||
), | ||
tag = "tasks" | ||
)] | ||
#[get("/description/{task_id}")] | ||
pub async fn description( | ||
app_state: Data<AppState>, | ||
task_id: Path<String>, | ||
) -> Result<HttpResponse, Error> { | ||
let manager = app_state | ||
.task_manager | ||
.read() | ||
.map_err(|_| Error::PoisonedLock)?; | ||
let content_bytes = manager.load_asset(&task_id, "description.md").await?; | ||
let content = | ||
String::from_utf8(content_bytes).map_err(TaskError::ErrorWhileReadingDescription)?; | ||
|
||
Ok(HttpResponse::Ok().body(content)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@import 'tailwindcss'; | ||
@import '@nuxt/ui'; | ||
@plugin "@tailwindcss/typography"; | ||
@tailwind utilities; | ||
|
||
:root { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
const props = defineProps<{ | ||
text: string | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div class="prose prose-invert"> | ||
<MDC :value="props.text" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script setup lang="ts"> | ||
import { FetchError } from 'ofetch' | ||
const props = defineProps<{ | ||
taskId: string | string[] | undefined | ||
}>() | ||
const description = ref('') | ||
try { | ||
const taskId = String(props.taskId) | ||
const address = '/tasks/description/{task_id}' | ||
const { data: response } = await useApi(address, { | ||
path: { task_id: taskId }, | ||
key: `task-description-${taskId}`, | ||
}) | ||
if (response.value === undefined) { | ||
showError({ | ||
statusCode: 404, | ||
message: 'Zadanie nie zostało znalezione', | ||
}) | ||
console.error('Task not found') | ||
} else { | ||
description.value = String(response.value) | ||
} | ||
} catch (error) { | ||
console.error(error) | ||
if (!(error instanceof FetchError)) { | ||
throw error | ||
} | ||
showError(error) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col mx-[10vw] w-[80vw] pt-5"> | ||
<MarkdownContent :text="description" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script setup lang="ts"> | ||
const route = useRoute() | ||
const taskId = route.params.id | ||
</script> | ||
|
||
<template> | ||
<TaskDescription :task-id="taskId" /> | ||
</template> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.