From 71994b234b0366cb6dc37434806986baaaae33f4 Mon Sep 17 00:00:00 2001 From: blankie Date: Sat, 29 Apr 2023 15:02:31 +0700 Subject: [PATCH] Add link to tags --- routes/artworks.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/routes/artworks.cpp b/routes/artworks.cpp index f125bd1..fdaad86 100644 --- a/routes/artworks.cpp +++ b/routes/artworks.cpp @@ -11,7 +11,7 @@ static inline Element generate_images(const httplib::Request& req, const Config& static inline Element generate_preview_images(const httplib::Request& req, const Config& config, const Illust& illust); static inline std::vector parse_description_line(const httplib::Request& req, const Config& config, std::string str); static inline Element generate_description(const httplib::Request& req, const Config& config, const std::string& description); -static inline Element generate_illust_tags(const Illust& illust); +static inline Element generate_illust_tags(const httplib::Request& req, const Config& config, const Illust& illust); static inline bool is_true(const std::string& str); static inline std::string time_to_string(time_t time); @@ -49,7 +49,7 @@ void artworks_route(const httplib::Request& req, httplib::Response& res, const C if (illust.comment) { body.nodes.push_back(generate_description(req, config, *illust.comment)); } - body.nodes.push_back(generate_illust_tags(illust)); + body.nodes.push_back(generate_illust_tags(req, config, illust)); body.nodes.push_back(Element("p", {time_to_string(illust.upload_time)})); serve(req, res, config, std::move(illust.title), std::move(body)); } @@ -161,7 +161,7 @@ static inline Element generate_description(const httplib::Request& req, const Co return p; } -static inline Element generate_illust_tags(const Illust& illust) { +static inline Element generate_illust_tags(const httplib::Request& req, const Config& config, const Illust& illust) { Element div("div", {{"class", "illusttags"}}, {}); if (illust.ai_generated) { @@ -174,7 +174,9 @@ static inline Element generate_illust_tags(const Illust& illust) { return i.japanese; }(); - div.nodes.push_back(Element("span", {"#", std::move(tag)})); + div.nodes.push_back(Element("a", {{"href", get_origin(req, config) + "/tags/" + blankie::murl::escape(i.japanese)}}, { + "#", std::move(tag) + })); } return div;