ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
assets.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7// Static-asset serving for `rux gui`.
8//
9// The frontend bundle is a *data asset installed next to the binary*, never
10// embedded in it (issue #265): Phase 2 builds it with Nix into
11// `share/reusex/gui/` and the server picks it up from there. Until that bundle
12// exists, a built-in placeholder page stands in so the server is usable and
13// self-describing on day one.
14
15#include <filesystem>
16#include <string>
17#include <string_view>
18
19namespace rux::gui {
20
31std::filesystem::path
32resolve_asset_dir(const std::filesystem::path &override_dir);
33
36std::filesystem::path executable_dir();
37
43std::string percent_decode(std::string_view text);
44
50std::filesystem::path resolve_asset(const std::filesystem::path &root,
51 std::string_view url_path);
52
58bool looks_like_spa_route(std::string_view url_path);
59
62std::string mime_type_for(const std::filesystem::path &path);
63
68std::string placeholder_page(std::string_view project_name);
69
70} // namespace rux::gui
std::filesystem::path resolve_asset_dir(const std::filesystem::path &override_dir)
Locate the frontend asset directory, in precedence order:
std::string mime_type_for(const std::filesystem::path &path)
Content type for a file, by extension.
std::string percent_decode(std::string_view text)
Percent-decode a URL path component ("%2e%2e" -> "..").
bool looks_like_spa_route(std::string_view url_path)
True when a path looks like a client-side route rather than a missing file.
std::filesystem::path executable_dir()
Directory of the running executable, or an empty path if it cannot be determined.
std::filesystem::path resolve_asset(const std::filesystem::path &root, std::string_view url_path)
Map a request path onto a file inside root.
std::string placeholder_page(std::string_view project_name)
The built-in landing page served when no asset bundle is installed.