New footer that includes current commit
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ aboba
|
|||||||
build
|
build
|
||||||
gpp1
|
gpp1
|
||||||
watcher
|
watcher
|
||||||
|
commit.h
|
||||||
|
32
build.c
32
build.c
@ -16,7 +16,11 @@ int main(int argc, char ** argv)
|
|||||||
RULE("./aboba",
|
RULE("./aboba",
|
||||||
"./main.c",
|
"./main.c",
|
||||||
"./routes.c",
|
"./routes.c",
|
||||||
|
"./routes.h",
|
||||||
"./baked.c",
|
"./baked.c",
|
||||||
|
"./baked.h",
|
||||||
|
"./clonestr.h",
|
||||||
|
"./commit.h"
|
||||||
|
|
||||||
"./mongoose.o",
|
"./mongoose.o",
|
||||||
"./gpp1",
|
"./gpp1",
|
||||||
@ -47,6 +51,34 @@ int main(int argc, char ** argv)
|
|||||||
CMD("cc", "-DHAVE_STRDUP", "-DHAVE_FNMATCH_H", "-o", "gpp1", "gpp/gpp.c");
|
CMD("cc", "-DHAVE_STRDUP", "-DHAVE_FNMATCH_H", "-o", "gpp1", "gpp/gpp.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RULE("./commit.h") {
|
||||||
|
String_Builder commit = {0};
|
||||||
|
defer { sb_free(&commit); }
|
||||||
|
Cmd commit_get_cmd = {0};
|
||||||
|
defer { cmd_free(&commit_get_cmd); }
|
||||||
|
cmd_append(&commit_get_cmd, "git");
|
||||||
|
cmd_append(&commit_get_cmd, "rev-parse");
|
||||||
|
cmd_append(&commit_get_cmd, "HEAD");
|
||||||
|
cmd_run_collect(&commit_get_cmd, &commit);
|
||||||
|
commit.items[commit.count - 2] = '\0'; // \n -> \0
|
||||||
|
|
||||||
|
LOGI("Commit %s\n", commit.items);
|
||||||
|
|
||||||
|
String_Builder header = {0};
|
||||||
|
defer { sb_free(&header); }
|
||||||
|
|
||||||
|
sb_append_nstr(&header, "#ifndef COMMIT_H_\n");
|
||||||
|
sb_append_nstr(&header, "#define COMMIT_H_\n");
|
||||||
|
sb_append_nstr(&header, fmt("#define COMMIT_STRING \"%s\"\n", commit.items));
|
||||||
|
sb_append_nstr(&header, "#endif // COMMIT_H_\n");
|
||||||
|
|
||||||
|
FILE *out = fopen("./commit.h", "w");
|
||||||
|
if (out) {
|
||||||
|
fwrite(header.items, header.count, 1, out);
|
||||||
|
fclose(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
CMD("cc", "-fPIC", "-ggdb", "-I.", "-DDEBUG=1", "-D_GNU_SOURCE", "-DGEBS_NO_PREFIX",
|
CMD("cc", "-fPIC", "-ggdb", "-I.", "-DDEBUG=1", "-D_GNU_SOURCE", "-DGEBS_NO_PREFIX",
|
||||||
"-DINCBIN_PREFIX=", "-DINCBIN_STYLE=INCBIN_STYLE_SNAKE", "-Wl,-z,execstack", "-o", "./aboba",
|
"-DINCBIN_PREFIX=", "-DINCBIN_STYLE=INCBIN_STYLE_SNAKE", "-Wl,-z,execstack", "-o", "./aboba",
|
||||||
|
2
gebs
2
gebs
Submodule gebs updated: d8e1d54f3d...c3be4ce8ee
9
routes.c
9
routes.c
@ -6,6 +6,7 @@
|
|||||||
#include "routes.h"
|
#include "routes.h"
|
||||||
#include "baked.h"
|
#include "baked.h"
|
||||||
#include "clonestr.h"
|
#include "clonestr.h"
|
||||||
|
#include "commit.h"
|
||||||
|
|
||||||
#define INTERNAL_SERVER_ERROR_MSG "Internal server error ;(. Try again later..."
|
#define INTERNAL_SERVER_ERROR_MSG "Internal server error ;(. Try again later..."
|
||||||
|
|
||||||
@ -106,6 +107,8 @@ ROUTE_HANDLER(page_not_found)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_append(&env, fmt("-DCOMMIT=%s", COMMIT_STRING));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
list_append(&env, "-DHOTRELOAD=1");
|
list_append(&env, "-DHOTRELOAD=1");
|
||||||
#else
|
#else
|
||||||
@ -192,6 +195,8 @@ ROUTE_HANDLER(home)
|
|||||||
make_internal_server_error(result);
|
make_internal_server_error(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_append(&env, fmt("-DCOMMIT=%s", COMMIT_STRING));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
list_append(&env, "-DHOTRELOAD=1");
|
list_append(&env, "-DHOTRELOAD=1");
|
||||||
@ -225,6 +230,8 @@ ROUTE_HANDLER(generic_blog)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_append(&env, fmt("-DCOMMIT=%s", COMMIT_STRING));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
list_append(&env, "-DHOTRELOAD=1");
|
list_append(&env, "-DHOTRELOAD=1");
|
||||||
#else
|
#else
|
||||||
@ -310,6 +317,8 @@ ROUTE_HANDLER(blog)
|
|||||||
make_internal_server_error(result);
|
make_internal_server_error(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_append(&env, fmt("-DCOMMIT=%s", COMMIT_STRING));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
list_append(&env, "-DHOTRELOAD=1");
|
list_append(&env, "-DHOTRELOAD=1");
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<#BLOG_POSTS>
|
<#BLOG_POSTS>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<a href="/">HOME</a>
|
<div style="float: left;">
|
||||||
|
<a href="/">HOME</a>
|
||||||
|
<span>COMMIT: <#COMMIT></span>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<#if HOTRELOAD>
|
<#if HOTRELOAD>
|
||||||
|
@ -46,7 +46,10 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
<footer>
|
<footer>
|
||||||
<a href="/">HOME</a>
|
<div style="float: left;">
|
||||||
|
<a href="/">HOME</a>
|
||||||
|
<span>COMMIT: <#COMMIT></span>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<#if HOTRELOAD>
|
<#if HOTRELOAD>
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
URL was: <#URL><br />
|
URL was: <#URL><br />
|
||||||
</p>
|
</p>
|
||||||
<footer>
|
<footer>
|
||||||
<a href="/">HOME</a>
|
<div style="float: left;">
|
||||||
|
<a href="/">HOME</a>
|
||||||
|
<span>COMMIT: <#COMMIT></span>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<#if HOTRELOAD>
|
<#if HOTRELOAD>
|
||||||
|
@ -8,7 +8,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="content"></div>
|
<div id="content"></div>
|
||||||
<footer>
|
<footer>
|
||||||
<a href="/">HOME</a>
|
<div style="float: left;">
|
||||||
|
<a href="/">HOME</a>
|
||||||
|
<span>COMMIT: <#COMMIT></span>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
Reference in New Issue
Block a user