From 3c28b81405a2d7238faffed01327c1603b25e4f5 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 24 Nov 2023 15:29:33 +1100 Subject: [PATCH] Add home page --- CMakeLists.txt | 2 +- main.cpp | 4 +--- routes/home.cpp | 24 ++++++++++++++++++++++++ routes/routes.h | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 routes/home.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b49af94..7597564 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ add_link_options(${FLAGS}) add_executable(${PROJECT_NAME} main.cpp numberhelper.cpp config.cpp models.cpp client.cpp servehelper.cpp timeutils.cpp - routes/css.cpp routes/user.cpp routes/status.cpp + routes/home.cpp routes/css.cpp routes/user.cpp routes/status.cpp blankie/serializer.cpp blankie/escape.cpp) set_target_properties(${PROJECT_NAME} PROPERTIES diff --git a/main.cpp b/main.cpp index 86726cc..b8d3692 100644 --- a/main.cpp +++ b/main.cpp @@ -34,9 +34,7 @@ int main(int argc, char** argv) { httplib::Server server; -// server.Get("/", [&](const httplib::Request& req, httplib::Response& res) { -// home_route(req, res, config); -// }); + server.Get("/", home_route); server.Get("/style.css", css_route); server.Get("/(" DOMAIN_RE ")/@(" ACCT_RE ")(|/with_replies|/media)", user_route); server.Get("/(" DOMAIN_RE ")/users/(" ACCT_RE ")(|/with_replies|/media)", [](const httplib::Request& req, httplib::Response& res) { diff --git a/routes/home.cpp b/routes/home.cpp new file mode 100644 index 0000000..4ace82c --- /dev/null +++ b/routes/home.cpp @@ -0,0 +1,24 @@ +#include "routes.h" +#include "../servehelper.h" + +void home_route(const httplib::Request& req, httplib::Response& res) { + Element body("body", { + Element("p", {"Coyote, a Javascript-less Mastodon frontend."}), + Element("h2", {"Example links"}), + Element("ul", { + Element("li", {Element("a", {{"href", get_origin(req) + "/vt.social/@lina"}}, {"Asahi Lina (朝日リナ) // nullptr::live"})}), + Element("li", {Element("a", {{"href", get_origin(req) + "/vt.social/@LucydiaLuminous/111290028216105435"}}, {"\"I love kids and their creativity. So I was explain…\""})}), + }), + Element("hr"), + Element("p", { + "The ", Element("a", {{"href", "https://gitlab.com/blankX/coyote"}}, {"source code"}), " to Coyote is available under the ", + Element("a", {{"href", "https://gitlab.com/blankX/coyote/-/blob/master/LICENSE"}}, {"MIT license"}), ". " + "Some icons are used from ", Element("a", {{"href", "https://fontawesome.com"}}, {"Font Awesome"}), " Free, which are created by Fonticons, Inc. and ", + Element("a", {{"href", "https://fontawesome.com/license/free#icons"}}, {"licensed"}), " under the ", + Element("a", {{"href", "https://creativecommons.org/licenses/by/4.0/"}}, {"CC-BY 4.0"}), ". " + "Icons used are slightly modified for better accessibility." + }), + }); + + serve(req, res, "Coyote", std::move(body)); +} diff --git a/routes/routes.h b/routes/routes.h index 9503190..2f13c31 100644 --- a/routes/routes.h +++ b/routes/routes.h @@ -4,6 +4,7 @@ extern const uint64_t css_hash; +void home_route(const httplib::Request& req, httplib::Response& res); void css_route(const httplib::Request& req, httplib::Response& res); void user_route(const httplib::Request& req, httplib::Response& res); void status_route(const httplib::Request& req, httplib::Response& res);