comparison page-static.c @ 75:b12491ceabfd

pasterd: begin of custom theme
author David Demelier <markand@malikania.fr>
date Wed, 15 Mar 2023 20:15:00 +0100
parents 67b3d13a5035
children fe78b16c694d
comparison
equal deleted inserted replaced
74:67b3d13a5035 75:b12491ceabfd
1 /* 1 /*
2 * page-static.c -- page /static 2 * page-static.c -- page /static
3 * 3 *
4 * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr> 4 * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
5 * 5 *
6 * Permission to use, copy, modify, and/or distribute this software for any 6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies. 8 * copyright notice and this permission notice appear in all copies.
9 * 9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
31 get(struct kreq *req) 31 get(struct kreq *req)
32 { 32 {
33 struct stat st; 33 struct stat st;
34 char path[PATH_MAX]; 34 char path[PATH_MAX];
35 35
36 snprintf(path, sizeof (path), "%s%s", config.themedir, req->fullpath); 36 /* Skip /static part that we don't want in the theme directory. */
37 snprintf(path, sizeof (path), "%s%s", config.themedir, req->fullpath + 7);
37 38
38 if (stat(path, &st) < 0) 39 if (stat(path, &st) < 0)
39 page_status(req, KHTTP_404); 40 page_status(req, KHTTP_404);
40 else { 41 else {
41 khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]); 42 khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]);