|
@@ -10,35 +10,36 @@
|
|
|
#include <LibCore/DateTime.h>
|
|
|
#include <LibCore/Directory.h>
|
|
|
#include <LibCore/System.h>
|
|
|
-#include <LibWeb/Loader/FileDirectoryLoader.h>
|
|
|
+#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
-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;
|
|
|
}
|
|
|
|
|
|
-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;
|
|
|
}
|
|
|
|
|
|
-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;
|
|
|
}
|
|
|
|
|
|
-ErrorOr<DeprecatedString> load_file_directory_page(LoadRequest const& request)
|
|
|
+
|
|
|
+ErrorOr<String> load_file_directory_page(LoadRequest const& request)
|
|
|
{
|
|
|
// Generate HTML contents entries table
|
|
|
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
|
|
|
// 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_contents = TRY(template_file->read_until_eof());
|
|
|
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("contents", contents.to_deprecated_string());
|
|
|
generator.append(template_contents);
|
|
|
- return generator.as_string_view().to_deprecated_string();
|
|
|
+ return TRY(String::from_utf8(generator.as_string_view()));
|
|
|
}
|
|
|
|
|
|
}
|