mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
Ladybird+LibWeb: Rename FileDirectoryLoader to GeneratedPagesLoader
This commit is contained in:
parent
6f8ceb49c2
commit
8f2319e966
8 changed files with 41 additions and 38 deletions
|
@ -21,7 +21,7 @@
|
||||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/Loader/ContentFilter.h>
|
#include <LibWeb/Loader/ContentFilter.h>
|
||||||
#include <LibWeb/Loader/FileDirectoryLoader.h>
|
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
||||||
#include <LibWeb/Platform/AudioCodecPluginAgnostic.h>
|
#include <LibWeb/Platform/AudioCodecPluginAgnostic.h>
|
||||||
|
@ -70,8 +70,8 @@ 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_resource_directory_url(DeprecatedString::formatted("file://{}/res", s_serenity_resource_root));
|
Web::set_resource_directory_url(TRY(String::formatted("file://{}/res", s_serenity_resource_root)));
|
||||||
Web::set_directory_page_url(DeprecatedString::formatted("file://{}/res/html/directory.html", s_serenity_resource_root));
|
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/html/directory.html", s_serenity_resource_root)));
|
||||||
|
|
||||||
TRY(Web::Bindings::initialize_main_thread_vm());
|
TRY(Web::Bindings::initialize_main_thread_vm());
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/Loader/ContentFilter.h>
|
#include <LibWeb/Loader/ContentFilter.h>
|
||||||
#include <LibWeb/Loader/FileDirectoryLoader.h>
|
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
||||||
#include <LibWeb/Platform/AudioCodecPluginAgnostic.h>
|
#include <LibWeb/Platform/AudioCodecPluginAgnostic.h>
|
||||||
|
@ -96,8 +96,8 @@ 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_resource_directory_url(DeprecatedString::formatted("file://{}/res", s_serenity_resource_root));
|
Web::set_resource_directory_url(TRY(String::formatted("file://{}/res", s_serenity_resource_root)));
|
||||||
Web::set_directory_page_url(DeprecatedString::formatted("file://{}/res/html/directory.html", s_serenity_resource_root));
|
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/html/directory.html", s_serenity_resource_root)));
|
||||||
|
|
||||||
TRY(Web::Bindings::initialize_main_thread_vm());
|
TRY(Web::Bindings::initialize_main_thread_vm());
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ source_set("Loader") {
|
||||||
deps = [ "//Userland/Libraries/LibWeb:all_generated" ]
|
deps = [ "//Userland/Libraries/LibWeb:all_generated" ]
|
||||||
sources = [
|
sources = [
|
||||||
"ContentFilter.cpp",
|
"ContentFilter.cpp",
|
||||||
"FileDirectoryLoader.cpp",
|
|
||||||
"FileRequest.cpp",
|
"FileRequest.cpp",
|
||||||
|
"GeneratedPagesLoader.cpp",
|
||||||
"LoadRequest.cpp",
|
"LoadRequest.cpp",
|
||||||
"ProxyMappings.cpp",
|
"ProxyMappings.cpp",
|
||||||
"Resource.cpp",
|
"Resource.cpp",
|
||||||
|
|
|
@ -450,8 +450,8 @@ set(SOURCES
|
||||||
Layout/TreeBuilder.cpp
|
Layout/TreeBuilder.cpp
|
||||||
Layout/VideoBox.cpp
|
Layout/VideoBox.cpp
|
||||||
Loader/ContentFilter.cpp
|
Loader/ContentFilter.cpp
|
||||||
Loader/FileDirectoryLoader.cpp
|
|
||||||
Loader/FileRequest.cpp
|
Loader/FileRequest.cpp
|
||||||
|
Loader/GeneratedPagesLoader.cpp
|
||||||
Loader/LoadRequest.cpp
|
Loader/LoadRequest.cpp
|
||||||
Loader/ProxyMappings.cpp
|
Loader/ProxyMappings.cpp
|
||||||
Loader/Resource.cpp
|
Loader/Resource.cpp
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <LibWeb/Loader/Resource.h>
|
|
||||||
|
|
||||||
namespace Web {
|
|
||||||
|
|
||||||
ErrorOr<DeprecatedString> load_file_directory_page(LoadRequest const&);
|
|
||||||
DeprecatedString resource_directory_url();
|
|
||||||
void set_resource_directory_url(DeprecatedString);
|
|
||||||
DeprecatedString directory_page_url();
|
|
||||||
void set_directory_page_url(DeprecatedString);
|
|
||||||
|
|
||||||
}
|
|
|
@ -10,35 +10,36 @@
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
#include <LibCore/Directory.h>
|
#include <LibCore/Directory.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibWeb/Loader/FileDirectoryLoader.h>
|
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
static DeprecatedString s_resource_directory_url = "file:///res";
|
static String s_resource_directory_url = "file:///res"_string;
|
||||||
|
|
||||||
DeprecatedString resource_directory_url()
|
String resource_directory_url()
|
||||||
{
|
{
|
||||||
return s_resource_directory_url;
|
return s_resource_directory_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_resource_directory_url(DeprecatedString resource_directory_url)
|
void set_resource_directory_url(String resource_directory_url)
|
||||||
{
|
{
|
||||||
s_resource_directory_url = resource_directory_url;
|
s_resource_directory_url = resource_directory_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DeprecatedString s_directory_page_url = "file:///res/html/directory.html";
|
static String s_directory_page_url = "file:///res/html/directory.html"_string;
|
||||||
|
|
||||||
DeprecatedString directory_page_url()
|
String directory_page_url()
|
||||||
{
|
{
|
||||||
return s_directory_page_url;
|
return s_directory_page_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_directory_page_url(DeprecatedString directory_page_url)
|
void set_directory_page_url(String directory_page_url)
|
||||||
{
|
{
|
||||||
s_directory_page_url = directory_page_url;
|
s_directory_page_url = directory_page_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<DeprecatedString> load_file_directory_page(LoadRequest const& request)
|
|
||||||
|
ErrorOr<String> load_file_directory_page(LoadRequest const& request)
|
||||||
{
|
{
|
||||||
// Generate HTML contents entries table
|
// Generate HTML contents entries table
|
||||||
auto lexical_path = LexicalPath(request.url().serialize_path());
|
auto lexical_path = LexicalPath(request.url().serialize_path());
|
||||||
|
@ -69,7 +70,7 @@ ErrorOr<DeprecatedString> load_file_directory_page(LoadRequest const& request)
|
||||||
|
|
||||||
// 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()).serialize_path();
|
auto template_path = AK::URL::create_with_url_or_path(directory_page_url().to_deprecated_string()).serialize_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;
|
||||||
|
@ -79,7 +80,7 @@ ErrorOr<DeprecatedString> load_file_directory_page(LoadRequest const& request)
|
||||||
generator.set("parent_path", escape_html_entities(lexical_path.parent().string()));
|
generator.set("parent_path", escape_html_entities(lexical_path.parent().string()));
|
||||||
generator.set("contents", contents.to_deprecated_string());
|
generator.set("contents", contents.to_deprecated_string());
|
||||||
generator.append(template_contents);
|
generator.append(template_contents);
|
||||||
return generator.as_string_view().to_deprecated_string();
|
return TRY(String::from_utf8(generator.as_string_view()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
21
Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.h
Normal file
21
Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Loader/Resource.h>
|
||||||
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
||||||
|
|
||||||
|
namespace Web {
|
||||||
|
|
||||||
|
String resource_directory_url();
|
||||||
|
void set_resource_directory_url(String);
|
||||||
|
String directory_page_url();
|
||||||
|
void set_directory_page_url(String);
|
||||||
|
|
||||||
|
ErrorOr<String> load_file_directory_page(LoadRequest const&);
|
||||||
|
|
||||||
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
#include <LibWeb/Cookie/Cookie.h>
|
#include <LibWeb/Cookie/Cookie.h>
|
||||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||||
#include <LibWeb/Loader/ContentFilter.h>
|
#include <LibWeb/Loader/ContentFilter.h>
|
||||||
#include <LibWeb/Loader/FileDirectoryLoader.h>
|
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
||||||
#include <LibWeb/Loader/LoadRequest.h>
|
#include <LibWeb/Loader/LoadRequest.h>
|
||||||
#include <LibWeb/Loader/ProxyMappings.h>
|
#include <LibWeb/Loader/ProxyMappings.h>
|
||||||
#include <LibWeb/Loader/Resource.h>
|
#include <LibWeb/Loader/Resource.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue