Mercurial
diff mrjunejune/main.c @ 100:65e5a5b89a4e
[Seobeo] Migrated everything to this page.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Sat, 03 Jan 2026 07:48:07 -0800 |
| parents | 70401cf61e97 |
| children | dbf14f84d51c |
line wrap: on
line diff
--- a/mrjunejune/main.c Fri Jan 02 20:38:02 2026 -0800 +++ b/mrjunejune/main.c Sat Jan 03 07:48:07 2026 -0800 @@ -19,9 +19,11 @@ char *path, Dowa_Arena *arena ) { + Seobeo_Log(SEOBEO_DEBUG, "[Curr] %s\n", path); size_t html_size = 0; char *template = Seobeo_Web_LoadFile(path, &html_size); if (!template) return; + Seobeo_Log(SEOBEO_DEBUG, "[Curr] ??\n"); size_t current_offset = 0; char *cursor = template; @@ -47,6 +49,7 @@ size_t sub_file_size = 0; char *sub_content = Seobeo_Web_LoadFile(include_name, &sub_file_size); + Seobeo_Log(SEOBEO_DEBUG, "[Curr] Sub content: %s\n", sub_content); if (sub_content) { memcpy(final_body + current_offset, sub_content, sub_file_size); @@ -435,6 +438,42 @@ return resp; } +Seobeo_Request_Entry *RenderBlogList(Seobeo_Request_Entry *req, Dowa_Arena *arena) +{ + Seobeo_Request_Entry *resp = NULL; + char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); + Seobeo_ServerSideRender(final_body, "/blog/index.html", arena); + Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); + return resp; +} + + +Seobeo_Request_Entry *RenderBlog(Seobeo_Request_Entry *req, Dowa_Arena *arena) +{ + Seobeo_Log(SEOBEO_DEBUG, "[CURR], Hello\n"); + Seobeo_Request_Entry *resp = NULL; + + void *blog_id_kv = Dowa_HashMap_Get_Ptr(req, ":blog_id"); + if (!blog_id_kv) + { + char *error_msg = "No Blog Id"; + Dowa_HashMap_Push_Arena(resp, "status", "404", arena); + Dowa_HashMap_Push_Arena(resp, "content-type", "text/plain", arena); + Dowa_HashMap_Push_Arena(resp, "body", error_msg, arena); + return resp; + } + + const char *blog_id = ((Seobeo_Request_Entry *)blog_id_kv)->value; + char *html_path = Dowa_Arena_Allocate(arena, 512); + sprintf(html_path, "/blog/%s/index.html", blog_id); + + char *final_body = Dowa_Arena_Allocate(arena, 100 * 1024); // TODO: Think about the sizes + Seobeo_ServerSideRender(final_body, html_path, arena); + Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); + return resp; +} + + CREATE_REDIRECT_HANDLER(HomePage, "/") CREATE_REDIRECT_HANDLER(Resume, "/resume") CREATE_REDIRECT_HANDLER(Tools, "/tools") @@ -459,9 +498,14 @@ Seobeo_Router_Register("GET", "/tools/file_converter", GetFileConverter); Seobeo_Router_Register("GET", "/tools/file_converter/index.html", GetRedirectFileConverter); + // -- File converter --/ Seobeo_Router_Register("POST", "/api/convert/image-to-webp", ConvertImageToWebP); Seobeo_Router_Register("POST", "/api/convert/video-to-mp4", ConvertVideoToMP4); Seobeo_Router_Register("GET", "/api/download/:filename", DownloadConvertedFile); + // -- Blog --/ + Seobeo_Router_Register("GET", "/blog", RenderBlogList); + Seobeo_Router_Register("GET", "/blog/:blog_id", RenderBlog); + Seobeo_Web_Server_Start("mrjunejune/src", "6969", SEOBEO_MODE_EDGE, 3); }