use relative url in header, escape name and description too
1 files changed, 40 insertions(+), 33 deletions(-) | |||
---|---|---|---|
M | urmoms.c | +40 | -33 |
1@@ -111,39 +111,6 @@ err:
2 return NULL;
3 }
4
5-int
6-writeheader(FILE *fp)
7-{
8- fputs("<!DOCTYPE HTML>"
9- "<html dir=\"ltr\" lang=\"en\">\n<head>\n"
10- "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
11- "<meta http-equiv=\"Content-Language\" content=\"en\" />\n", fp);
12- fprintf(fp, "<title>%s%s%s</title>\n", name, description[0] ? " - " : "", description);
13- fprintf(fp, "<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", relpath);
14- fprintf(fp, "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"%s Atom Feed\" href=\"%satom.xml\" />\n",
15- name, relpath);
16- fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath);
17- fputs("</head>\n<body>\n\n", fp);
18- fprintf(fp, "<table><tr><td><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></td>"
19- "<td><h1>%s</h1><span class=\"desc\">%s</span></td></tr><tr><td></td><td>\n",
20- relpath, name, description);
21- fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
22- fprintf(fp, "<a href=\"%sfiles.html\">Files</a>", relpath);
23- if (hasreadme)
24- fprintf(fp, " | <a href=\"%sfile/README.html\">README</a>", relpath);
25- if (haslicense)
26- fprintf(fp, " | <a href=\"%sfile/LICENSE.html\">LICENSE</a>", relpath);
27- fputs("</td></tr></table>\n<hr/><div id=\"content\">\n", fp);
28-
29- return 0;
30-}
31-
32-int
33-writefooter(FILE *fp)
34-{
35- return !fputs("</div></body>\n</html>", fp);
36-}
37-
38 FILE *
39 efopen(const char *name, const char *flags)
40 {
41@@ -244,6 +211,46 @@ printtimeshort(FILE *fp, const git_time *intime)
42 printtimeformat(fp, intime, "%Y-%m-%d %H:%M");
43 }
44
45+int
46+writeheader(FILE *fp)
47+{
48+ fputs("<!DOCTYPE HTML>"
49+ "<html dir=\"ltr\" lang=\"en\">\n<head>\n"
50+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
51+ "<meta http-equiv=\"Content-Language\" content=\"en\" />\n<title>", fp);
52+ xmlencode(fp, name, strlen(name));
53+ if (description[0])
54+ fputs(" - ", fp);
55+ xmlencode(fp, description, strlen(description));
56+ fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", relpath);
57+ fprintf(fp, "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"%s Atom Feed\" href=\"%satom.xml\" />\n",
58+ name, relpath);
59+ fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath);
60+ fputs("</head>\n<body>\n\n<table><tr><td>", fp);
61+ fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>",
62+ relpath, relpath);
63+ fputs("</td><td><h1>", fp);
64+ xmlencode(fp, name, strlen(name));
65+ fputs("</h1><span class=\"desc\">", fp);
66+ xmlencode(fp, description, strlen(description));
67+ fputs("</span></td></tr><tr><td></td><td>\n", fp);
68+ fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
69+ fprintf(fp, "<a href=\"%sfiles.html\">Files</a>", relpath);
70+ if (hasreadme)
71+ fprintf(fp, " | <a href=\"%sfile/README.html\">README</a>", relpath);
72+ if (haslicense)
73+ fprintf(fp, " | <a href=\"%sfile/LICENSE.html\">LICENSE</a>", relpath);
74+ fputs("</td></tr></table>\n<hr/><div id=\"content\">\n", fp);
75+
76+ return 0;
77+}
78+
79+int
80+writefooter(FILE *fp)
81+{
82+ return !fputs("</div></body>\n</html>", fp);
83+}
84+
85 void
86 writeblobhtml(FILE *fp, const git_blob *blob)
87 {