pixwhile/routes/home.cpp

24 lines
1.0 KiB
C++
Raw Normal View History

2023-04-03 15:10:08 +00:00
#include "routes.h"
2023-04-03 09:32:26 +00:00
#include "../servehelper.h"
2023-04-03 08:57:51 +00:00
2023-04-03 09:32:26 +00:00
void home_route(const httplib::Request& req, httplib::Response& res, const Config& config) {
2023-04-03 14:40:34 +00:00
std::string origin = get_origin(req, config);
auto get_artwork_element = [&](size_t illust_id, const char* illust_title, size_t author_id, const char* author_display_name) {
return Element("li", {
Element("a", {{"href", origin + "/artworks/" + std::to_string(illust_id)}}, {illust_title}),
" by ",
Element("a", {{"href", origin + "/users/" + std::to_string(author_id)}}, {author_display_name}),
});
};
Element body("body", {
Element("p", {"Pixwhile is an alternative frontend to Pixiv that utilizes no Javascript."}),
Element("h2", {"Try it out"}),
Element("ul", {
get_artwork_element(106623268, "アル社長の日常", 1960050, "torino"),
get_artwork_element(94449946, "Gura and Shion", 15961697, "ZWJ")
})
});
2023-04-03 09:32:26 +00:00
serve(req, res, config, "Pixwhile", std::move(body));
2023-04-03 08:57:51 +00:00
}