commit: 76a439bd5f6087866c456f277794be5903f3fc03
parent 3b2b05378fddf7bab07308f09cdf47a4aa78a0f3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 14 Mar 2023 13:14:32 +0100
notes_index.pm: Use git-ls-tree instead of File::Find
Diffstat:
2 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/notes/index.xhtml b/notes/index.xhtml
@@ -25,7 +25,6 @@
<tr><td><a href="ciphers.txt">ciphers.txt</a></td><td data-value="717" data-type="int">717 B</td><td>2018-09-13 11:34:17 +0200</td></tr>
<tr><td><a href="cloudchaser-issues">cloudchaser-issues</a></td><td data-value="3754" data-type="int">3 754 B</td><td>2023-02-12 20:27:12 +0100</td></tr>
<tr><td><a href="computing-truths.txt">computing-truths.txt</a></td><td data-value="7363" data-type="int">7 363 B</td><td>2021-04-29 01:33:38 +0200</td></tr>
- <tr><td><a href="copyright-assignment.txt">copyright-assignment.txt</a></td><td data-value="409" data-type="int">409 B</td><td></td></tr>
<tr><td><a href="drivers">drivers</a></td><td data-value="3549" data-type="int">3 549 B</td><td>2020-07-08 04:21:23 +0200</td></tr>
<tr><td><a href="editors">editors</a></td><td data-value="1353" data-type="int">1 353 B</td><td>2020-07-08 04:21:23 +0200</td></tr>
<tr><td><a href="feeds">feeds</a></td><td data-value="1023" data-type="int">1 023 B</td><td>2020-07-08 04:21:23 +0200</td></tr>
@@ -36,11 +35,9 @@
<tr><td><a href="license-pick">license-pick</a></td><td data-value="3849" data-type="int">3 849 B</td><td>2023-01-10 04:23:21 +0100</td></tr>
<tr><td><a href="minitel2.txt">minitel2.txt</a></td><td data-value="542" data-type="int">542 B</td><td>2023-03-02 18:30:28 +0100</td></tr>
<tr><td><a href="new-install-checklist">new-install-checklist</a></td><td data-value="1246" data-type="int">1 246 B</td><td>2020-05-22 11:33:33 +0200</td></tr>
- <tr><td><a href="npm.txt">npm.txt</a></td><td data-value="127" data-type="int">127 B</td><td></td></tr>
<tr><td><a href="oric-atmos">oric-atmos</a></td><td data-value="1340" data-type="int">1 340 B</td><td>2021-04-12 19:13:09 +0200</td></tr>
<tr><td><a href="osu%21">osu!</a></td><td data-value="1360" data-type="int">1 360 B</td><td>2020-07-08 04:21:23 +0200</td></tr>
<tr><td><a href="petitions">petitions</a></td><td data-value="1510" data-type="int">1 510 B</td><td>2022-03-02 22:39:07 +0100</td></tr>
- <tr><td><a href="programming-languages.txt">programming-languages.txt</a></td><td data-value="1677" data-type="int">1 677 B</td><td></td></tr>
<tr><td><a href="pure-wayland">pure-wayland</a></td><td data-value="30218" data-type="int">30 218 B</td><td>2022-09-27 00:37:53 +0200</td></tr>
<tr><td><a href="pure_wayland_T495_glewinfo.log">pure_wayland_T495_glewinfo.log</a></td><td data-value="207699" data-type="int">207 699 B</td><td>2021-05-03 14:14:58 +0200</td></tr>
<tr><td><a href="pure_wayland_T495_glinfo.log">pure_wayland_T495_glinfo.log</a></td><td data-value="17747" data-type="int">17 747 B</td><td>2021-05-03 14:14:58 +0200</td></tr>
diff --git a/notes_index.pm b/notes_index.pm
@@ -2,30 +2,9 @@
# Copyright 2023 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
# SPDX-License-Identifier: MIT
-# dev-lang/perl
-use File::Find;
-
# dev-perl/URI
use URI::Escape;
-my @content;
-
-sub wanted {
- my $fn = $File::Find::name;
-
- $fn =~ s@^\./@@;
-
- if ( $fn !~ /^(index.xhtml|\.)$/ ) {
- push @content, $fn;
- }
-
- return;
-}
-
-chdir('./notes/');
-
-find( \&wanted, './' );
-
print '<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -43,8 +22,20 @@ print '<!DOCTYPE html>
<tbody>
';
-foreach ( sort(@content) ) {
- my $raw = $_;
+chdir('./notes/');
+
+my $lstree =
+`git ls-tree -r -z --format="%(objecttype)%x01%(objectsize:padded)%x01%(path)" HEAD`;
+
+my @list = split( /\x00/, $lstree );
+
+foreach (@list) {
+ my ( $objtype, $size, $raw ) = split( /\x01/, $_, 3 );
+ $objtype == "blob" or die "${raw}: objtype is ${objtype}, not blob";
+
+ if ( $raw =~ /^index\.(s|x)html$/ ) {
+ next;
+ }
# try_files $uri $uri.shtml $uri.html $uri.xhtml $uri/ =404;
my $fn = $raw;
@@ -53,10 +44,10 @@ foreach ( sort(@content) ) {
my $escaped = uri_escape_utf8($fn);
$escaped =~ s@%2F@/@;
- my $size = ( lstat($raw) )[7];
-
my $now = `git log -1 --format="format:%ai" -- "$raw"`;
+ $size =~ s/^ *//;
+
# thousand separation
my $size_pp = $size;
while ( $size_pp =~ s/(\d+)(\d{3})/$1 $2/ ) { }