Base: Use % for keys in templates

The previous character used, @, conflicted with CSS. % is used by other
templating engines, and doesn't conflict with language features (e.g.
media queries).
This commit is contained in:
Jamie Mansfield 2024-07-07 20:08:09 +01:00 committed by Andreas Kling
parent 634f2f655b
commit 27f3305b87
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00
4 changed files with 17 additions and 17 deletions

View file

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Index of @path@</title> <title>Index of %path%</title>
<style> <style>
header { header {
margin-bottom: 10px; margin-bottom: 10px;
@ -51,11 +51,11 @@
<body> <body>
<header> <header>
<span class="folder" style="width: 24px; height: 24px;"></span> <span class="folder" style="width: 24px; height: 24px;"></span>
<h1>Index of @path@</h1> <h1>Index of %path%</h1>
</header> </header>
<p><a href="@parent_url@"><span class="open-parent"></span>Open Parent Directory</a></p> <p><a href="%parent_url%"><span class="open-parent"></span>Open Parent Directory</a></p>
<hr> <hr>
@contents@ %contents%
<hr> <hr>
</body> </body>
</html> </html>

View file

@ -20,8 +20,8 @@
<body> <body>
<header> <header>
<img src="resource://icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24"> <img src="resource://icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24">
<h1>Failed to load @failed_url@</h1> <h1>Failed to load %failed_url%</h1>
</header> </header>
<p>@error_message@</p> <p>%error_message%</p>
</body> </body>
</html> </html>

View file

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>About @browser_name@</title> <title>About %browser_name%</title>
<style> <style>
img { img {
float: left; float: left;
@ -20,32 +20,32 @@
<body> <body>
<header> <header>
<img src="resource://icons/128x128/app-browser.png"> <img src="resource://icons/128x128/app-browser.png">
<h1>About @browser_name@</h1> <h1>About %browser_name%</h1>
</header> </header>
<table> <table>
<tr> <tr>
<th>Version:</th> <th>Version:</th>
<td>@browser_version@</td> <td>%browser_version%</td>
</tr> </tr>
<tr> <tr>
<th>Arch:</th> <th>Arch:</th>
<td>@arch_name@</td> <td>%arch_name%</td>
</tr> </tr>
<tr> <tr>
<th>Operating System:</th> <th>Operating System:</th>
<td>@os_name@</td> <td>%os_name%</td>
</tr> </tr>
<tr> <tr>
<th>User Agent:</th> <th>User Agent:</th>
<td>@user_agent@</td> <td>%user_agent%</td>
</tr> </tr>
<tr> <tr>
<th>Command Line:</th> <th>Command Line:</th>
<td>@command_line@</td> <td>%command_line%</td>
</tr> </tr>
<tr> <tr>
<th>Executable Path:</th> <th>Executable Path:</th>
<td>@executable_path@</td> <td>%executable_path%</td>
</tr> </tr>
</table> </table>
</body> </body>

View file

@ -32,7 +32,7 @@ ErrorOr<String> load_error_page(URL::URL const& url, StringView error_message)
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time) // 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/error.html"sv)); auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/error.html"sv));
StringBuilder builder; StringBuilder builder;
SourceGenerator generator { builder }; SourceGenerator generator { builder, '%', '%' };
generator.set("failed_url", url.to_byte_string()); generator.set("failed_url", url.to_byte_string());
generator.set("error_message", escape_html_entities(error_message)); generator.set("error_message", escape_html_entities(error_message));
generator.append(template_file->data()); generator.append(template_file->data());
@ -72,7 +72,7 @@ ErrorOr<String> load_file_directory_page(URL::URL const& url)
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time) // 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/directory.html"sv)); auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/directory.html"sv));
StringBuilder builder; StringBuilder builder;
SourceGenerator generator { builder }; SourceGenerator generator { builder, '%', '%' };
generator.set("path", escape_html_entities(lexical_path.string())); 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("parent_url", TRY(String::formatted("file://{}", escape_html_entities(lexical_path.parent().string()))));
generator.set("contents", contents.to_byte_string()); generator.set("contents", contents.to_byte_string());
@ -86,7 +86,7 @@ ErrorOr<String> load_about_version_page()
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time) // 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/version.html"sv)); auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/version.html"sv));
StringBuilder builder; StringBuilder builder;
SourceGenerator generator { builder }; SourceGenerator generator { builder, '%', '%' };
generator.set("browser_name", BROWSER_NAME); generator.set("browser_name", BROWSER_NAME);
generator.set("browser_version", BROWSER_VERSION); generator.set("browser_version", BROWSER_VERSION);
generator.set("arch_name", CPU_STRING); generator.set("arch_name", CPU_STRING);