mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:05:06 +00:00
LibWeb: Use resources to find internal HTML template paths
This commit is contained in:
parent
f8feca5d21
commit
009729d5e3
5 changed files with 3 additions and 40 deletions
|
@ -72,9 +72,6 @@ ErrorOr<int> service_main(int ipc_socket, int fd_passing_socket)
|
||||||
Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode);
|
Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode);
|
||||||
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
|
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
|
||||||
|
|
||||||
Web::set_error_page_url(TRY(String::formatted("file://{}/res/ladybird/error.html", s_serenity_resource_root)));
|
|
||||||
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/ladybird/directory.html", s_serenity_resource_root)));
|
|
||||||
|
|
||||||
TRY(Web::Bindings::initialize_main_thread_vm());
|
TRY(Web::Bindings::initialize_main_thread_vm());
|
||||||
|
|
||||||
auto maybe_content_filter_error = load_content_filters();
|
auto maybe_content_filter_error = load_content_filters();
|
||||||
|
|
|
@ -115,9 +115,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
|
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
|
||||||
|
|
||||||
Web::set_error_page_url(TRY(String::formatted("file://{}/res/ladybird/error.html", s_serenity_resource_root)));
|
|
||||||
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/ladybird/directory.html", s_serenity_resource_root)));
|
|
||||||
|
|
||||||
TRY(Web::Bindings::initialize_main_thread_vm());
|
TRY(Web::Bindings::initialize_main_thread_vm());
|
||||||
|
|
||||||
auto maybe_content_filter_error = load_content_filters();
|
auto maybe_content_filter_error = load_content_filters();
|
||||||
|
|
|
@ -49,9 +49,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
VERIFY(fd_passing_socket >= 0);
|
VERIFY(fd_passing_socket >= 0);
|
||||||
|
|
||||||
Web::set_error_page_url(TRY(String::formatted("file://{}/res/ladybird/error.html", s_serenity_resource_root)));
|
|
||||||
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/ladybird/directory.html", s_serenity_resource_root)));
|
|
||||||
|
|
||||||
TRY(Web::Bindings::initialize_main_thread_vm());
|
TRY(Web::Bindings::initialize_main_thread_vm());
|
||||||
|
|
||||||
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebWorker::ConnectionFromClient>());
|
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebWorker::ConnectionFromClient>());
|
||||||
|
|
|
@ -9,40 +9,17 @@
|
||||||
#include <AK/SourceGenerator.h>
|
#include <AK/SourceGenerator.h>
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
#include <LibCore/Directory.h>
|
#include <LibCore/Directory.h>
|
||||||
|
#include <LibCore/Resource.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
static String s_error_page_url = "file:///res/ladybird/error.html"_string;
|
|
||||||
|
|
||||||
String error_page_url()
|
|
||||||
{
|
|
||||||
return s_error_page_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_error_page_url(String error_page_url)
|
|
||||||
{
|
|
||||||
s_error_page_url = error_page_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String s_directory_page_url = "file:///res/ladybird/directory.html"_string;
|
|
||||||
|
|
||||||
String directory_page_url()
|
|
||||||
{
|
|
||||||
return s_directory_page_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_directory_page_url(String directory_page_url)
|
|
||||||
{
|
|
||||||
s_directory_page_url = directory_page_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<String> load_error_page(AK::URL const& url)
|
ErrorOr<String> load_error_page(AK::URL const& url)
|
||||||
{
|
{
|
||||||
// Generate HTML error page from error template file
|
// 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)
|
// 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 = AK::URL::create_with_url_or_path(error_page_url().to_byte_string()).serialize_path();
|
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_file = TRY(Core::File::open(template_path, Core::File::OpenMode::Read));
|
||||||
auto template_contents = TRY(template_file->read_until_eof());
|
auto template_contents = TRY(template_file->read_until_eof());
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
@ -83,7 +60,7 @@ ErrorOr<String> load_file_directory_page(AK::URL const& url)
|
||||||
|
|
||||||
// Generate HTML directory page from directory template file
|
// 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)
|
// 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 = AK::URL::create_with_url_or_path(directory_page_url().to_byte_string()).serialize_path();
|
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_file = TRY(Core::File::open(template_path, Core::File::OpenMode::Read));
|
||||||
auto template_contents = TRY(template_file->read_until_eof());
|
auto template_contents = TRY(template_file->read_until_eof());
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
String error_page_url();
|
|
||||||
void set_error_page_url(String);
|
|
||||||
String directory_page_url();
|
|
||||||
void set_directory_page_url(String);
|
|
||||||
|
|
||||||
ErrorOr<String> load_error_page(AK::URL const&);
|
ErrorOr<String> load_error_page(AK::URL const&);
|
||||||
|
|
||||||
ErrorOr<String> load_file_directory_page(AK::URL const&);
|
ErrorOr<String> load_file_directory_page(AK::URL const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue