Files
servo/components/default-resources/resources/directory-listing.html
Jonathan Schwender f4877c190e Embed default resources in Servo applications using a servo-default-resources crate (#43182)
This PR considers the following constraints:

- Resources must be available when building servo via a published
crates.io package (i.e. no `../../../resources/<file>` file references).
- Minimal setup when writing tests (`nextest` spawns each test in its
own process, so we don't want to explicitly initialize the resource
handler for every `#[test]` fn)
- Use local resources when developing locally
- Support loading the resources from a proper resource directory if the
embedder wishes so, including via a custom mechanism, not necessarily as
files

(File) Resources that are only accessed from servoshell are out of scope
of this PR, since it mainly focusses on unblocking publishing `libservo`
to crates.io.

Baking the resources into the binary by default simplifies the setup a
lot. We already supported that before, but only for testing purposes and
explicitly not for production builds.

Using [`inventory`](https://crates.io/crates/inventory) adds a simple
way for the embedder to replace the default baked in resources, while
also keeping the test usage of baked in resources simple.

rippy.png is also referenced from image_cache - We simply duplicate it,
since the image is small, to avoid adding unnecessarily complex
solutions like adding a dedicated crate.


Testing: Covered by existing tests. [mach try
full](https://github.com/jschwe/servo/actions/runs/23811669469)
Fixes: Part of #43145

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-04-01 07:16:28 +00:00

104 lines
3.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Index of</title>
<style>
h1 {
border-bottom: 1px solid black;
}
.listing {
margin: 0.5em;
display: table;
}
.listing .header,
.listing .entry {
display: table-row;
}
.listing .header {
font-weight: bold;
}
.listing .header span,
.listing .entry span {
display: table-cell;
padding-right: 1em;
}
.entry span:nth-child(1) {
min-width: 20em;
}
.entry span.size,
.entry span.last-modified {
white-space: nowrap;
}
.parent_link > a:before {
content: "📁 ";
}
.parent_link {
display: none;
}
.entry.directory > .name:before {
content: "📁 ";
}
.entry.file > .name:before {
content: "📄 ";
}
.entry.symlink > .name:before {
content: "🔗 ";
}
</style>
<script>
function setData(directoryName, parentLink, rows) {
document.title += " " + directoryName;
document.querySelector("h1").innerHTML += " " + directoryName;
if (parentLink != "") {
document.querySelector(".parent_link > a").href = parentLink;
document.querySelector(".parent_link").style.display = "initial";
}
rows.sort((rowA, rowB) => rowA[1].localeCompare(rowB[1]));
let listing = document.querySelector(".listing");
let rowTemplate = document.getElementById("rowTemplate");
for (row of rows) {
let rowElement = rowTemplate.content.cloneNode(true);
rowElement.querySelector(".entry").classList.add(row[0]);
rowElement.querySelector(".name > .link").innerText = row[1];
rowElement.querySelector(".name > .link").href = row[2];
rowElement.querySelector(".size").innerText = row[3];
rowElement.querySelector(".last-modified").innerText = row[4];
listing.appendChild(rowElement);
}
}
</script>
</head>
<body>
<h1>Index of</h1>
<div class="parent_link"><a href="">Up to parent directory</a></div>
<div class="listing">
<div class="header">
<span class="name">Name</span>
<span class="size">Size</span>
<span class="last-modified">Last Modified</span>
</div>
</div>
<template id="rowTemplate">
<div class="entry">
<span class="name"><a class="link"></a></span>
<span class="size"></span>
<span class="last-modified"></span>
</div>
</template>
</body>
</html>