commit 1faed6e0724acbb0fe0f0bba3b0f30c8e6dfe51e
parent b279c67105d53ccf3681772610e24bb448f8c656
Author: Andrew Laack <andrew@laack.co>
Date: Fri, 13 Nov 2026 19:36:56 -0600
Added basic script for rendering problems
Diffstat:
7 files changed, 69 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
@@ -28,6 +28,7 @@ build-cgi: build-ocaml
mkdir -p cgi-bin
cp scripts/home.sh cgi-bin/home
cp scripts/submit.sh cgi-bin/submit
+ cp scripts/problems.sh cgi-bin/problems
deploy-server: build-cgi
@@ -37,7 +38,7 @@ deploy-server: build-cgi
# state directories
sudo mkdir -p /var/lib/ojudge
- sudo cp -r assets/problems /var/lib/ojudge/problems
+ sudo cp -r assets/problems /var/lib/ojudge/
sudo mkdir -p /var/lib/ojudge/submissions
sudo mkdir -p /var/lib/ojudge/pending-review
sudo mkdir -p /var/lib/ojudge/problems
diff --git a/assets/problems/000001/problem.html b/assets/problems/000001/problem.html
@@ -7,34 +7,58 @@ There are buildings in front of you with heights [a_0,a_1,...,a_{n-1}], where a_
The first building is 100 units in front of you, and your eyes are 6 units above ground level. How many buildings are visible?
-Constraints:
+</p>
+
+<h2>Constraints</h2>
+
+<p>
-- 10 <= a_i <= 10^8
-- 1 <= n <= 10^7
+<ul>
+<li> 10 <= a_i <= 10^8 </li>
+<li> 1 <= n <= 10^7 </li>
+</ul>
+
+</p>
-Inputs:
+<h2>Inputs</h2>
+
+<p>
+
+<ul>
+<li> first line: n </li>
+<li> second line: the n integers of a </li>
+</ul>
+
+</p>
-- first line: n
-- second line: the n integers of a
+<h2>Examples</h2>
-Examples:
+<p>
Input 1:
+<pre>
6
10 47 500 1000 2783 4616
+</pre>
Output 1:
+<pre>
6
+</pre>
Input 2:
+<pre>
8
100 187 100 1000 1250 10000 1238 47100
+</pre>
Output 2:
+<pre>
4
+</pre>
</p>
diff --git a/cgi-bin/home b/cgi-bin/home
@@ -1,2 +1,9 @@
#!/bin/sh
-echo "<h1>This is the home! </h1>"
+echo "<h1>Problems</h1>"
+echo ""
+
+PROBLEMS=$(ls /var/lib/ojudge/problems/)
+
+for PROBLEM in $PROBLEMS; do
+ echo "<a href=\"problems/$PROBLEM\">$PROBLEM</a><br>"
+done
diff --git a/cgi-bin/problems b/cgi-bin/problems
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+echo "Content-Type: text/html"
+echo
+
+id=${PATH_INFO##*/}
+
+echo "<h1>Problem: $id</h1>"
+cat "/var/lib/ojudge/problems/$id/problem.html"
diff --git a/lighttpd.conf b/lighttpd.conf
@@ -23,5 +23,6 @@ $HTTP["url"] =~ "^/cgi-bin/" {
}
url.rewrite-once = (
- "^/(\?.*)?$" => "/cgi-bin/home$1"
+ "^/(\?.*)?$" => "/cgi-bin/home$1",
+ "^/problems(/[^?]*)?(\?.*)?$" => "/cgi-bin/problems$1$2"
)
diff --git a/scripts/home.sh b/scripts/home.sh
@@ -1,2 +1,9 @@
#!/bin/sh
-echo "<h1>This is the home! </h1>"
+echo "<h1>Problems</h1>"
+echo ""
+
+PROBLEMS=$(ls /var/lib/ojudge/problems/)
+
+for PROBLEM in $PROBLEMS; do
+ echo "<a href=\"problems/$PROBLEM\">$PROBLEM</a><br>"
+done
diff --git a/scripts/problems.sh b/scripts/problems.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+echo "Content-Type: text/html"
+echo
+
+id=${PATH_INFO##*/}
+
+echo "<h1>Problem: $id</h1>"
+cat "/var/lib/ojudge/problems/$id/problem.html"