summaryrefslogtreecommitdiff
path: root/Services
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-27 19:40:34 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-27 19:57:20 +0200
commit5c7d54d50d2cfdc2bdacb45b26de42d26dbc8adf (patch)
treef7d1d115c20de81220f793811e74f040beaac169 /Services
parentefa117f8011306042871e4dd6d3d48b84fec824a (diff)
downloadserenity-5c7d54d50d2cfdc2bdacb45b26de42d26dbc8adf.zip
WebServer: Use table tags in directory listings
Use tables to align stuff instead of putting everything in a <pre>.
Diffstat (limited to 'Services')
-rw-r--r--Services/WebServer/Client.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/Services/WebServer/Client.cpp b/Services/WebServer/Client.cpp
index 22864f2379..37bafda560 100644
--- a/Services/WebServer/Client.cpp
+++ b/Services/WebServer/Client.cpp
@@ -167,18 +167,16 @@ void Client::handle_directory_listing(const String& requested_path, const String
builder.append(escape_html_entities(requested_path));
builder.append("</h1>\n");
builder.append("<hr>\n");
- builder.append("<pre>\n");
+ builder.append("<table>\n");
Core::DirIterator dt(real_path);
while (dt.has_next()) {
auto name = dt.next_path();
- builder.append("<a href=\"");
+ builder.append("<tr><td><a href=\"");
builder.append(urlencode(name));
builder.append("\">");
builder.append(escape_html_entities(name));
- builder.append("</a>");
- for (size_t i = 0; i < (40 - name.length()); ++i)
- builder.append(' ');
+ builder.append("</a></td>");
StringBuilder path_builder;
path_builder.append(real_path);
@@ -190,13 +188,14 @@ void Client::handle_directory_listing(const String& requested_path, const String
if (rc < 0) {
perror("stat");
}
- builder.appendf(" %10d", st.st_size);
- builder.appendf(" ");
+ builder.appendf("<td>%10d</td>", st.st_size);
+ builder.append("<td>");
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string());
- builder.append("\n");
+ builder.append("</td>");
+ builder.append("</tr>\n");
}
- builder.append("</pre>\n");
+ builder.append("</table>\n");
builder.append("<hr>\n");
builder.append("<i>Generated by WebServer (SerenityOS)</i>\n");
builder.append("</body>\n");