From 362577ba1fb7a0b538717f3c25e4d3659eb423ae Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sun, 18 Apr 2021 13:21:54 -0400 Subject: [PATCH] Add desc file and fix table madness --- man/stagit-index.1 | 2 ++ resources/style.css | 19 +++++++++++-------- src/stagit-index.c | 36 ++++++++++++++++++++++++++++++++---- src/stagit.c | 17 ++++++++--------- 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 +#ifdef HAS_CMARK +#include +#endif + #include "cp.h" static git_repository *repo; @@ -75,11 +79,35 @@ writeheader(char *path) fprintf(fp, "\n\n", relpath); fprintf(fp, "\n", relpath); fputs("\n\n", fp); - fprintf(fp, "\n\n" - "\n" + "

", relpath); xmlencode(fp, description, strlen(description)); - fputs("

\n
\"\"

", relpath); + fprintf(fp, "

\n" - "
\n
\n
\n" + fputs("\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("

\n", fp); + while (c != EOF) { + fprintf(fp, &c, relpath); + c = fgetc(longdesc); + } +#endif + } + fclose(longdesc); + + fputs("

\n
\n
\n" "\n" "" "" 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, "\n", relpath); fprintf(fp, "\n", relpath); - fputs("\n\n
NameDescriptionOwnerLast commit
", fp); + fputs("

", fp); if (cloneurl[0]) { - fputs("", fp); + fputs("

", fp); } - fputs("
", fp); - fprintf(fp, "\"Home\"", + fputs("\n\n", fp); + fprintf(fp, "\"\"", relpath, relpath); - fputs("

", fp); + fputs("

", fp); xmlencode(fp, strippedname, strlen(strippedname)); - fputs("

", fp); + fputs("

", fp); xmlencode(fp, description, strlen(description)); - fputs("

git clone git clone ", fp); xmlencode(fp, cloneurl, strlen(cloneurl)); - fputs("
\n", fp); fprintf(fp, "Log | ", relpath); fprintf(fp, "Files | ", relpath); fprintf(fp, "Refs", relpath); @@ -417,7 +416,7 @@ writeheader(FILE *fp, const char *title) relpath, license); fprintf(fp, " | Download", relpath, strippedname); - fputs("
\n
\n
\n", fp); + fputs("
\n
\n", fp); } void -- 2.39.2