implemented namespace searching
authorGeorgios Atheridis <georgios@atheridis.org>
Tue, 27 Dec 2022 06:59:06 +0000 (06:59 +0000)
committerGeorgios Atheridis <georgios@atheridis.org>
Tue, 27 Dec 2022 06:59:06 +0000 (06:59 +0000)
LICENSE
example_create.sh
stagit-index.c

diff --git a/LICENSE b/LICENSE
index 1b58029ebb69d4119920101f0ef9367c20879815..9b253a9d5e9a1fd96c9179020374112c89354f72 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,7 @@
 MIT/X Consortium License
 
 (c) 2015-2022 Hiltjo Posthuma <hiltjo@codemadness.org>
+(c) 2022 Georgios Atheridis <georgios@atheridis.org>
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
index 24bcec5af3f6cd639cb446594bd0111151d23602..a9e1ccce7e38605865675f0df5f9840492a2ccc1 100755 (executable)
 # - sh example_create.sh
 
 # path must be absolute.
-reposdir="/var/www/domains/git.codemadness.nl/home/src"
-curdir="$(pwd)"
+reposdir="/home/git"
+curdir="/var/www/git.atheridis.org"
 
 # make index.
-stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
+stagit-index "${reposdir}/"*/* > "${curdir}/index.html"
 
 # make files per repo.
-for dir in "${reposdir}/"*/; do
-       # strip .git suffix.
-       r=$(basename "${dir}")
-       d=$(basename "${dir}" ".git")
-       printf "%s... " "${d}"
+for namespace in "${reposdir}/"*/; do
+        n=$(basename "${namespace}")
+        for repo in "$namespace"*; do
+                r=$(basename "${repo}")
 
-       mkdir -p "${curdir}/${d}"
-       cd "${curdir}/${d}" || continue
-       stagit -c ".cache" -u "https://git.codemadness.nl/$d/" "${reposdir}/${r}"
+                # strip .git suffix.
+                d=$(basename "${repo}" ".git")
+                printf "%s... " "${d}"
 
-       # symlinks
-       ln -sf log.html index.html
-       ln -sf ../style.css style.css
-       ln -sf ../logo.png logo.png
-       ln -sf ../favicon.png favicon.png
+                mkdir -p "${curdir}/${n}/${d}"
+                cd "${curdir}/${n}/${d}" || continue
+                stagit -c ".cache" -u "https://git.atheridis.org/$n/$d/" "${reposdir}/${n}/${r}"
 
-       echo "done"
+                # symlinks
+                ln -sf log.html index.html
+                ln -sf $curdir/style.css style.css
+                ln -sf $curdir/logo.png logo.png
+                ln -sf $curdir/favicon.png favicon.png
+
+                echo "done"
+        done
 done
index 30cbe8701ee244c6f30b53ca203a2029d521837b..223756c4f9a911efb73eb49266096ac24384b32d 100644 (file)
@@ -1,4 +1,5 @@
 #include <err.h>
+#include <libgen.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -13,6 +14,7 @@ static git_repository *repo;
 static const char *relpath = "";
 
 static char description[255] = "Repositories";
+static char *namespace = "";
 static char *name = "";
 static char owner[255];
 
@@ -152,6 +154,8 @@ writelog(FILE *fp)
                        *p = '\0';
 
        fputs("<tr><td><a href=\"", fp);
+       percentencode(fp, namespace, strlen(namespace));
+       fputs("/", fp);
        percentencode(fp, stripped_name, strlen(stripped_name));
        fputs("/log.html\">", fp);
        xmlencode(fp, stripped_name, strlen(stripped_name));
@@ -212,11 +216,9 @@ main(int argc, char *argv[])
                        continue;
                }
 
-               /* use directory name as name */
-               if ((name = strrchr(repodirabs, '/')))
-                       name++;
-               else
-                       name = "";
+               /* use directory name as name and namespace*/
+        name = basename(repodirabs);
+        namespace = basename(dirname(repodirabs));
 
                /* read description or .git/description */
                joinpath(path, sizeof(path), repodir, "description");