From 80941742cb07b22611f4ca26ba1e4749ebccf55d Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Tue, 27 Dec 2022 06:59:06 +0000 Subject: [PATCH] implemented namespace searching --- LICENSE | 1 + example_create.sh | 38 +++++++++++++++++++++----------------- stagit-index.c | 12 +++++++----- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/LICENSE b/LICENSE index 1b58029..9b253a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT/X Consortium License (c) 2015-2022 Hiltjo Posthuma +(c) 2022 Georgios Atheridis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/example_create.sh b/example_create.sh index 24bcec5..a9e1ccc 100755 --- a/example_create.sh +++ b/example_create.sh @@ -16,28 +16,32 @@ # - 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 diff --git a/stagit-index.c b/stagit-index.c index 30cbe87..223756c 100644 --- a/stagit-index.c +++ b/stagit-index.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -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("", 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"); -- 2.30.2