pixwhile/routes/home.cpp

24 lines
1.0 KiB
C++

#include "routes.h"
#include "../servehelper.h"
void home_route(const httplib::Request& req, httplib::Response& res, const Config& config) {
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")
})
});
serve(req, res, config, "Pixwhile", std::move(body));
}