1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

Ladybird+LibWeb: Add initial about:version internal page

This commit is contained in:
Bastiaan van der Plaat 2024-01-12 19:41:26 +01:00 committed by Tim Flynn
parent 05c0640474
commit cde14901bc
7 changed files with 100 additions and 1 deletions

View file

@ -12,6 +12,7 @@
#include <LibCore/Resource.h>
#include <LibCore/System.h>
#include <LibWeb/Loader/GeneratedPagesLoader.h>
#include <LibWeb/Loader/ResourceLoader.h>
namespace Web {
@ -68,4 +69,20 @@ ErrorOr<String> load_file_directory_page(AK::URL const& url)
return TRY(String::from_utf8(generator.as_string_view()));
}
ErrorOr<String> load_about_version_page()
{
// Generate HTML about version page from 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/version.html"sv));
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("browser_name", BROWSER_NAME);
generator.set("browser_version", BROWSER_VERSION);
generator.set("arch_name", CPU_STRING);
generator.set("os_name", OS_STRING);
generator.set("user_agent", default_user_agent);
generator.append(template_file->data());
return TRY(String::from_utf8(generator.as_string_view()));
}
}