Skip to content

Commit

Permalink
changes [deploy]
Browse files Browse the repository at this point in the history
  • Loading branch information
mbund committed Sep 26, 2024
1 parent 0d0d571 commit ea4450a
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rhombus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rhombus"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
description = "Next generation extendable CTF framework with batteries included"
authors = ["Mark Bundschuh <[email protected]>"]
Expand Down
67 changes: 41 additions & 26 deletions rhombus/frontend/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -631,38 +631,49 @@ const ChallengesComponent = ({
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-layout-grid"
class="lucide lucide-expand"
>
<rect width="7" height="7" x="3" y="3" rx="1" />
<rect
width="7"
height="7"
x="14"
y="3"
rx="1"
/>
<rect
width="7"
height="7"
x="14"
y="14"
rx="1"
/>
<rect
width="7"
height="7"
x="3"
y="14"
rx="1"
/>
<path d="m21 21-6-6m6 6v-4.8m0 4.8h-4.8" />
<path d="M3 16.2V21m0 0h4.8M3 21l6-6" />
<path d="M21 7.8V3m0 0h-4.8M21 3l-6 6" />
<path d="M3 7.8V3m0 0h4.8M3 3l6 6" />
</svg>
</button>
</div>
</div>
<SolidMarkdown
<div
class="prose dark:prose-invert"
children={challenge.description}
/>
innerHTML={challenge.description}
></div>
<div class="flex gap-2 mt-4">
<For each={challenge.attachments}>
{(attachment) => (
<a
class="pr-2 py-1 pl-1 max-w-fit rounded-lg flex"
style={`background-color: ${category.color}77`}
href={attachment.url}
>
<div class="scale-75">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-paperclip"
>
<path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" />
</svg>
</div>
{attachment.name}
</a>
)}
</For>
</div>
</li>
);
}}
Expand Down Expand Up @@ -698,6 +709,10 @@ type ChallengesData = {
points: number;
solves: number;
}[];
attachments: {
name: string;
url: string;
}[];
}[];
categories: {
id: number;
Expand Down
17 changes: 15 additions & 2 deletions rhombus/src/challenge_loader_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,19 @@ impl Plugin for ChallengeLoaderPlugin {

tracing::info!(name = challenge.name);

let description = markdown::to_html_with_options(
&challenge.description,
&markdown::Options {
compile: markdown::CompileOptions {
allow_dangerous_html: true,
allow_dangerous_protocol: true,
..markdown::CompileOptions::default()
},
..markdown::Options::default()
},
)
.unwrap();

_ = tx
.execute(
"
Expand All @@ -246,7 +259,7 @@ impl Plugin for ChallengeLoaderPlugin {
params!(
id,
challenge.name.as_str(),
challenge.description.as_str(),
description.as_str(),
challenge.flag.as_str(),
category_id,
author_id,
Expand Down Expand Up @@ -314,7 +327,7 @@ impl Plugin for ChallengeLoaderPlugin {

let url = context
.upload_provider
.upload(src.file_name().unwrap().to_str().unwrap(), stream)
.upload(&file.dst, stream)
.await
.unwrap();

Expand Down
32 changes: 4 additions & 28 deletions rhombus/src/internal/routes/challenges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ pub async fn route_challenges(
"points": division_points.points,
"solves": division_points.solves,
})).collect::<serde_json::Value>(),
"attachments": challenge.attachments.iter().map(|attachment| json!({
"name": attachment.name,
"url": attachment.url,
})).collect::<serde_json::Value>(),
})).collect::<serde_json::Value>(),
"categories": challenge_data.categories.iter().map(|category| json!({
"id": category.id,
Expand Down Expand Up @@ -167,19 +171,6 @@ pub async fn route_challenge_view(
.find(|c| challenge.category_id.eq(&c.id))
.unwrap();

let description = markdown::to_html_with_options(
&challenge.description,
&markdown::Options {
compile: markdown::CompileOptions {
allow_dangerous_html: true,
allow_dangerous_protocol: true,
..markdown::CompileOptions::default()
},
..markdown::Options::default()
},
)
.unwrap();

Html(
state
.jinja
Expand All @@ -190,7 +181,6 @@ pub async fn route_challenge_view(
page,
user,
challenge,
description,
category,
team,
divisions => challenge_data.divisions,
Expand Down Expand Up @@ -260,19 +250,6 @@ pub async fn route_ticket_view(
state.settings.read().await.default_ticket_template.clone()
};

let description = markdown::to_html_with_options(
&challenge.description,
&markdown::Options {
compile: markdown::CompileOptions {
allow_dangerous_html: true,
allow_dangerous_protocol: true,
..markdown::CompileOptions::default()
},
..markdown::Options::default()
},
)
.unwrap();

Html(
state
.jinja
Expand All @@ -283,7 +260,6 @@ pub async fn route_ticket_view(
page,
user,
challenge,
description,
category,
team,
ticket_template,
Expand Down
27 changes: 3 additions & 24 deletions rhombus/static/app.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions rhombus/static/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -1466,10 +1466,6 @@ body {
height: 100%;
}

.h-1 {
height: 0.25rem;
}

.h-10 {
height: 2.5rem;
}
Expand Down
4 changes: 3 additions & 1 deletion rhombus/templates/challenge.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
</rhombus-tooltip>
</div>
</div>
<div class="mb-4 prose dark:prose-invert">{{ description | safe }}</div>
<div class="mb-4 prose dark:prose-invert">
{{ challenge.description | safe }}
</div>
{% with solve=team.solves[challenge.id] %}
{% if not solve %}
<form
Expand Down
4 changes: 3 additions & 1 deletion rhombus/templates/ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
<span>{{ challenge.name }}</span>
</div>
</div>
<div class="mb-4 prose dark:prose-invert">{{ description | safe }}</div>
<div class="mb-4 prose dark:prose-invert">
{{ challenge.description | safe }}
</div>
<div class="h-60 mb-2" id="editor"></div>
<button
class="p-2 rounded-lg"
Expand Down

0 comments on commit ea4450a

Please sign in to comment.