summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-04-18 13:21:54 -0400
committerArmaan Bhojwani <me@armaanb.net>2021-04-18 13:21:54 -0400
commit362577ba1fb7a0b538717f3c25e4d3659eb423ae (patch)
treeb4c47fcd2191beee77e0f693d58d73cc5f888783
parent1ce89a949a7373ffcf214539572c33afb9d7b247 (diff)
downloadstagit-362577ba1fb7a0b538717f3c25e4d3659eb423ae.tar.gz
Add desc file and fix table madness
-rw-r--r--man/stagit-index.12
-rw-r--r--resources/style.css19
-rw-r--r--src/stagit-index.c36
-rw-r--r--src/stagit.c17
4 files changed, 53 insertions, 21 deletions
diff --git a/man/stagit-index.1 b/man/stagit-index.1
index 5a55a47..ed7239f 100644
--- a/man/stagit-index.1
+++ b/man/stagit-index.1
@@ -33,6 +33,8 @@ For changing the style of the page you can use the following files:
favicon image.
.It logo.png
32x32 logo.
+.It desc, desc.md
+A plaintext or markdown description to include on the index.
.It style.css
CSS stylesheet.
.El
diff --git a/resources/style.css b/resources/style.css
index b597cb7..10b5cdf 100644
--- a/resources/style.css
+++ b/resources/style.css
@@ -70,6 +70,7 @@ table td {
.desc {
color: #555;
+ margin: 0.5em 0;
}
hr {
@@ -100,17 +101,19 @@ pre a.d:hover {
text-decoration: none;
}
-.url td:nth-child(2) {
- padding-top: 0.2em;
- padding-bottom: 0.9em;
-}
-
-.url td:nth-child(2) span {
- padding: 1px 5px;
+.clone {
+ padding: 0.25em 0.5em;
border: 1px solid #555;
border-radius: 5px;
+ width: max-content;
+ margin: 0.5em 0;
}
-.url td:nth-child(2) span a {
+.clone a {
color: #555;
}
+
+.logo {
+ float: left;
+ padding-right: 1em;
+}
diff --git a/src/stagit-index.c b/src/stagit-index.c
index 5454edb..bad91d1 100644
--- a/src/stagit-index.c
+++ b/src/stagit-index.c
@@ -8,6 +8,10 @@
#include <git2.h>
+#ifdef HAS_CMARK
+#include <cmark-gfm.h>
+#endif
+
#include "cp.h"
static git_repository *repo;
@@ -75,11 +79,35 @@ writeheader(char *path)
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);
fputs("</head>\n<body>\n", fp);
- fprintf(fp, "<table>\n<tr><td><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></td>\n"
- "<td><h1>", relpath);
+ fprintf(fp, "<img src=\"%slogo.png\" class=\"logo\" width=\"32\" height=\"32\" /></td>\n"
+ "<h1>", relpath);
xmlencode(fp, description, strlen(description));
- fputs("</h1></td></tr><tr><td></td><td>\n"
- "</td></tr>\n</table>\n<hr/>\n<div id=\"content\">\n"
+ fputs("</h1>\n", fp);
+
+ FILE *longdesc = fopen("desc.md", "r");
+ if (longdesc == NULL) longdesc = fopen("desc", "r");
+ if (longdesc != NULL) {
+ char c = fgetc(longdesc);
+#ifdef HAS_CMARK
+ char buf[2048];
+ while (c != EOF) {
+ strncat(buf, &c, 1);
+ c = fgetc(longdesc);
+ }
+ char *md = cmark_markdown_to_html(buf, strlen(buf), CMARK_OPT_DEFAULT);
+ fprintf(fp, md, relpath);
+ free(md);
+#else
+ fputs("<p>\n", fp);
+ while (c != EOF) {
+ fprintf(fp, &c, relpath);
+ c = fgetc(longdesc);
+ }
+#endif
+ }
+ fclose(longdesc);
+
+ fputs("</p>\n<hr/>\n<div id=\"content\">\n"
"<table id=\"index\"><thead>\n"
"<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Owner</b></td>"
"<td><b>Last commit</b></td></tr>"
diff --git a/src/stagit.c b/src/stagit.c
index 77191d5..c43c717 100644
--- a/src/stagit.c
+++ b/src/stagit.c
@@ -387,22 +387,21 @@ writeheader(FILE *fp, const char *title)
name, relpath);
fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath);
fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%ssyntax.css\" />\n", relpath);
- fputs("</head>\n<body>\n<table><tr><td>", fp);
- fprintf(fp, "<a href=\"../%s\"><img alt=\"Home\" src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>",
+ fputs("</head>\n<body>\n", fp);
+ fprintf(fp, "<a href=\"../%s\"><img class=\"logo\" src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>",
relpath, relpath);
- fputs("</td><td><h1>", fp);
+ fputs("<h1>", fp);
xmlencode(fp, strippedname, strlen(strippedname));
- fputs("</h1></td></tr><tr><td></td><td><span class=\"desc\">", fp);
+ fputs("</h1><p class=\"desc\">", fp);
xmlencode(fp, description, strlen(description));
- fputs("</span></td></tr>", fp);
+ fputs("</p>", fp);
if (cloneurl[0]) {
- fputs("<tr class=\"url\"><td></td><td><span class=\"clone\">git clone <a href=\"", fp);
+ fputs("<p class=\"clone\">git clone <a href=\"", fp);
xmlencode(fp, cloneurl, strlen(cloneurl));
fputs("\">", fp);
xmlencode(fp, cloneurl, strlen(cloneurl));
- fputs("</a></span></td></tr>", fp);
+ fputs("</a></p>", fp);
}
- fputs("<tr><td></td><td>\n", fp);
fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath);
@@ -417,7 +416,7 @@ writeheader(FILE *fp, const char *title)
relpath, license);
fprintf(fp, " | <a href=\"%s%s.tar.gz\">Download</a>",
relpath, strippedname);
- fputs("</td></tr></table>\n<hr/>\n<div id=\"content\">\n", fp);
+ fputs("<hr/>\n<div id=\"content\">\n", fp);
}
void