From db02c4cc8028606fa57fd50424491008990ef6fd Mon Sep 17 00:00:00 2001 From: frosty Date: Fri, 3 Apr 2026 15:15:41 -0400 Subject: feat: added version to homepage --- Makefile | 12 ++++++++++-- src/Routes/Home.c | 1 + src/Utility/Utility.h | 4 ++++ static/main.css | 10 ++++++++++ templates/home.html | 3 +++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6e5b227..ecd6585 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,21 @@ UNAME_S := $(shell uname -s) PKG_CONFIG ?= pkg-config PKG_DEPS := libxml-2.0 libcurl openssl +GIT_HASH := $(shell git rev-parse --short HEAD) +GIT_DATE := $(shell git log -1 --format='%ad' --date='format:%y.%m.%d') +GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) + +VERSION := $(GIT_DATE)+$(GIT_HASH)_$(GIT_BRANCH) + +CFLAGS := -Wall -Wextra -O2 -Isrc -DVERSION='"$(VERSION)"' + ifeq ($(UNAME_S),Darwin) DEP_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_DEPS) 2>/dev/null) DEP_LIBS := $(shell $(PKG_CONFIG) --libs $(PKG_DEPS) 2>/dev/null) -CFLAGS := -Wall -Wextra -O2 -Isrc $(DEP_CFLAGS) +CFLAGS += $(DEP_CFLAGS) LIBS := -lbeaker $(DEP_LIBS) -lpthread -lm else -CFLAGS := -Wall -Wextra -O2 -Isrc -I/usr/include/libxml2 +CFLAGS += -I/usr/include/libxml2 LIBS := -lbeaker -lcurl -lxml2 -lpthread -lm -lssl -lcrypto endif diff --git a/src/Routes/Home.c b/src/Routes/Home.c index bbd53b7..1e5c3df 100644 --- a/src/Routes/Home.c +++ b/src/Routes/Home.c @@ -10,6 +10,7 @@ int home_handler(UrlParams *params) { TemplateContext ctx = new_context(); context_set(&ctx, "theme", theme); + context_set(&ctx, "version", VERSION); beaker_set_locale(&ctx, locale); char *rendered_html = render_template("home.html", &ctx); send_response(rendered_html); diff --git a/src/Utility/Utility.h b/src/Utility/Utility.h index 2002307..8d13306 100644 --- a/src/Utility/Utility.h +++ b/src/Utility/Utility.h @@ -3,6 +3,10 @@ #include +#ifndef VERSION +#define VERSION "unknown" +#endif + #define LINK_FIELD_COUNT 3 int hex_to_int(char c); diff --git a/static/main.css b/static/main.css index 1b56721..2ef60c3 100644 --- a/static/main.css +++ b/static/main.css @@ -135,6 +135,16 @@ img[src=""] { mask-position:center; text-decoration:none; } +.home-footer { + position: fixed; + bottom: 0; + left: 0; + right: 0; + padding: 8px 24px; + font-size: 12px; + color: var(--text-muted); + text-align: center; +} .nav-settings-icon { width:24px; height:24px; diff --git a/templates/home.html b/templates/home.html index 9921ac4..0aef27b 100644 --- a/templates/home.html +++ b/templates/home.html @@ -39,6 +39,9 @@ + -- cgit v1.2.3