#include <git2.h>
+#include "cp.h"
+
static git_repository *repo;
static const char *relpath = "";
}
void
-writeheader(FILE *fp)
+writeheader(char *path)
{
+ FILE *fp = fopen(path, "w");
fputs("<!DOCTYPE html>\n"
"<html>\n<head>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
"<title>", fp);
xmlencode(fp, description, strlen(description));
fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", relpath);
- fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath);
+ fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.min.css\" />\n", relpath);
fputs("</head>\n<body>\n", fp);
fprintf(fp, "<table>\n<tr><td><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></td>\n"
"<td><span class=\"desc\">", relpath);
"<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Owner</b></td>"
"<td><b>Last commit</b></td></tr>"
"</thead><tbody>\n", fp);
+ fclose(fp);
}
void
-writefooter(FILE *fp)
+writefooter(char *path)
{
+ FILE *fp = fopen(path, "a");
fputs("</tbody>\n</table>\n</div>\n</body>\n</html>\n", fp);
+ fclose(fp);
}
int
-writelog(FILE *fp)
+writelog(char *path)
{
+ FILE *fp = fopen(path, "a");
git_commit *commit = NULL;
const git_signature *author;
git_revwalk *w = NULL;
err:
git_revwalk_free(w);
free(stripped_name);
+ fclose(fp);
return ret;
}
err(1, "pledge");
#endif
- writeheader(stdout);
+ writeheader("index.html");
for (i = 1; i < argc; i++) {
repodir = argv[i];
owner[strcspn(owner, "\n")] = '\0';
fclose(fp);
}
- writelog(stdout);
+ writelog("index.html");
}
- writefooter(stdout);
+ writefooter("index.html");
+
+ /* copy css */
+ char cwd[PATH_MAX];
+ strcpy(cwd, getcwd(cwd, sizeof(cwd)));
+ cp("/usr/local/share/stagit/style.min.css", strcat(cwd, "/style.min.css"));
/* cleanup */
git_repository_free(repo);