mobley

C Git HTTP server
Log | Files | Refs | Submodules | README | git clone https://git.ne02ptzero.me/git/mobley

commit 8b59578f38d2853739578bad5721ac2b49843fce
parent c3934bbb3818aa470466fb2742ee0c90f181fd25
Author: Louis Solofrizzo <lsolofrizzo@online.net>
Date:   Wed, 30 Jan 2019 14:18:08 +0100

Template: Add favicon w/ config

Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>

Diffstat:
Mconfig.c | 2++
Mconfig.yaml | 1+
Mmobley.h | 2++
Mtemplate.c | 11+++++++++++
4 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/config.c b/config.c @@ -33,6 +33,8 @@ static bool config_read_token(const char *tok, unsigned char *value, mobley_t *c COPY_OR_FAIL(ctx->conf.static_dir, value); else if (strcmp(tok, "logo") == 0) COPY_OR_FAIL(ctx->conf.logo, value); + else if (strcmp(tok, "favicon") == 0) + COPY_OR_FAIL(ctx->conf.favicon, value); else if (strcmp(tok, "desc") == 0) COPY_OR_FAIL(ctx->conf.root_desc, value); else if (strcmp(tok, "title") == 0) diff --git a/config.yaml b/config.yaml @@ -2,6 +2,7 @@ address : 0.0.0.0 port : 4242 static_dir : /usr/local/share/mobley logo : logo.png +favicon : favicon.ico desc : Software Stuff title : git:// repo_dir : /home/louis/Work/perso/git_local/repositories diff --git a/mobley.h b/mobley.h @@ -39,6 +39,7 @@ typedef struct { bool sort_repo; char *clone_ssh_url; char *source_highlight_data_dir; + char *favicon; list_head_t styles; } conf; @@ -69,6 +70,7 @@ static inline void mobley_conf_dtr(mobley_t *ctx) free(ctx->repos.repo_dir); free(ctx->conf.clone_ssh_url); free(ctx->conf.source_highlight_data_dir); + free(ctx->conf.favicon); string_array_free(&ctx->conf.styles); repository_list_free(&ctx->repos.repos); } diff --git a/template.c b/template.c @@ -190,6 +190,17 @@ void template_begin(const mobley_t *ctx, server_req_t *r) .closing_slash = true ); + if (ctx->conf.favicon != NULL) + { + html_nd("link", + .rel = "icon", + .type = "image/x-icon", + .href = ctx->conf.favicon, + .closing_slash = true, + .is_static = true + ); + } + } html_close("head"); html_open("body") {