mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-23 02:55:15 +00:00
Ladybird: Move and format directory and error template files
This commit is contained in:
parent
2960bf4ec8
commit
e3ad75d073
|
@ -1,51 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Index of @path@</title>
|
||||
<style>
|
||||
header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
h1 {
|
||||
display: inline;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
a:focus, a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
table {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.folder, .file, .open-parent {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 5px;
|
||||
background-size: contain;
|
||||
}
|
||||
.folder {
|
||||
background-image: url('resource://icons/32x32/filetype-folder.png');
|
||||
}
|
||||
.file {
|
||||
background-image: url('resource://icons/32x32/filetype-unknown.png');
|
||||
}
|
||||
.open-parent {
|
||||
background-image: url('resource://icons/16x16/open-parent-directory.png');
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<span class="folder" style="width: 24px; height: 24px;"></span>
|
||||
<h1>Index of @path@</h1>
|
||||
</header>
|
||||
<p><a href="@parent_url@"><span class="open-parent"></span>Open Parent Directory</a></p>
|
||||
<hr>
|
||||
@contents@
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
|
@ -1,23 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Error!</title>
|
||||
<style>
|
||||
h1 {
|
||||
display: inline;
|
||||
}
|
||||
header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
img {
|
||||
margin-right: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<img src="resource://icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24">
|
||||
<h1>Failed to load @failed_url@</h1>
|
||||
</header>
|
||||
</body>
|
||||
</html>
|
61
Base/res/ladybird/templates/directory.html
Normal file
61
Base/res/ladybird/templates/directory.html
Normal file
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Index of @path@</title>
|
||||
<style>
|
||||
header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:focus,
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
table {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.folder,
|
||||
.file,
|
||||
.open-parent {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 5px;
|
||||
background-size: contain;
|
||||
}
|
||||
|
||||
.folder {
|
||||
background-image: url('resource://icons/32x32/filetype-folder.png');
|
||||
}
|
||||
|
||||
.file {
|
||||
background-image: url('resource://icons/32x32/filetype-unknown.png');
|
||||
}
|
||||
|
||||
.open-parent {
|
||||
background-image: url('resource://icons/16x16/open-parent-directory.png');
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<span class="folder" style="width: 24px; height: 24px;"></span>
|
||||
<h1>Index of @path@</h1>
|
||||
</header>
|
||||
<p><a href="@parent_url@"><span class="open-parent"></span>Open Parent Directory</a></p>
|
||||
<hr>
|
||||
@contents@
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
26
Base/res/ladybird/templates/error.html
Normal file
26
Base/res/ladybird/templates/error.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Error!</title>
|
||||
<style>
|
||||
h1 {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
img {
|
||||
margin-right: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<img src="resource://icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24">
|
||||
<h1>Failed to load @failed_url@</h1>
|
||||
</header>
|
||||
</body>
|
||||
</html>
|
|
@ -294,11 +294,11 @@ if (current_os == "mac") {
|
|||
|
||||
bundle_data("ladybird_web_resources") {
|
||||
sources = [
|
||||
"//Base/res/ladybird/directory.html",
|
||||
"//Base/res/ladybird/error.html",
|
||||
"//Base/res/ladybird/inspector.css",
|
||||
"//Base/res/ladybird/inspector.js",
|
||||
"//Base/res/ladybird/new-tab.html",
|
||||
"//Base/res/ladybird/templates/directory.html",
|
||||
"//Base/res/ladybird/templates/error.html",
|
||||
]
|
||||
outputs = [ "{{bundle_resources_dir}}/res/ladybird/{{source_file_part}}" ]
|
||||
}
|
||||
|
|
|
@ -19,13 +19,11 @@ ErrorOr<String> load_error_page(AK::URL const& url)
|
|||
{
|
||||
// Generate HTML error page from error template file
|
||||
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time)
|
||||
auto template_path = TRY(Core::Resource::load_from_uri("resource://ladybird/error.html"sv))->filesystem_path();
|
||||
auto template_file = TRY(Core::File::open(template_path, Core::File::OpenMode::Read));
|
||||
auto template_contents = TRY(template_file->read_until_eof());
|
||||
auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/error.html"sv));
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
generator.set("failed_url", url.to_byte_string());
|
||||
generator.append(template_contents);
|
||||
generator.append(template_file->data());
|
||||
return TRY(String::from_utf8(generator.as_string_view()));
|
||||
}
|
||||
|
||||
|
@ -60,15 +58,13 @@ ErrorOr<String> load_file_directory_page(AK::URL const& url)
|
|||
|
||||
// Generate HTML directory page from directory template file
|
||||
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time)
|
||||
auto template_path = TRY(Core::Resource::load_from_uri("resource://ladybird/directory.html"sv))->filesystem_path();
|
||||
auto template_file = TRY(Core::File::open(template_path, Core::File::OpenMode::Read));
|
||||
auto template_contents = TRY(template_file->read_until_eof());
|
||||
auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/directory.html"sv));
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
generator.set("path", escape_html_entities(lexical_path.string()));
|
||||
generator.set("parent_url", TRY(String::formatted("file://{}", escape_html_entities(lexical_path.parent().string()))));
|
||||
generator.set("contents", contents.to_byte_string());
|
||||
generator.append(template_contents);
|
||||
generator.append(template_file->data());
|
||||
return TRY(String::from_utf8(generator.as_string_view()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue