diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-02-03 22:40:27 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-02-03 22:40:27 +0100 |
| commit | 82c9ac237fbc15e839ba6a5baeb7164736174852 (patch) | |
| tree | 80db606893e22858aef8667da3cc254574fb63f3 /src/lib | |
| parent | 4a9bb9e3c2088682e1f2ab336c233f5e3818c162 (diff) | |
Add substitute().
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/http_server.cc | 14 | ||||
| -rw-r--r-- | src/lib/http_server.h | 1 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc index 4a708a88c..f30260d95 100644 --- a/src/lib/http_server.cc +++ b/src/lib/http_server.cc @@ -105,18 +105,24 @@ Response::send(shared_ptr<Socket> socket) } +void +HTTPServer::substitute(string& page) const +{ + boost::algorithm::replace_all(page, "TITLE", variant::dcpomatic_player()); + boost::algorithm::replace_all(page, "SIDEBAR", dcp::file_to_string(resources_path() / "web" / "sidebar.html")); +} + + Response HTTPServer::get_request(string const& url) { if (url == "/") { auto page = dcp::file_to_string(resources_path() / "web" / "index.html"); - boost::algorithm::replace_all(page, "TITLE", variant::dcpomatic_player()); - boost::algorithm::replace_all(page, "SIDEBAR", dcp::file_to_string(resources_path() / "web" / "sidebar.html")); + substitute(page); return Response(200, page); } else if (url == "/playlists") { auto page = dcp::file_to_string(resources_path() / "web" / "playlists.html"); - boost::algorithm::replace_all(page, "TITLE", variant::dcpomatic_player()); - boost::algorithm::replace_all(page, "SIDEBAR", dcp::file_to_string(resources_path() / "web" / "sidebar.html")); + substitute(page); return Response(200, page); } else if (url == "/common.css") { auto page = dcp::file_to_string(resources_path() / "web" / "common.css"); diff --git a/src/lib/http_server.h b/src/lib/http_server.h index d22a347d3..b100a5db7 100644 --- a/src/lib/http_server.h +++ b/src/lib/http_server.h @@ -90,6 +90,7 @@ public: private: void handle(std::shared_ptr<Socket> socket) override; + void substitute(std::string& page) const; Response request(std::vector<std::string> const& request, std::string const& body); Response get_request(std::string const& url); Response post_request(std::string const& url, std::string const& body); |
