aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2022-04-25 20:22:45 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2022-04-25 20:22:45 +0200
commit3efe4d899370bb4304c92d0a23782f0612947c69 (patch)
tree7a7ba219971378440bef3ce4e47b87b227f9212a
parentcounter update, less retarded and probably opti (diff)
downloadjoe-scripts-3efe4d899370bb4304c92d0a23782f0612947c69.tar.gz
joe-scripts-3efe4d899370bb4304c92d0a23782f0612947c69.tar.bz2
joe-scripts-3efe4d899370bb4304c92d0a23782f0612947c69.tar.xz
joe-scripts-3efe4d899370bb4304c92d0a23782f0612947c69.tar.zst
joe-scripts-3efe4d899370bb4304c92d0a23782f0612947c69.zip
Cleaner
-rwxr-xr-xsrc/cron/gitjoe.pl30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/cron/gitjoe.pl b/src/cron/gitjoe.pl
index 07c8fc4..87d95a2 100755
--- a/src/cron/gitjoe.pl
+++ b/src/cron/gitjoe.pl
@@ -5,14 +5,16 @@ use warnings;
use Term::ANSIColor;
use File::Copy;
use Capture::Tiny;
+
use constant {
+ HOME_DIR => '/usr/home/',
TMP_DIR => '/tmp/gitjoe/',
SITE_DIR => '/usr/local/www/gitjoe/'
};
sub get_repos_index {
my $user = $_[0];
- my $home_dir = '/usr/home/' . $user . '/';
+ my $home_dir = HOME_DIR . $user . '/';
opendir(DIR, $home_dir);
my @repos;
my $i = 0;
@@ -29,7 +31,7 @@ sub get_repos_index {
sub stagit_generate {
my ($user, @repos) = @_;
- my $home_dir = '/usr/home/' . $user . '/';
+ my $home_dir = HOME_DIR . $user . '/';
chdir(TMP_DIR);
mkdir($user . '/', 0755);
my $i = 0;
@@ -45,7 +47,7 @@ sub stagit_generate {
$repos[$i] = $repos[$i] . '.git';
print "Indexing " . colored($user . '/' . $repos[$i], 'bold') . ".\n";
system(
- '/usr/local/bin/stagit',
+ 'stagit',
$home_dir . $repos[$i] . '/'
);
copy('../style.css', './style.css');
@@ -54,30 +56,20 @@ sub stagit_generate {
}
chdir(TMP_DIR . $user . '/');
system(
- '/usr/local/bin/dash',
- '-c',
- '/usr/local/bin/stagit-index ' . $repos_line . '>index.html'
- );
- system(
- '/usr/local/bin/dash',
- '-c',
- "/usr/local/bin/gsed -i 's/<td>" . $user . "<\\/td>/<td class=\"td_author\">" . $user . "<\\/td>/g' index.html"
+ 'stagit-index ' . $repos_line . '>index.html'
);
system(
- '/usr/local/bin/dash',
- '-c',
- "/usr/local/bin/gsed -i 's/<td><span class=\"desc\">Repositories<\\/span><\\/td>/<td><span class=\"desc\"><h1>" . $user . " - Repositories<\\/h1><\\/span><\\/td><\\/tr><tr><td><\\/td><td>Back to <a href=\"https:\\/\\/gitjoe.xyz\\/\">GitJoe<\\/a><\\/td><\\/tr>/' index.html"
+ "sed -i '' -e 's/<td>" . $user . "<\\/td>/<td class=\"td_author\">" . $user . "<\\/td>/g' index.html"
);
system(
- '/usr/local/bin/dash',
- '-c',
- "/usr/local/bin/gsed -i 's/log.html/files.html/g' index.html"
+ "sed -i '' -e 's/<td><span class=\"desc\">Repositories<\\/span><\\/td>/<td><span class=\"desc\"><h1>" . $user . " - Repositories<\\/h1><\\/span><\\/td><\\/tr><tr><td><\\/td><td>Back to <a href=\"https:\\/\\/gitjoe.xyz\\/\">GitJoe<\\/a><\\/td><\\/tr>/' index.html"
);
+ system("sed -i '' -e 's/log.html/files.html/g' index.html");
return;
}
sub main {
- my $home_dir = '/usr/home/';
+ my $home_dir = HOME_DIR;
my @users;
opendir(DIR, $home_dir);
my $i = 0;
@@ -95,7 +87,7 @@ sub main {
stagit_generate($users[$i], @repos);
print "Removing user " . colored($users[$i], 'bold green') . " old directory from " . colored(SITE_DIR, 'bold') . ".\n";
system(
- '/bin/rm',
+ 'rm',
'-rf',
SITE_DIR . $users[$i]
);