diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-10-16 18:44:00 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-10-16 18:44:00 -0400 |
| commit | ab5be5bcdca38952de7e3dac383828faaf6b03a8 (patch) | |
| tree | a60a70aef9caf05f7db3dfa1cbc57d28cfc28eef | |
| parent | 5244276a0d17b6e0de14f028f7ae7be43fa19cc6 (diff) | |
| download | greypool-ab5be5bcdca38952de7e3dac383828faaf6b03a8.tar.gz | |
Add rudimentary HTML styling, fix a couple of bugs.
| -rwxr-xr-x | greypool | 65 |
1 files changed, 52 insertions, 13 deletions
@@ -28,6 +28,12 @@ $VERSION = "0.0.0"; $verbose = $force_download = $html = 0; $stamp = strftime("%Y%m%d", localtime); +# defaults for HTML colors +$fg_color = 'ffffff'; +$bg_color = '000000'; +$old_color = 'ff0000'; +$new_color = '00ff00'; + # all the parsed data gets shoved in here. # keys are visiblename of each project. # values are another hash, with keys projname (repology's name for @@ -137,14 +143,16 @@ sub get_repo_list { 'https://repology.org/repositories/statistics' . '|'; fatal "failed to run wget: $!\n" unless $f; + my $ok = 0; while(<$f>) { + $ok = 1; if(m,<a\s*href="/repository/([^"/]+)">([^<]+)</a>,) { $repo_list{$1} = $2; } } - my $status = close $f; - if($status) { - fatal "wget failed, exit status " . ($status >> 8); + close $f; + if(!$ok) { + warning "couldn't get repo list from repology.org"; } } @@ -231,7 +239,7 @@ repo $repo # Optional: List any bad versions of packages you don't want to update # to here. One line per package, multiple versions per line allowed. -#mask srecord 1.65 +#mask srecord 1.65.0 # Optional: Format string for package URLs. These are the "local" package # names (what your repository calls them, not repology's name). @@ -239,13 +247,25 @@ repo $repo # If this is not set, the package names won't by clickable links. # NOTE: For SlackBuilds.org, the URL *must* end in a trailing slash! $pfmt + +# Optional: Colors for the HTML output. 4 of them, in order: +# background text new-version old-version +# These are hex RGB triplets, but *don't* precede them with a # +# because that would be taken as a comment. +htmlcolors $bg_color $fg_color $new_color $old_color EOF - $yn = prompt("Config file created. Check package status now", "Y"); - unless($yn =~ /^\s*y/i) { - print "\nOK. Run $SELF again when you're ready to check package status.\n"; - exit 0; + close $f; + print "Config file created. Re-run to check package status.\n"; + exit 0; +} + +sub parse_html_colors { + my @colors = split /\s+/, $_[0]; + if(@colors != 4) { + fatal "$config_file:$.: htmlcolors needs exactly 4 color values"; } + ($bg_color, $fg_color, $new_color, $old_color) = @colors; } sub parse_mask { @@ -277,6 +297,7 @@ sub read_config_file { /pkgurl/ && do { $ok++; $pkgurl = $val; }; /ignore/ && do { $ok++; $ignore{$_}++ for split /\s+/, $val; }; /mask/ && do { $ok++; parse_mask($val); }; + /htmlcolors/ && do { $ok++; parse_html_colors($val) }; fatal "$config_file line $. malformed (unknown key '$_')" unless $ok; } } @@ -491,9 +512,26 @@ sub generate_report { sub print_report_header { return if $csv_output; return if $html_frag; - print "<html><head><title>\n" if $html; + if($html) { + print <<EOF; +<html> +<head> +<meta name="Generator" content="$SELF/$VERSION"> +<style> +body { color: #$fg_color; background-color: #$bg_color; } +a { text-decoration: none;} +a:link { color: #$fg_color } +a:visited { color: #$fg_color } +a:hover { color: #$new_color } +.name { color: #$fg_color; } +.oldver { color: #$old_color; } +.newver { color: #$new_color; } +</style> +<title> +EOF + } print "Repology status report for $email ($repo repository)\n\n"; - print "</title></head>\n<body>\n" if $html; + print "</title>\n</head>\n<body>\n" if $html; } sub print_empty_report { @@ -504,7 +542,7 @@ sub print_empty_report { sub print_table_start { if($html) { print "Repology status report for $email ($repo repository)<p />\n"; - print "<table><tr><th>Package</th><th>Version</th><th>Newest Version</th></tr>\n"; + print "<table><tr><th>Package</th><th>Repology Link</th><th>Version</th><th>Newest Version</th></tr>\n"; } elsif($csv_output) { print "Package,RepologyName,Version,Newest\n"; } else { @@ -532,7 +570,7 @@ sub print_report_line { $nlink = $name; } my $pnlink = "<a href=\"https://repology.org/project/$projname/versions\">$projname</a>"; - print "<tr><td>$nlink => $pnlink</td><td>$oldver</td><td>$newver</td></tr>\n"; + print "<tr><td class=\"name\">$nlink</td><td class=\"name\">$pnlink</td><td class=\"oldver\">$oldver</td><td class=\"newver\">$newver</td></tr>\n"; } elsif($csv_output) { print "$name,$projname,$oldver,$newver\n"; } else { @@ -582,8 +620,9 @@ sub colorize { ### main() parse_opts(); -read_config_file(); +mkdir_p($privdir); create_wgetrc(); +read_config_file(); check_cache(); generate_report(); stamp_cache(); |
