Help: Replace file:// URLs with launch:// URLs

LibWeb already thinks it knows how to handle `file://` URLs, so does not
call into the client to handle the URL scheme. Replacing these with
`launch://` means LibWeb will call into `handle_custom_scheme`, which
allows the Help app to process these requests.
This commit is contained in:
MacDue
2025-03-29 19:39:19 +00:00
committed by Nico Weber
parent b2153a9538
commit b222f411d6
43 changed files with 48 additions and 45 deletions

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-3d-file-viewer.png) 3D File Viewer
[Open](file:///bin/3DFileViewer)
[Open](launch:///bin/3DFileViewer)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/ladyball.png) About - About SerenityOS
[Open](file:///bin/About)
[Open](launch:///bin/About)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-analog-clock.png) Analog Clock
[Open](file:///bin/AnalogClock)
[Open](launch:///bin/AnalogClock)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-assistant.png) Assistant - Serenity Assistant
[Open](file:///bin/Assistant)
[Open](launch:///bin/Assistant)
## Synopsis
@@ -18,5 +18,5 @@ $ Assistant
- Enter a URL to open it in [Browser](help://man/1/Applications/Browser), e.g. `serenityos.org`.
- Perform quick calculations by typing the equal sign (=) followed by a mathematical expression, e.g. `=22*101`. Press `Return` to copy the result.
- Run commands in [Terminal](help://man/1/Applications/Terminal) by prefixing them with a dollar sign ($), e.g. `$ uname -a`.
- Run commands in [Terminal](help://man/1/Applications/Terminal) by prefixing them with a dollar sign (\$), e.g. `$ uname -a`.
- Launch applications with arguments, e.g. launch [Pixel Paint](help://man/1/Applications/PixelPaint) with a file: `pp image.png`.

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-browser.png) Browser - Serenity WWW Browser
[Open](file:///bin/Browser)
[Open](launch:///bin/Browser)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-calculator.png) Calculator - Serenity calculator
[Open](file:///bin/Calculator)
[Open](launch:///bin/Calculator)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-calendar.png) Calendar - Serenity calendar
[Open](file:///bin/Calendar)
[Open](launch:///bin/Calendar)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-catdog.png) CatDog - A helpful companion
[Open](file:///bin/CatDog)
[Open](launch:///bin/CatDog)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/certificate.png) Certificate Settings
[Open](file:///bin/CertificateSettings)
[Open](launch:///bin/CertificateSettings)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-character-map.png) Character Map - Unicode character viewer
[Open](file:///bin/CharacterMap)
[Open](launch:///bin/CharacterMap)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-crash-reporter.png) CrashReporter - information about crashed programs
[Open](file:///bin/CrashReporter)
[Open](launch:///bin/CrashReporter)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-eyes.png) Eyes - follow the mouse LibGUI demo
[Open](file:///bin/Eyes)
[Open](launch:///bin/Eyes)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-font-editor.png) FontEditor - Serenity font editor
[Open](file:///bin/FontEditor)
[Open](launch:///bin/FontEditor)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-gml-playground.png) GML Playground - GUI Markup Language (GML) editor
[Open](file:///bin/GMLPlayground)
[Open](launch:///bin/GMLPlayground)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-help.png) Help - digital manual
[Open](file:///bin/Help)
[Open](launch:///bin/Help)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/hex.png) Hex Editor - Binary file editor
[Open](file:///bin/HexEditor)
[Open](launch:///bin/HexEditor)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-image-viewer.png) Image Viewer - SerenityOS image viewer
[Open](file:///bin/ImageViewer)
[Open](launch:///bin/ImageViewer)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-magnifier.png) Magnifier - Magnifier application
[Open](file:///bin/Magnifier)
[Open](launch:///bin/Magnifier)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-mail.png) Mail - Serenity e-mail client
[Open](file:///bin/Mail)
[Open](launch:///bin/Mail)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-maps.png) Maps
[Open](file:///bin/Maps)
[Open](launch:///bin/Maps)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-mouse.png) Mouse Settings - Mouse settings application
[Open](file:///bin/MouseSettings)
[Open](launch:///bin/MouseSettings)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-pixel-paint.png) Pixel Paint - Image Editor
[Open](file:///bin/PixelPaint)
[Open](launch:///bin/PixelPaint)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-presenter.png) Presenter - Present slides to an audience
[Open](file:///bin/Presenter)
[Open](launch:///bin/Presenter)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-profiler.png) Profiler - Serenity process profiler
[Open](file:///bin/Profiler)
[Open](launch:///bin/Profiler)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-sql-studio.png) SQL Studio - SerenityOS SQL Manager
[Open](file:///bin/SQLStudio)
[Open](launch:///bin/SQLStudio)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-screenshot.png) Screenshot
[Open](file:///bin/Screenshot)
[Open](launch:///bin/Screenshot)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-terminal.png) Terminal - Serenity terminal emulator
[Open](file:///bin/Terminal)
[Open](launch:///bin/Terminal)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-text-editor.png) TextEditor - SerenityOS text editor
[Open](file:///bin/TextEditor)
[Open](launch:///bin/TextEditor)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-2048.png) 2048
[Open](file:///bin/2048)
[Open](launch:///bin/2048)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-brickgame.png) BrickGame
[Open](file:///bin/BrickGame)
[Open](launch:///bin/BrickGame)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-chess.png) Chess
[Open](file:///bin/Chess)
[Open](launch:///bin/Chess)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-colorlines.png) Color Lines
[Open](file:///bin/ColorLines)
[Open](launch:///bin/ColorLines)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-flappybug.png) Flappy Bug
[Open](file:///bin/FlappyBug)
[Open](launch:///bin/FlappyBug)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-flood.png) Flood
[Open](file:///bin/Flood)
[Open](launch:///bin/Flood)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-gameoflife.png) GameOfLife
[Open](file:///bin/GameOfLife)
[Open](launch:///bin/GameOfLife)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-hearts.png) Hearts - The Hearts card game
[Open](file:///bin/Hearts)
[Open](launch:///bin/Hearts)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-masterword.png) MasterWord
[Open](file:///bin/MasterWord)
[Open](launch:///bin/MasterWord)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-minesweeper.png) Minesweeper
[Open](file:///bin/Minesweeper)
[Open](launch:///bin/Minesweeper)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-snake.png) Snake
[Open](file:///bin/Snake)
[Open](launch:///bin/Snake)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-solitaire.png) Solitaire - The Solitaire card game
[Open](file:///bin/Solitaire)
[Open](launch:///bin/Solitaire)
## Synopsis

View File

@@ -2,7 +2,7 @@
![Icon](/res/icons/16x16/app-spider.png) Spider - The Spider card game
[Open](file:///bin/Spider)
[Open](launch:///bin/Spider)
## Synopsis

View File

@@ -118,8 +118,11 @@ ErrorOr<void> MainWidget::initialize(GUI::Window& window)
m_web_view = find_descendant_of_type_named<WebView::OutOfProcessWebView>("web_view");
m_web_view->use_native_user_style_sheet();
m_web_view->handle_custom_scheme = [this](auto& url) {
if (url.scheme() == "file") {
m_web_view->handle_custom_scheme = [this](auto& custom_url) {
auto url = custom_url;
if (url.scheme() == "launch") {
// Treat "launch://" URLs as "file://" for use with Desktop::Launcher.
url.set_scheme("file"_string);
auto path = LexicalPath { URL::percent_decode(url.serialize_path()) };
if (!path.is_child_of(Manual::manual_base_path)) {
open_external(url);

View File

@@ -209,7 +209,7 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
m_file_links.append({ file, ByteString(), StringCollector::from(*link_node.text) });
return RecursionDecision::Recurse;
}
if (url.scheme() == "file") {
if (url.scheme() == "file" || url.scheme() == "launch") {
auto file_path = URL::percent_decode(url.serialize_path());
if (file_path.contains("man"sv) && file_path.ends_with(".md"sv)) {
warnln("Inter-manpage link without the help:// scheme: {}\nPlease use help URLs of the form 'help://man/<section>/<subsection...>/<page>'", href);