Skip to content

Commit

Permalink
Added HTML encoding for a few accented characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamkirby committed Feb 2, 2024
1 parent 2c35158 commit 4a5943a
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 19 deletions.
20 changes: 16 additions & 4 deletions src/main/java/lap_race/OutputHTML.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

Expand Down Expand Up @@ -119,7 +122,7 @@ private void printOverallResultsBody(final OutputStreamWriter writer) throws IOE
writer.append("""
</td>
<td>""");
writer.append(String.valueOf(result.team.name));
writer.append(htmlEncode(result.team.name));
writer.append("""
</td>
<td>""");
Expand Down Expand Up @@ -203,7 +206,7 @@ private void printDetailedResult(final OutputStreamWriter writer, final int resu
writer.append("""
</td>
<td>""");
writer.append(String.valueOf(result.team.name));
writer.append(htmlEncode(result.team.name));
writer.append("""
</td>
<td>""");
Expand Down Expand Up @@ -242,7 +245,7 @@ private void printLegDetails(OutputStreamWriter writer, OverallResult result, Te

writer.append("""
<td>""");
writer.append(team.runners[leg - 1]);
writer.append(htmlEncode(team.runners[leg - 1]));

addMassStartAnnotation(writer, leg_result, leg);

Expand Down Expand Up @@ -294,7 +297,7 @@ private void printLegResultsBody(final OutputStreamWriter writer, final LegResul
writer.append("""
</td>
<td>""");
writer.append(leg_result.team.runners[leg_result.leg_number-1]);
writer.append(htmlEncode(leg_result.team.runners[leg_result.leg_number-1]));
writer.append("""
</td>
<td>""");
Expand All @@ -305,11 +308,20 @@ private void printLegResultsBody(final OutputStreamWriter writer, final LegResul
}
}
}

private void printLegResultsFooter(final OutputStreamWriter writer) throws IOException {

writer.append("""
</tbody>
</table>
""");
}

private String htmlEncode(String s) {

return s.replaceAll("è", "&egrave;").
replaceAll("é", "&eacute;").
replaceAll("ü", "&uuml;").
replaceAll("’", "&acute;");
}
}
5 changes: 5 additions & 0 deletions src/test/java/lap_race/devils_burdens/ResultsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ResultsTest {
@AfterEach
public void tearDown() throws IOException {

// Disable this when debugging and you don't want the test results to be immediately deleted.

FileManipulation.deleteDirectory(temp_directory);
}

Expand Down Expand Up @@ -455,7 +457,10 @@ private void processingCompletes(String configuration_name) throws Exception {

private void configureTest(String test_resource_root) throws IOException {

// Swap these when debugging and you don't want the test results to be immediately deleted.

temp_directory = Files.createTempDirectory(null);
// temp_directory = Paths.get("/Users/gnck/Desktop/temp");

Path temp_input_sub_directory = Files.createDirectories(temp_directory.resolve("input"));
temp_output_sub_directory = Files.createDirectories(temp_directory.resolve("output"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Pos,No,Team,Category,Runners 1,Leg 1,Split 1,Runners 2,Leg 2,Split 2,Runners 3,L
1,1,Team 1,Women Senior,John Smith,00:42:43,00:42:43,Hailey Dickson:) & Alix Crawford,00:44:17,01:27:00,Rhys Müllar & Paige Thompson,01:08:05,02:35:05,Amé MacDonald,01:12:53,03:47:58
2,2,Team 2,Open 50+,Bartosz Thomson,00:43:52,00:43:52,John Smith & Zuzanna Miller-Ford,00:59:16,01:43:08,Leo McKenzie & Henry Muir,00:52:26,02:35:34,Regan Millar,01:12:48,03:48:22
3,3,Team 3,Open Senior,JackBruce,00:44:59,00:44:59,Martin King & Leland Donaldson,00:58:49,01:43:48,Neil MacDonald & Myles Christie,00:52:11,02:35:59,Hubert Gray,01:12:30,03:48:29
4,4,Team 4,Women 50+,Sofia O'Connor,00:45:35,00:45:35,Philip O’Donohue & Hasan Robertson,01:01:48,01:47:23,Lena K. Maclean & Isabel Ritchie,00:48:47,02:36:10,Martha Gibson,01:13:11,03:49:21
,5,Team 5,Open Senior,Clark O' Connor,00:45:43,00:45:43,Nina Joan Fiona Walker & Hope Christie,01:02:01,01:47:44,Cayla Duncan & Scott Kelly,00:49:35,02:37:19,Amelia Muir,DNF,DNF
4,4,Team ,Women 50+,Sofia O'Connor,00:45:35,00:45:35,Philip O’Donohue & Hasan Robertson,01:01:48,01:47:23,Lena K. Maclean & Isabel Ritchie,00:48:47,02:36:10,Martha Gibson,01:13:11,03:49:21
,5,Team 5,Open Senior,Clark O' Connor,00:45:43,00:45:43,Nina Joan Fiona Walker & Hope Christie,01:02:01,01:47:44,Cayla Duncan & Scott Kelly,00:49:35,02:37:19,Amèlia Muir,DNF,DNF
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
<td>Hailey Dickson:) & Alix Crawford</td>
<td>00:44:17</td>
<td>01:27:00</td>
<td>Rhys Müllar & Paige Thompson</td>
<td>Rhys M&uuml;llar & Paige Thompson</td>
<td>01:08:05</td>
<td>02:35:05</td>
<td>Amé MacDonald</td>
<td>Am&eacute; MacDonald</td>
<td>01:12:53</td>
<td>03:47:58</td>
</tr>
Expand Down Expand Up @@ -77,12 +77,12 @@
<tr>
<td>4</td>
<td>4</td>
<td>Team 4</td>
<td>Team 4&eacute;</td>
<td>Women 50+</td>
<td>Sofia O'Connor</td>
<td>00:45:35</td>
<td>00:45:35</td>
<td>Philip ODonohue & Hasan Robertson</td>
<td>Philip O&acute;Donohue & Hasan Robertson</td>
<td>01:01:48</td>
<td>01:47:23</td>
<td>Lena K. Maclean & Isabel Ritchie</td>
Expand All @@ -106,7 +106,7 @@
<td>Cayla Duncan & Scott Kelly</td>
<td>00:49:35</td>
<td>02:37:19</td>
<td>Amelia Muir</td>
<td>Am&egrave;lia Muir</td>
<td>DNF</td>
<td>DNF</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</tr>
<tr>
<td>4</td>
<td>Philip ODonohue & Hasan Robertson</td>
<td>Philip O&acute;Donohue & Hasan Robertson</td>
<td>01:01:48</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</tr>
<tr>
<td>5</td>
<td>Rhys Müllar & Paige Thompson</td>
<td>Rhys M&uuml;llar & Paige Thompson</td>
<td>01:08:05</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</tr>
<tr>
<td>3</td>
<td>Amé MacDonald</td>
<td>Am&eacute; MacDonald</td>
<td>01:12:53</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Pos,No,Team,Category,Total
1,1,Team 1,Women Senior,03:47:58
2,2,Team 2,Open 50+,03:48:22
3,3,Team 3,Open Senior,03:48:29
4,4,Team 4,Women 50+,03:49:21
4,4,Team ,Women 50+,03:49:21
,5,Team 5,Open Senior,DNF
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<tr>
<td>4</td>
<td>4</td>
<td>Team 4</td>
<td>Team 4&eacute;</td>
<td>Women 50+</td>
<td>03:49:21</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Devil's Burdens Results 2020
Category: Women Senior
----------------------

1: Team 4 (Women 50+) 03:49:21
1: Team (Women 50+) 03:49:21


Category: Open Senior
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1 Team 1 Women Senior John Smith Hailey Dickson:) & Alix Crawford Rhys Müllar & Paige Thompson Amé MacDonald
2 Team 2 Open 50+ Bartosz Thomson John Smith & Zuzanna Miller-Ford Leo McKenzie & Henry Muir Regan Millar
3 Team 3 Open Senior JackBruce Martin King & Leland Donaldson Neil MacDonald & Myles Christie Hubert Gray
4 Team 4 Women 50+ Sofia O'Connor Philip O’Donohue & Hasan Robertson Lena K. Maclean & Isabel Ritchie Martha Gibson
5 Team 5 Open Senior Clark O' Connor Nina Joan Fiona Walker & Hope Christie Cayla Duncan & Scott Kelly Amelia Muir
4 Team Women 50+ Sofia O'Connor Philip O’Donohue & Hasan Robertson Lena K. Maclean & Isabel Ritchie Martha Gibson
5 Team 5 Open Senior Clark O' Connor Nina Joan Fiona Walker & Hope Christie Cayla Duncan & Scott Kelly Amèlia Muir

0 comments on commit 4a5943a

Please sign in to comment.