diff --git a/main.c b/main.c
index a297c7e..d4a3c31 100644
--- a/main.c
+++ b/main.c
@@ -21,6 +21,7 @@ WITH REGARD TO THIS SOFTWARE.
*/
struct dirent* dir;
+time_t edittime;
typedef struct Lexicon {
int len, refs[LEXICON_SIZE];
@@ -51,6 +52,8 @@ int error(char* msg, char* val) {
return 0;
}
+time_t getlater(time_t a, time_t b) { return a > b ? a : b; }
+
int ismetanav(char* name) { return scmp(name, "meta.nav"); }
int findf(Lexicon* l, char* f) {
@@ -109,13 +112,18 @@ int gettwtxt(FILE* f) {
}
}
-void fpedited(FILE* f, char* path) {
- struct stat attr;
- stat(path, &attr);
- fprintf(f, "Edited on %s
", ctime(&attr.st_mtime));
+void fpedited(FILE* f) {
+ struct tm timebuf;
+ char strbuf[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+
+ timebuf = *localtime(&edittime);
+ strftime(strbuf, 16, "%Y-%m-%d", &timebuf);
+
+ fprintf(f, "modified %s
", strbuf);
}
int fpportal(FILE* f, Lexicon* l, char* s, int head) {
+ struct stat attr;
int target;
char srcpath[64], filename[64];
target = findf(l, s);
@@ -124,6 +132,10 @@ int fpportal(FILE* f, Lexicon* l, char* s, int head) {
srcpath[0] = 0;
filename[0] = 0;
scat(scat(scat(srcpath, "inc/"), scpy(s, filename, 64)), ".htm");
+ stat(scsw(srcpath, ' ', '_'), &attr);
+ if (!ismetanav(s)) {
+ edittime = getlater(edittime, attr.st_mtime);
+ }
if (head)
fprintf(
f,
@@ -454,10 +466,12 @@ int fptemplate(FILE* f, Lexicon* l, char* s) {
case '&':
return fppara(f, l, s + 1);
}
- if (s[0])
+ if (s[0]) {
target = findf(l, s);
- if (target < 0)
+ }
+ if (target < 0) {
return error("Missing link", s);
+ }
fprintf(f, "", scsw(stlc(s), ' ', '_'));
fprintf(f, "%s", scsw(stlc(s), '_', ' '));
l->refs[target]++;
@@ -498,8 +512,9 @@ int fpmetatemplate(FILE* f, Lexicon* l, char* s) {
return error("Templating error", "text block exceeds tag body size");
if (t) {
ccat(ss, *s);
- } else
+ } else {
fprintf(f, "%c", *s);
+ }
s++;
}
return 1;
@@ -516,6 +531,7 @@ int fpinject(FILE* f, Lexicon* l, char* filepath) {
scsw(filepath, ' ', '_');
if (!(inc = fopen(filepath, "r")))
return error("Missing include", filepath);
+
s[0] = 0;
while ((c = fgetc(inc)) != EOF) {
if (c == '}') {
@@ -538,23 +554,26 @@ int fpinject(FILE* f, Lexicon* l, char* filepath) {
continue;
}
}
- if (slen(s) >= TAG_BODY_SIZE)
+ if (slen(s) >= TAG_BODY_SIZE) {
return error("Templating error", filepath);
- if (t)
+ }
+ if (t) {
ccat(s, c);
- else
+ } else {
fprintf(f, "%c", c);
+ }
}
fclose(inc);
return 1;
}
-int fpfooter(FILE* f, char* name, char* path) {
- if (!f || !name || !path)
+int fpfooter(FILE* f, char* name) {
+ if (!f || !name) {
return 0;
+ }
fputs("