]> git.armaanb.net Git - stagit.git/commitdiff
Copy css in stagit-index
authorArmaan Bhojwani <me@armaanb.net>
Mon, 8 Mar 2021 15:31:42 +0000 (10:31 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 8 Mar 2021 15:31:42 +0000 (10:31 -0500)
src/cp.h [new file with mode: 0644]
src/stagit-index.c
src/stagit.c

diff --git a/src/cp.h b/src/cp.h
new file mode 100644 (file)
index 0000000..1372b5b
--- /dev/null
+++ b/src/cp.h
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int cp(char fileSource[], char fileDestination[])
+{
+    int c;
+    FILE *stream_R, *stream_W; 
+
+    stream_R = fopen(fileSource, "r");
+    if (stream_R == NULL)
+        return -1;
+    stream_W = fopen(fileDestination, "w");   //create and write to file
+    if (stream_W == NULL)
+     {
+        fclose(stream_R);
+        return -2;
+     }    
+    while ((c = fgetc(stream_R)) != EOF)
+        fputc(c, stream_W);
+    fclose(stream_R);
+    fclose(stream_W);
+
+    return 0;
+}
+
index 2b243ec15660ba042313d4317b2d33810f9300a3..fa0c21a86cfc1c6a57d849f6087556ead89e0bc9 100644 (file)
@@ -8,6 +8,8 @@
 
 #include <git2.h>
 
+#include "cp.h"
+
 static git_repository *repo;
 
 static const char *relpath = "";
@@ -69,7 +71,7 @@ writeheader(FILE *fp)
                "<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);
@@ -212,6 +214,11 @@ main(int argc, char *argv[])
        }
        writefooter(stdout);
 
+       /* 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);
        git_libgit2_shutdown();
index 264604eb4fffd984ff7ef47993e7ff0d4b44de84..aa99c7767eff014f68b0ec0477f6e1ac94b83a4c 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <git2.h>
 
+#include "cp.h"
 #include "compat.h"
 
 struct deltainfo {
@@ -70,28 +71,6 @@ static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + NUL byte */
 static FILE *rcachefp, *wcachefp;
 static const char *cachefile;
 
-int cp(char fileSource[], char fileDestination[])
-{
-    int c;
-    FILE *stream_R, *stream_W; 
-
-    stream_R = fopen(fileSource, "r");
-    if (stream_R == NULL)
-        return -1;
-    stream_W = fopen(fileDestination, "w");   //create and write to file
-    if (stream_W == NULL)
-     {
-        fclose(stream_R);
-        return -2;
-     }    
-    while ((c = fgetc(stream_R)) != EOF)
-        fputc(c, stream_W);
-    fclose(stream_R);
-    fclose(stream_W);
-
-    return 0;
-}
-
 void
 joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
 {