Add illustration search box
This commit is contained in:
parent
71994b234b
commit
4586931adf
|
@ -5,11 +5,13 @@ Pixwhile is an alternative frontend to Pixiv that utilizes no Javascript.
|
||||||
- Does not contain an asinine amount of Javascript
|
- Does not contain an asinine amount of Javascript
|
||||||
- Allows you to open the original versions of cover images and profile pictures
|
- Allows you to open the original versions of cover images and profile pictures
|
||||||
- Can view illustrations and list user illustrations
|
- Can view illustrations and list user illustrations
|
||||||
|
- Can search for newest and oldest illustrations
|
||||||
|
|
||||||
## Missing Features
|
## Missing Features
|
||||||
|
|
||||||
This list is not exhaustive, nor does it mean that these are being worked on.
|
This list is not exhaustive, nor does it mean that these are being worked on.
|
||||||
|
|
||||||
|
- Can only search for newest and oldest illustrations
|
||||||
- No search
|
- No search
|
||||||
- No ability to login
|
- No ability to login
|
||||||
- No ability to see comments or like counts
|
- No ability to see comments or like counts
|
||||||
|
|
|
@ -52,5 +52,9 @@ std::string Element::serialize() const {
|
||||||
} // namespace blankie
|
} // namespace blankie
|
||||||
|
|
||||||
static inline bool is_autoclosing_tag(const char* tag) {
|
static inline bool is_autoclosing_tag(const char* tag) {
|
||||||
return !strncmp(tag, "link", 5) || !strncmp(tag, "meta", 5) || !strncmp(tag, "img", 4) || !strncmp(tag, "br", 3);
|
return !strncmp(tag, "link", 5)
|
||||||
|
|| !strncmp(tag, "meta", 5)
|
||||||
|
|| !strncmp(tag, "img", 4)
|
||||||
|
|| !strncmp(tag, "br", 3)
|
||||||
|
|| !strncmp(tag, "label", 6);
|
||||||
}
|
}
|
||||||
|
|
9
main.cpp
9
main.cpp
|
@ -62,6 +62,15 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
serve_redirect(req, res, config, get_origin(req, config) + "/artworks/" + illust_id);
|
serve_redirect(req, res, config, get_origin(req, config) + "/artworks/" + illust_id);
|
||||||
});
|
});
|
||||||
|
server.Get("/search", [&](const httplib::Request& req, httplib::Response& res) {
|
||||||
|
std::string q = req.get_param_value("q");
|
||||||
|
if (q.empty()) {
|
||||||
|
res.status = 400;
|
||||||
|
serve_error(req, res, config, "400: Bad Request", "Missing or empty search query");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serve_redirect(req, res, config, get_origin(req, config) + "/tags/" + blankie::murl::escape(std::move(q)));
|
||||||
|
});
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
server.Get("/debug/exception/known", [](const httplib::Request& req, httplib::Response& res) {
|
server.Get("/debug/exception/known", [](const httplib::Request& req, httplib::Response& res) {
|
||||||
|
|
|
@ -15,6 +15,12 @@ void home_route(const httplib::Request& req, httplib::Response& res, const Confi
|
||||||
"Pixwhile is an alternative frontend to Pixiv that utilizes no Javascript. (",
|
"Pixwhile is an alternative frontend to Pixiv that utilizes no Javascript. (",
|
||||||
Element("a", {{"href", "https://gitlab.com/blankX/pixwhile"}}, {"source code"}),
|
Element("a", {{"href", "https://gitlab.com/blankX/pixwhile"}}, {"source code"}),
|
||||||
")",
|
")",
|
||||||
|
Element("form", {{"method", "get"}, {"action", "search"}}, {
|
||||||
|
Element("br"),
|
||||||
|
Element("input", {{"name", "q"}, {"required", ""}}, {}),
|
||||||
|
" ",
|
||||||
|
Element("button", {"Search for illustrations"})
|
||||||
|
}),
|
||||||
Element("h2", {"Try it out"}),
|
Element("h2", {"Try it out"}),
|
||||||
Element("ul", {
|
Element("ul", {
|
||||||
get_artwork_element(106623268, "アル社長の日常", 1960050, "torino"),
|
get_artwork_element(106623268, "アル社長の日常", 1960050, "torino"),
|
||||||
|
@ -24,12 +30,13 @@ void home_route(const httplib::Request& req, httplib::Response& res, const Confi
|
||||||
Element("ul", {
|
Element("ul", {
|
||||||
Element("li", {"Does not contain an asinine amount of Javascript"}),
|
Element("li", {"Does not contain an asinine amount of Javascript"}),
|
||||||
Element("li", {"Allows you to open the original versions of cover images and profile pictures"}),
|
Element("li", {"Allows you to open the original versions of cover images and profile pictures"}),
|
||||||
Element("li", {"Can view illustrations and list user illustrations"})
|
Element("li", {"Can view illustrations and list user illustrations"}),
|
||||||
|
Element("li", {"Can search for newest and oldest illustrations"})
|
||||||
}),
|
}),
|
||||||
Element("h2", {"Missing Features"}),
|
Element("h2", {"Missing Features"}),
|
||||||
Element("p", {"This list is not exhaustive, nor does it mean that these are being worked on."}),
|
Element("p", {"This list is not exhaustive, nor does it mean that these are being worked on."}),
|
||||||
Element("ul", {
|
Element("ul", {
|
||||||
Element("li", {"No search"}),
|
Element("li", {"Can only search for newest and oldest illustrations"}),
|
||||||
Element("li", {"No ability to login"}),
|
Element("li", {"No ability to login"}),
|
||||||
Element("li", {"No ability to see comments or like counts"}),
|
Element("li", {"No ability to see comments or like counts"}),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue