Prefix blogs with blog-, fix minor leaks
This commit is contained in:
8
build.c
8
build.c
@ -34,10 +34,10 @@ int main(int argc, char ** argv)
|
||||
"./etc/me.jpg", \
|
||||
"./etc/tmoa-engine.jpg", \
|
||||
"./etc/tmoa-garbage.jpg", \
|
||||
"./blog/welcome.md", \
|
||||
"./blog/weird-page.md", \
|
||||
"./blog/curious-case-of-gebs.md", \
|
||||
"./blog/the-making-of-aboba.md"
|
||||
"./blog/blog-welcome.md", \
|
||||
"./blog/blog-weird-page.md", \
|
||||
"./blog/blog-curious-case-of-gebs.md", \
|
||||
"./blog/blog-the-making-of-aboba.md"
|
||||
|
||||
RULE("./aboba",
|
||||
"./main.c",
|
||||
|
5
routes.c
5
routes.c
@ -29,7 +29,7 @@ void make_application_json(Allocator *alloc, Route_Result *result, int code, cJS
|
||||
|
||||
result->status_code = code;
|
||||
result->type = ROUTE_RESULT_DYNAMIC;
|
||||
list_append(&result->headers, clonestr_alloc(alloc, "Content-Type: application/json"));
|
||||
list_append_alloc(alloc, &result->headers, clonestr_alloc(alloc, "Content-Type: application/json"));
|
||||
sb_append_nstr_alloc(alloc, &result->body, buf);
|
||||
sb_finish_alloc(alloc, &result->body);
|
||||
}
|
||||
@ -193,7 +193,7 @@ void route_generic_blog(Allocator *alloc, struct mg_http_message *msg, Route_Res
|
||||
#endif
|
||||
|
||||
String_Builder md = {0};
|
||||
if (!sb_read_file(&md, md_path)) {
|
||||
if (!sb_read_file_alloc(alloc, &md, md_path)) {
|
||||
make_internal_server_error(alloc, result);
|
||||
return;
|
||||
}
|
||||
@ -243,6 +243,7 @@ void route_generic_blog(Allocator *alloc, struct mg_http_message *msg, Route_Res
|
||||
void collect_blogs(Baked_Resource *resource, void *udata)
|
||||
{
|
||||
struct { Allocator *alloc; String_Builder *sb; } *ud = udata;
|
||||
printf("%s\n", resource->key);
|
||||
if ((strlen(resource->key) >= strlen("blog-"))
|
||||
&& strncmp(resource->key, "blog-", strlen("blog-")) == 0) {
|
||||
sb_append_nstr_alloc(ud->alloc, ud->sb,
|
||||
|
Reference in New Issue
Block a user