Finish the illustrations page
This commit is contained in:
		
							parent
							
								
									3d37733af9
								
							
						
					
					
						commit
						936851a478
					
				| 
						 | 
				
			
			@ -54,6 +54,19 @@ void css_route(const httplib::Request& req, httplib::Response& res) {
 | 
			
		|||
    .center {
 | 
			
		||||
        text-align: center;
 | 
			
		||||
    }
 | 
			
		||||
    .userillustrations {
 | 
			
		||||
        display: flex;
 | 
			
		||||
        flex-wrap: wrap;
 | 
			
		||||
        gap: 1em;
 | 
			
		||||
        justify-content: center;
 | 
			
		||||
    }
 | 
			
		||||
    .userillustrations img {
 | 
			
		||||
        width: 15em;
 | 
			
		||||
        height: 15em;
 | 
			
		||||
    }
 | 
			
		||||
    .userillustrations p {
 | 
			
		||||
        width: 15em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .error {
 | 
			
		||||
        text-align: center;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#include "common.h"
 | 
			
		||||
 | 
			
		||||
static Element generate_pager(const Illusts& illusts, size_t page);
 | 
			
		||||
static inline Element generate_content(const Illusts& illusts);
 | 
			
		||||
static inline Element generate_content(const httplib::Request& req, const Config& config, const Illusts& illusts);
 | 
			
		||||
 | 
			
		||||
void user_illustrations_route(const httplib::Request& req, httplib::Response& res, const Config& config, PixivClient& pixiv_client) {
 | 
			
		||||
    uint64_t user_id = to_ull(req.matches[1].str());
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ void user_illustrations_route(const httplib::Request& req, httplib::Response& re
 | 
			
		|||
        generate_user_header(std::move(user), config),
 | 
			
		||||
        generate_pager(illusts, page),
 | 
			
		||||
        Element("br"),
 | 
			
		||||
        generate_content(illusts),
 | 
			
		||||
        generate_content(req, config, illusts),
 | 
			
		||||
        generate_pager(illusts, page)
 | 
			
		||||
    });
 | 
			
		||||
    serve(req, res, config, user.display_name + " illustrations", std::move(body));
 | 
			
		||||
| 
						 | 
				
			
			@ -64,16 +64,19 @@ static Element generate_pager(const Illusts& illusts, size_t page) {
 | 
			
		|||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline Element generate_content(const Illusts& illusts) {
 | 
			
		||||
    // TODO be real
 | 
			
		||||
    Element ul("ul");
 | 
			
		||||
static inline Element generate_content(const httplib::Request& req, const Config& config, const Illusts& illusts) {
 | 
			
		||||
    Element div("div", {{"class", "userillustrations"}}, {});
 | 
			
		||||
 | 
			
		||||
    ul.nodes.reserve(illusts.illusts.size());
 | 
			
		||||
    div.nodes.reserve(illusts.illusts.size());
 | 
			
		||||
    for (const Illust& i : illusts.illusts) {
 | 
			
		||||
        ul.nodes.push_back(Element("li", {
 | 
			
		||||
            std::to_string(i.illust_id)
 | 
			
		||||
        std::string illust_url = get_origin(req, config) + "/artworks/" + std::to_string(i.illust_id);
 | 
			
		||||
        std::string image_url = proxy_image_url(config, i.images[0].thumbnail_or_original());
 | 
			
		||||
 | 
			
		||||
        div.nodes.push_back(Element("a", {{"href", {std::move(illust_url)}}}, {
 | 
			
		||||
            Element("img", {{"loading", "lazy"}, {"src", std::move(image_url)}}, {}),
 | 
			
		||||
            Element("p", {i.title})
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ul;
 | 
			
		||||
    return div;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue