mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
Help: Use LibWeb to open files via RequestServer
This commit is contained in:
parent
662711fa26
commit
0c2dc6be66
2 changed files with 2 additions and 16 deletions
|
@ -267,22 +267,7 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
||||||
void MainWidget::open_url(URL const& url)
|
void MainWidget::open_url(URL const& url)
|
||||||
{
|
{
|
||||||
if (url.protocol() == "file") {
|
if (url.protocol() == "file") {
|
||||||
auto path = url.path();
|
m_web_view->load(url);
|
||||||
auto source_result = m_manual_model->page_view(path);
|
|
||||||
if (source_result.is_error()) {
|
|
||||||
GUI::MessageBox::show(window(), String::formatted("{}", source_result.error()), "Failed to open man page", GUI::MessageBox::Type::Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto source = source_result.value();
|
|
||||||
String html;
|
|
||||||
{
|
|
||||||
auto md_document = Markdown::Document::parse(source);
|
|
||||||
VERIFY(md_document);
|
|
||||||
html = md_document->render_to_html();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_web_view->load_html(html, url);
|
|
||||||
m_web_view->scroll_to_top();
|
m_web_view->scroll_to_top();
|
||||||
|
|
||||||
GUI::Application::the()->deferred_invoke([&, path = url.path()] {
|
GUI::Application::the()->deferred_invoke([&, path = url.path()] {
|
||||||
|
|
|
@ -33,6 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
TRY(Core::System::unveil("/res", "r"));
|
TRY(Core::System::unveil("/res", "r"));
|
||||||
TRY(Core::System::unveil("/usr/share/man", "r"));
|
TRY(Core::System::unveil("/usr/share/man", "r"));
|
||||||
|
TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw"));
|
||||||
TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
|
TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
|
||||||
TRY(Core::System::unveil("/tmp/portal/webcontent", "rw"));
|
TRY(Core::System::unveil("/tmp/portal/webcontent", "rw"));
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue