diff --git a/stagit.c b/stagit.c
@@ -19,7 +19,7 @@
#include "compat.h"
-#define LEN(s) (sizeof(s)/sizeof(*s))
+#define LEN(s) (sizeof(s)/sizeof(*s))
struct deltainfo {
git_patch *patch;
@@ -423,7 +423,7 @@ void printtime(FILE *fp, const git_time *intime)
intime->offset / 60, intime->offset % 60);
}
-void printtimeshort(FILE *fp, const git_time *intime)
+void formattime(FILE *fp, const char *fstring, const git_time *intime)
{
struct tm *intm;
time_t t;
@@ -432,7 +432,7 @@ void printtimeshort(FILE *fp, const git_time *intime)
t = (time_t)intime->time;
if (!(intm = gmtime(&t)))
return;
- strftime(out, sizeof(out), "%Y-%m-%d %H:%M", intm);
+ strftime(out, sizeof(out), fstring, intm);
fputs(out, fp);
}
@@ -633,7 +633,7 @@ void printshowfile(FILE *fp, struct commitinfo *ci)
memset(&linestr, '+', add);
memset(&linestr[add], '-', del);
- fprintf(fp, "</a></td><td> | </td><td class=\"num\">%zu</td><td><span class=\"i\">",
+ fprintf(fp, "</a></td><td> | </td><td>%zu</td><td><span class=\"i\">",
ci->deltas[i]->addcount + ci->deltas[i]->delcount);
fwrite(&linestr, 1, add, fp);
fputs("</span><span class=\"d\">", fp);
@@ -696,31 +696,33 @@ void printshowfile(FILE *fp, struct commitinfo *ci)
void writelogline(FILE *fp, struct commitinfo *ci)
{
- fputs("<tr><td>", fp);
- if (ci->author)
- {
+ fputs("<article>\n", fp);
+
+ if (ci->author) {
+ fputs("<div>\n<span>", fp);
+ xmlencode(fp, ci->author->name, strlen(ci->author->name));
+ fputs("</span>\n", fp);
+
fputs("<time datetime=\"", fp);
- printtimeshort(fp, &(ci->author->when));
+ formattime(fp, "%Y-%m-%d %H:%M", &(ci->author->when));
fputs("\">", fp);
- printtimeshort(fp, &(ci->author->when));
- fputs("</time>", fp);
+ formattime(fp, "%d/%m/%Y %H:%M", &(ci->author->when));
+ fputs("</time>\n</div>\n", fp);
}
- fputs("</td><td>", fp);
+
if (ci->summary) {
- fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
+ fprintf(fp, "<p>\n<a href=\"%scommit/%s.html\">", relpath, ci->oid);
xmlencode(fp, ci->summary, strlen(ci->summary));
- fputs("</a>", fp);
+ fputs("</a>\n</p>\n", fp);
+ } else {
+ fprintf(
+ fp,
+ "<p>\n<a href=\"%scommit/%s.html\">Commit %s</a>\n</p>\n",
+ relpath,
+ ci->oid,
+ ci->oid
+ );
}
- fputs("</td><td>", fp);
- if (ci->author)
- xmlencode(fp, ci->author->name, strlen(ci->author->name));
- fputs("</td><td class=\"num\" align=\"right\">", fp);
- fprintf(fp, "%zu", ci->filecount);
- fputs("</td><td class=\"num\" align=\"right\">", fp);
- fprintf(fp, "+%zu", ci->addcount);
- fputs("</td><td class=\"num\" align=\"right\">", fp);
- fprintf(fp, "-%zu", ci->delcount);
- fputs("</td></tr>\n", fp);
}
int writelog(FILE *fp, const git_oid *oid)
@@ -1038,7 +1040,7 @@ int writefilestree(FILE *fp, git_tree *tree, const char *path)
xmlencode(fp, filepath, strlen(filepath));
fputs("\">", fp);
xmlencode(fp, entrypath, strlen(entrypath));
- fputs("</a></td><td class=\"num\" align=\"right\">", fp);
+ fputs("</a></td><td align=\"right\">", fp);
if (lc > 0)
fprintf(fp, "%zuL", lc);
else
@@ -1053,7 +1055,7 @@ int writefilestree(FILE *fp, git_tree *tree, const char *path)
fputs("</a> @ ", fp);
git_oid_tostr(oid, sizeof(oid), git_tree_entry_id(entry));
xmlencode(fp, oid, strlen(oid));
- fputs("</td><td class=\"num\" align=\"right\"></td></tr>\n", fp);
+ fputs("</td><td align=\"right\"></td></tr>\n", fp);
}
}
@@ -1066,16 +1068,16 @@ int writefiles(FILE *fp, const git_oid *id)
git_commit *commit = NULL;
int ret = -1;
- fputs("<div class=\"table-container\"><table id=\"files\"><thead>\n<tr>"
- "<td><b>Mode</b></td><td><b>Name</b></td>"
- "<td class=\"num\" align=\"right\"><b>Size</b></td>"
- "</tr>\n</thead><tbody>\n", fp);
+ fputs("<table>\n<thead>\n<tr>"
+ "<td>Mode</td><td>Name</td>"
+ "<td align=\"right\">Size</td>"
+ "</tr>\n</thead>\n<tbody>\n", fp);
if (!git_commit_lookup(&commit, repo, id) &&
!git_commit_tree(&tree, commit))
ret = writefilestree(fp, tree, "");
- fputs("</tbody></table></div>", fp);
+ fputs("</tbody>\n</table>\n", fp);
git_commit_free(commit);
git_tree_free(tree);
@@ -1097,19 +1099,18 @@ int writerefs(FILE *fp)
for (i = 0, j = 0, count = 0; i < refcount; i++) {
if (j == 0 && git_reference_is_tag(ris[i].ref)) {
- if (count)
- fputs("</tbody></table></div><br/>\n", fp);
+ if (count) fputs("</tbody>\n</table>\n<br/>\n", fp);
count = 0;
j = 1;
}
/* print header if it has an entry (first). */
if (++count == 1) {
- fprintf(fp, "<h2>%s</h2><div class=\"table-container\"><table id=\"%s\">"
- "<thead>\n<tr><td><b>Name</b></td>"
- "<td><b>Last commit date</b></td>"
- "<td><b>Author</b></td>\n</tr>\n"
- "</thead><tbody>\n",
+ fprintf(fp, "<h2>%s</h2>\n<table id=\"%s\">\n"
+ "<thead>\n<tr><td>Name</td>"
+ "<td>Last commit date</td>"
+ "<td>Author</td>\n</tr>\n"
+ "</thead>\n<tbody>\n",
titles[j], ids[j]);
}
@@ -1119,8 +1120,13 @@ int writerefs(FILE *fp)
fputs("<tr><td>", fp);
xmlencode(fp, s, strlen(s));
fputs("</td><td>", fp);
- if (ci->author)
- printtimeshort(fp, &(ci->author->when));
+ if (ci->author) {
+ fputs("<time datetime=\"", fp);
+ formattime(fp, "%Y-%m-%d %H:%M", &(ci->author->when));
+ fputs("\">", fp);
+ formattime(fp, "%d/%m/%Y %H:%M", &(ci->author->when));
+ fputs("</time>\n", fp);
+ }
fputs("</td><td>", fp);
if (ci->author)
xmlencode(fp, ci->author->name, strlen(ci->author->name));
@@ -1316,14 +1322,10 @@ int main(int argc, char *argv[])
mkdir("commit", S_IRWXU | S_IRWXG | S_IRWXO);
writeheader(fp, "Log");
fputs("</ul>\n", fp);
- fputs("<div class=\"table-container\"><table id=\"log\"><thead>\n<tr><td><b>Date</b></td>"
- "<td><b>Commit message</b></td>"
- "<td><b>Author</b></td><td class=\"num\" align=\"right\"><b>Files</b></td>"
- "<td class=\"num\" align=\"right\"><b>+</b></td>"
- "<td class=\"num\" align=\"right\"><b>-</b></td></tr>\n</thead><tbody>\n", fp);
+ fputs("<div class=\"article-list\">\n", fp);
if (cachefile && head) {
- /* read from cache file (does not need to exist) */
+ /* Read from cache file (does not need to exist) */
if ((rcachefp = fopen(cachefile, "r"))) {
if (!fgets(lastoidstr, sizeof(lastoidstr), rcachefp))
errx(1, "%s: no object id", cachefile);
@@ -1331,12 +1333,12 @@ int main(int argc, char *argv[])
errx(1, "%s: invalid object id", cachefile);
}
- /* write log to (temporary) cache */
+ /* Write log to (temporary) cache */
if ((fd = mkstemp(tmppath)) == -1)
err(1, "mkstemp");
if (!(wcachefp = fdopen(fd, "w")))
err(1, "fdopen: '%s'", tmppath);
- /* write last commit id (HEAD) */
+ /* Write last commit id (HEAD) */
git_oid_tostr(buf, sizeof(buf), head);
fprintf(wcachefp, "%s\n", buf);