commit 3c00e328b546283294871232e65e39b9d2b80041
parent bda0c0dc3edd12eac75e700e98d2b7e2c4b771f2
Author: Armaan Bhojwani <me@armaanb.net>
Date: Mon, 8 Mar 2021 09:11:20 -0500
Use /usr/local/share
Diffstat:
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
@@ -7,6 +7,7 @@ VERSION = 0.9.3
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/man
DOCPREFIX = ${PREFIX}/share/doc/${NAME}
+SHAREPREFIX = ${PREFIX}/share/${NAME}
LIBGIT_INC = -I/usr/local/include
LIBGIT_LIB = -L/usr/local/lib -lgit2
@@ -80,15 +81,17 @@ install: all
for f in ${BIN}; do chmod 755 ${DESTDIR}${PREFIX}/bin/$$f; done
# installing example files.
mkdir -p ${DESTDIR}${DOCPREFIX}
- cp -f style.min.css\
- syntax.css\
- favicon.png\
+ cp -f favicon.png\
logo.png\
example_create.sh\
example_post-receive.sh\
README\
- highlight.py\
${DESTDIR}${DOCPREFIX}
+ mkdir -p ${DESTDIR}${SHAREPREFIX}
+ cp -f style.min.css\
+ syntax.css\
+ highlight.py\
+ ${DESTDIR}${SHAREPREFIX}
# installing manual pages.
mkdir -p ${DESTDIR}${MANPREFIX}/man1
cp -f ${MAN1} ${DESTDIR}${MANPREFIX}/man1
@@ -99,9 +102,9 @@ uninstall:
for f in ${BIN}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done
# removing example files.
rm -f \
- ${DESTDIR}${DOCPREFIX}/style.min.css\
- ${DESTDIR}${DOCPREFIX}/syntax.css\
- ${DESTDIR}${DOCPREFIX}/highlight.py\
+ ${DESTDIR}${SHAREPREFIX}/style.min.css\
+ ${DESTDIR}${SHAREPREFIX}/syntax.css\
+ ${DESTDIR}${SHAREPREFIX}/highlight.py\
${DESTDIR}${DOCPREFIX}/favicon.png\
${DESTDIR}${DOCPREFIX}/logo.png\
${DESTDIR}${DOCPREFIX}/example_create.sh\
diff --git a/highlight.py b/highlight.py
@@ -46,14 +46,15 @@ formatter = HtmlFormatter(
anchorlinenos=True,
)
+outp = ""
if rendered:
- print('<article class="markup markdown">')
- print(rendered)
- print("</article>")
-print('<div id="blob">')
-print(highlight(contents, lexer, formatter))
-print("</div>")
-print('<link rel="stylesheet" href="/syntax.css"')
+ outp += '<article class="markup markdown">'
+ outp += rendered
+ outp += "</article>"
+outp += f'<div id="blob">{highlight(contents, lexer, formatter)}</div>"'
+outp += '<link rel="stylesheet" href="/syntax.css"'
+
+print(outp)
print(f"Filename: {filename}; Lexer: {lexer}.", file=stderr)
diff --git a/requirements.txt b/requirements.txt
@@ -1,4 +1,3 @@
Pygments
markdown
pymdown-extensions
-
diff --git a/stagit.c b/stagit.c
@@ -418,7 +418,7 @@ writefooter(FILE *fp)
}
int
-syntax_highlight(const char *filename, FILE *fp, const char *s, size_t len)
+call_py(const char *filename, FILE *fp, const char *s, size_t len)
{
// Flush HTML-file
fflush(fp);
@@ -428,7 +428,7 @@ syntax_highlight(const char *filename, FILE *fp, const char *s, size_t len)
dup2(fileno(fp), 1);
// Python Pygments script for syntax highlighting.
- FILE *child = popen("/usr/local/share/doc/stagit/highlight.py", "w");
+ FILE *child = popen("/usr/local/share/stagit/highlight.py", "w");
if (child == NULL) {
printf("child is null: %s", strerror(errno));
exit(1);
@@ -458,7 +458,7 @@ writeblobhtml(const char *filename, FILE *fp, const git_blob *blob)
git_off_t len = git_blob_rawsize(blob);
if (len > 0) {
- lc = syntax_highlight(filename, fp, s, len);
+ lc = call_py(filename, fp, s, len);
}
return lc;
@@ -1171,9 +1171,9 @@ main(int argc, char *argv[])
/* copy css */
char cwd[PATH_MAX];
strcpy(cwd, getcwd(cwd, sizeof(cwd)));
- cp("/usr/local/share/doc/stagit/syntax.css", strcat(cwd, "/syntax.css"));
+ cp("/usr/local/share/stagit/syntax.css", strcat(cwd, "/syntax.css"));
strcpy(cwd, getcwd(cwd, sizeof(cwd)));
- cp("/usr/local/share/doc/stagit/style.min.css", strcat(cwd, "/style.min.css"));
+ cp("/usr/local/share/stagit/style.min.css", strcat(cwd, "/style.min.css"));
/* strip .git suffix */
if (!(strippedname = strdup(name)))