diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-02-03 22:40:27 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-02-16 01:20:39 +0100 |
| commit | 425d599055c66c63b6d52f0c6ef2da522e359ee7 (patch) | |
| tree | d5472468f6ea1228455624dd68f1338f047a84d7 | |
| parent | f3b446cdb542211ba0813c90899bce875f4da772 (diff) | |
Add substitute().
| -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); |
