commit 507332742b255295849a879a3fb397bbad4819f6
parent 7ab7f07a28a914f53ce31d884d3bff2c6f467e9c
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 29 Jun 2024 12:55:11 +0200
feat: long description via script and form
Diffstat:
3 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/bin/git_create_repo.sh b/bin/git_create_repo.sh
@@ -6,16 +6,18 @@
# $2 - prv/pub
# $3 - repo name
# $4 - description
-# $5 - owner/maintainer
+# $5 - long description
+# $6 - owner/maintainer
# Error out if not all options are given
-if [ -z "$5" ]; then
+if [ -z "$6" ]; then
echo "Usage:
git_create_repo.sh \\
\"/var/www/git.example.git\" \\
\"pub\" \\
\"stagit-jayvii.de\" \\
\"An example repository.\" \\
+ \"A long description for this respoitory.\" \\
\"JayVii\"
"
exit 1;
@@ -51,11 +53,14 @@ git init --bare || exit 1;
# Set default branch to "main"
echo "ref: refs/heads/main" > HEAD
-# Add description
+# Add short description
echo "$4" > description
+# Add long description
+echo "$5" > description_full
+
# Add owner
-echo "$5" > owner
+echo "$6" > owner
# Add Clone URL, if "url" file exists in root directory
if [ -f "${1}/url" ]; then
diff --git a/bin/git_update_repo_html.sh b/bin/git_update_repo_html.sh
@@ -61,7 +61,7 @@ RMENU=$(
sed -e 's/\//\\\//g'
)
-# read template sections
+## read template sections
THEAD=$(
cat "${1}/templates/head.html" | \
sed \
@@ -79,6 +79,22 @@ TMENU=$(
-e "s/<\!--MENU-->/${RMENU}/g"
)
+## if no full description exists, use the repository's readme
+if [ -z "$RDESCF" ]; then
+ # find readme
+ READMEFILE=$(
+ find "${1}/${2}/${3}/file" -type f -name "*README*" | \
+ head -n 1
+ )
+ if [ ! -z "$READMEFILE" ]; then
+ RDESCF=$(
+ grep -E "<a\ href=\"#l[0-9]+\"\ class=\"line\"\ id=\"l[0-9]+\">" \
+ "$READMEFILE" | \
+ sed -E -e 's/^<a\ .*?<\/a>//g'
+ )
+ fi
+fi
+
## Write template
echo "<!DOCTYPE html>
<html>
diff --git a/create_repo/index.php b/create_repo/index.php
@@ -27,6 +27,14 @@ $repo_desc = preg_replace(
rawurldecode($_GET["description"])
);
+// Fetch Repository Full Description
+$repo_desc_full = preg_replace(
+ '/[^a-zA-Z0-9\s\.\,\!\?\:\_\-]/',
+ '',
+ rawurldecode($_GET["description_full"])
+);
+
+
// Fetch Repository Owner
$repo_owner = preg_replace(
'/[^a-zA-Z0-9\s\.\,\!\?\:\_\-]/',
@@ -57,7 +65,7 @@ $repo_owner = preg_replace(
<?php
# check whether all variables are set
- if ($repo_type == "" || $repo_name == "" || $repo_desc == "" || $repo_owner == "") {
+ if ($repo_type == "" || $repo_name == "" || $repo_desc == "" || $repo_desc_full = "" || $repo_owner == "") {
$content = "<p id=\"status\"></p>";
} else {
passthru(
@@ -66,6 +74,7 @@ $repo_owner = preg_replace(
"\"" . $repo_type . "\" " .
"\"" . $repo_name . "\" " .
"\"" . $repo_desc . "\" " .
+ "\"" . $repo_desc_full . "\" " .
"\"" . $repo_owner . "\"",
$response
);
@@ -80,6 +89,8 @@ $repo_owner = preg_replace(
<input type="text" id="name" name="name" maxlength="30" placeholder="my_new_project" default=<?php echo "\"" . $repo_name . "\""; ?> required><br>
<label for="description">Repository Description</label><br>
<input type="text" id="description" name="description" maxlength="100" placeholder="This project is about..." default=<?php echo "\"" . $repo_desc . "\""; ?> required><br>
+ <label for="description_full">Long Description of the Repository</label><br>
+ <textarea id="description_full" name="description_full" style="min-height:150px;" required></textarea><br>
<label for="owner" >Repository Owner</label><br>
<input type="text" id="owner" name="owner" maxlength="30" placeholder="Me" default=<?php echo "\"" . $repo_owner . "\""; ?> required><br>
<label for="type">Repository Type</label><br>