Skip to content

Commit 83b3860

Browse files
committed
improve file index design
1 parent e8e166d commit 83b3860

5 files changed

Lines changed: 124 additions & 79 deletions

File tree

backend/src/requests.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ impl RequestLogger {
130130
ratelimit = Some(RateLimitData {
131131
limit: if request.uri.path().contains("files") {
132132
30
133+
} else if organization.is_some() {
134+
240
133135
} else {
134-
if organization.is_some() { 240 } else { 120 }
136+
120
135137
},
136138
hits: count,
137139
});

backend/src/routes/index/_type_/_version_/_build_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn router(state: &State) -> OpenApiRouter<State> {
2323
InstallationStep::Download(step) => {
2424
files.push(IndexFile {
2525
name: step.file,
26-
size: format!("{} bytes", step.size),
26+
size: human_bytes::human_bytes(step.size as f64),
2727
href: Some(step.url),
2828
});
2929
}

backend/src/routes/index/_type_/_version_/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn router(state: &State) -> OpenApiRouter<State> {
2828
.rev()
2929
.map(|b| IndexFile {
3030
name: format!("{}/", b.name),
31-
size: format!("{} bytes", b.installation_size()),
31+
size: human_bytes::human_bytes(b.installation_size() as f64),
3232
href: Some(format!("{}/", b.id)),
3333
})
3434
.collect::<Vec<_>>();

backend/src/routes/index/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ pub fn render(state: GetState, location: &str, files: Vec<IndexFile>) -> Respons
2323
.into_iter()
2424
.map(|f| {
2525
let href = f.href.unwrap_or_else(|| f.name.clone());
26+
let element = if href == "#" { "span" } else { "a" };
2627

2728
format!(
2829
r#"
2930
<tr>
30-
<td><a href="{}">{}</a></td>
31+
<td>
32+
<span class="icon {}-icon"></span>
33+
<{element} href="{}">{}</{element}>
34+
</td>
3135
<td class="size">{}</td>
3236
</tr>
3337
"#,
38+
if href.ends_with("/") {
39+
"folder"
40+
} else {
41+
"file"
42+
},
3443
if href.starts_with("https") {
3544
href
3645
} else {

backend/static/index.html

Lines changed: 109 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,111 @@
1-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2-
<html>
3-
<head>
4-
<title>Index of {{LOCATION}}</title>
5-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6-
<style type="text/css">
7-
body {
8-
font-family: monospace;
9-
background-color: #FFFFFF;
10-
color: #000000;
11-
margin: 8px;
12-
}
13-
h1 {
14-
font-size: 18px;
15-
font-weight: bold;
16-
}
17-
pre {
18-
margin: 0;
19-
font-family: monospace;
20-
}
21-
table {
22-
border: 0;
23-
width: 100%;
24-
}
25-
td {
26-
padding: 1px 0;
27-
font-size: 14px;
28-
white-space: nowrap;
29-
}
30-
a {
31-
color: #0000FF;
32-
text-decoration: none;
33-
}
34-
a:visited {
35-
color: #800080;
36-
}
37-
a:hover {
38-
text-decoration: underline;
39-
}
40-
.size {
41-
text-align: right;
42-
}
43-
hr {
44-
height: 1px;
45-
color: #CCCCCC;
46-
background-color: #CCCCCC;
47-
border: none;
48-
}
49-
address {
50-
font-style: italic;
51-
font-size: 12px;
52-
margin-top: 10px;
53-
}
54-
</style>
55-
</head>
56-
<body>
57-
<h1>Index of {{LOCATION}}</h1>
58-
<hr>
59-
<table>
60-
<tr>
61-
<th style="text-align: left;">Name</th>
62-
<th style="text-align: right;">Size</th>
63-
</tr>
64-
</table>
65-
<hr>
66-
<table cellspacing="0">
67-
<tr>
68-
<td><a href="../">[Parent Directory]</a></td>
69-
<td class="size">-</td>
70-
</tr>
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<html lang="en">
3+
<head>
4+
<title>Index of {{LOCATION}}</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<style type="text/css">
8+
body {
9+
font-family: monospace;
10+
background-color: #ffffff;
11+
color: #000000;
12+
margin: 8px;
13+
}
14+
h1 {
15+
font-size: 18px;
16+
font-weight: bold;
17+
}
18+
pre {
19+
margin: 0;
20+
font-family: monospace;
21+
}
22+
table {
23+
border: 0;
24+
width: auto;
25+
min-width: 50%;
26+
max-width: 800px;
27+
table-layout: fixed;
28+
}
29+
th,
30+
td {
31+
padding: 4px 8px;
32+
font-size: 14px;
33+
white-space: nowrap;
34+
overflow: hidden;
35+
text-overflow: ellipsis;
36+
}
37+
th {
38+
text-align: left;
39+
}
40+
tr:hover {
41+
background-color: #f0f0f0;
42+
}
43+
a {
44+
color: #0000ff;
45+
text-decoration: none;
46+
}
47+
a:visited {
48+
color: #800080;
49+
}
50+
a:hover {
51+
text-decoration: underline;
52+
}
53+
.size {
54+
text-align: right;
55+
width: 100px;
56+
padding-left: 20px;
57+
}
58+
hr {
59+
height: 1px;
60+
color: #cccccc;
61+
background-color: #cccccc;
62+
border: none;
63+
max-width: 800px;
64+
margin-left: 0;
65+
}
66+
address {
67+
font-style: italic;
68+
font-size: 12px;
69+
margin-top: 10px;
70+
}
71+
.parent-dir {
72+
font-weight: bold;
73+
}
7174

72-
<!-- ENTRIES -->
73-
</table>
74-
<hr>
75-
<address>MCJars/{{VERSION}} Server</address>
76-
</body>
75+
.icon {
76+
display: inline-block;
77+
width: 16px;
78+
height: 16px;
79+
margin-right: 5px;
80+
vertical-align: middle;
81+
}
82+
.folder-icon {
83+
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABgUlEQVR4AayQPUpDURCFZwLZg5Y2YpHCtwL7iC5DlNe4A12CoEGwcQtWwVJLK1MIkpdCO91ABIPJ+J25MSkV4uOee+b3zNzXshW//xN4ue6uNVfd7aZXMDzf2/rLcrlBc9k9+/rwN5v4o1mB++x52Ns/tV++FLCZ74QKXZeZyC3g6UnT243RxW6IhRF+g//EpsZXBCIwOQvCcDcXEUZJNwhkS7Adfk3AigDFZEyFbgYxH9HAgUjRZPoIkDUishRJAaXdo6SCNDCJqgKoGEkTcGEiHNkpIDsIhyJyxABNbgQzt0xEWStzKZCN6WJxcjisVnr5F+nk4rkFBXqeWlJAhuCqxshyjXccTinOKB6HDRxglZ+oOkEBTS22Zv1YYoGs1NhgPqsIEL5f6qtx7kFaJN/MAzRAveKZ2YM4n7BZ948nNl7/tHZl3q4mZpXN7fCoJi5fiCraUY1b042tun+4EJDRqe/eO/XNYBN06n6ybMQHxVcMHPQH1dHtq3qElq5V8A0AAP//4hBxdwAAAAZJREFUAwApsKAhTGjZfQAAAABJRU5ErkJggg==");
84+
}
85+
.file-icon {
86+
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABeUlEQVR4AaRSMVLDQAxc2Q2UPCAMT/HkPExKu+M34SmUdAlVCqLMPYEfkBk+QAeNLVZnbHIOVNycLN2edk/SuMA/15lACNUqhNBUoWoY0wf3q7/eyQRI/DCUO8A2JcoNaCVj+l1d1/e/iRQZaLgQswkaIkG36C5769f17blILiDkCj9G85DmIvEhfvaL68u+s/W8klyAhLSd70wehL7iTMq344rwnbESwtPOBJgLt/RxpqeR9T2HDfFHgAB+VibgV25DBx6BHNoAYOCmJzCuTICpaTt1nGUq5BQYVEY+ZgIpE072WY5Z4nUU8gTQBPSY1kyAuAi4nZKEIMTYgu61Ud037olMOxeY2rPEc6EpkwF/NFuGpbmvQ9gSmrWQGuYY+KJfpjI88Crc08SlzY571YbHXMCAd9IxvmwU9HkgXy0ENyEsXx3OWjjo4aqDtLxo0XVtj74VQYqJQVWFtlU9SFf0npdX4ElRlQm0GLdR4xT73anF5/ji5y8AAAD//9+HONgAAAAGSURBVAMAtAiaIe2mkdUAAAAASUVORK5CYII=");
87+
}
88+
</style>
89+
</head>
90+
<body>
91+
<h1>Index of {{LOCATION}}</h1>
92+
<hr />
93+
<table cellspacing="0">
94+
<tr>
95+
<th>Name</th>
96+
<th class="size">Size</th>
97+
</tr>
98+
<tr>
99+
<td>
100+
<span class="icon folder-icon"></span>
101+
<a href="../" class="parent-dir">[Parent Directory]</a>
102+
</td>
103+
<td class="size">-</td>
104+
</tr>
105+
106+
<!-- ENTRIES -->
107+
</table>
108+
<hr />
109+
<address>MCJars/{{VERSION}} Server</address>
110+
</body>
77111
</html>

0 commit comments

Comments
 (0)