comparison page-search.c @ 64:e8d8eaa0da53

pasterd: support <title> in header
author David Demelier <markand@malikania.fr>
date Thu, 26 May 2022 13:28:10 +0200
parents ecb0b90d94d8
children 1a98bc0daa49
comparison
equal deleted inserted replaced
63:1075658abc74 64:e8d8eaa0da53
62 .keysz = NELEM(keywords), 62 .keysz = NELEM(keywords),
63 .cb = template, 63 .cb = template,
64 .arg = r 64 .arg = r
65 }; 65 };
66 66
67 page(r, &kt, KHTTP_200, "pages/search.html"); 67 page(r, &kt, KHTTP_200, "pages/search.html", "Search pastes");
68 } 68 }
69 69
70 static void 70 static void
71 post(struct kreq *r) 71 post(struct kreq *r)
72 { 72 {
93 title = NULL; 93 title = NULL;
94 if (author && strlen(author) == 0) 94 if (author && strlen(author) == 0)
95 author = NULL; 95 author = NULL;
96 96
97 if (!database_search(pastes, &pastesz, title, author, language)) 97 if (!database_search(pastes, &pastesz, title, author, language))
98 page(r, NULL, KHTTP_500, "pages/500.html"); 98 page(r, NULL, KHTTP_500, "pages/500.html", "500");
99 else 99 else
100 page_index_render(r, pastes, pastesz); 100 page_index_render(r, pastes, pastesz);
101 101
102 for (size_t i = 0; i < pastesz; ++i) 102 for (size_t i = 0; i < pastesz; ++i)
103 paste_finish(&pastes[i]); 103 paste_finish(&pastes[i]);
114 break; 114 break;
115 case KMETHOD_POST: 115 case KMETHOD_POST:
116 post(r); 116 post(r);
117 break; 117 break;
118 default: 118 default:
119 page(r, NULL, KHTTP_400, "pages/400.html"); 119 page(r, NULL, KHTTP_400, "pages/400.html", "400");
120 break; 120 break;
121 } 121 }
122 } 122 }