commit 4c951975e551f13ecb1be9cd0a1aca166d71597e Author: deepend Date: Mon Dec 2 00:38:51 2019 -0700 Initial commit. diff --git a/README.md b/README.md new file mode 100644 index 0000000..292c7b1 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Recently-Updated Page Shell Scripts + +As soon as [~ford](http://tilde.club/~ford) granted me entrance to tilde.Club, I knew that I wanted to keep tabs on what cool things folks were doing there. And thinking back to the mid-90s, what was the best way to know what was new on a site? A recently-updated page! So I set about making one for tilde.club. + +There's no question at all that this is a rudimentary hack, but it's the *exact* sort of hack that was The Way To Do Things on the mid-90s Internet. (Note that that's the mid-90s-capital-I-Internet, not the [21st-century-lowercase-i-internet](http://www.nytimes.com/2002/12/29/weekinreview/29SCHW.html).) And I'm using tried-and-true command-line Unix filesystem commands to grab, parse, and sort the list of pages, so I feel like I'm treading in the footsteps of thousands before me. The result is [the list of all tilde.club pages updated in the last 24 hours](http://tilde.club/~delfuego/tilde.24h.html), which is generated from the ```findmod.sh``` shell script once a minute from a crontab job. + +Of course, while the HTML version of the recently-updated list is firmly mid-90s (well, if you view source you'll see that it's 21st-century HTML5, but still), enabling cooler 21st-century functionality required making the same list available in a more easily-parsed format. Enter JSON, and the [API version of the recently-updated list](http://tilde.club/~delfuego/tilde.24h.json), generated by the ```findmod-json.sh``` shell script once a minute via crontab as well. + +Hope these are useful to someone! + +Jason Levine, aka [~delfuego](http://tilde.club/~delfuego) + + +# Recently-Updated Page Perl Script + +`findmod2.pl` is a pure-Perl5 reimplementation of ~delfuego's scripts. +It's self-contained, readable, well-documented and will search a +user's entire `public_html` subtree for the most recent file rather +than just using the date of the `index.html` file. + +It accepts the following command-lines options: + +* --domain *name* -- Domain name for the site. Guesses if omitted. +* --root *url* -- Root URL to use in links. Derived from domain by default. +* --since-hours *hours* -- Number of hours considered recent. Default = 24. +* --destdir *path* -- Destination directory for output files. +* --update-every *seconds* -- Regenerate the lists every *seconds*. +* --verbose -- Print more information as the program runs. +* --help -- Print a simple help message and exit. + +If `--update-every` is given with a positive number, `findmod2.pl` +will loop forever, waiting the given number of seconds before +rescanning and regenerating the list. Otherwise, it will scan once +and exit. + +The output files are named `tilde.XXh.json` and `tilde.XXh.html`, +where *XX* is replaced by number of hours considered recent (24 or the +argument given with `--since-hours`). + +Chris Reuter, [~suetanvil](http://totallynuclear.club/~suetanvil). + diff --git a/findmod-json.sh b/findmod-json.sh new file mode 100755 index 0000000..d047dc8 --- /dev/null +++ b/findmod-json.sh @@ -0,0 +1,2 @@ +#!/bin/bash +find /home/*/public_html -regex "/home/\_?[0-9a-zA-Z]*/public_html/index.html" -type f -name "index.html" -mtime 0 -printf '%T@ %p %TD %Tr %TY-%Tm-%TdT%TTZ\n' 2> /dev/null | sort -r | perl -CSD -pe 'BEGIN { print "{ \"pagelist\": [ \n"; }; END { print "] }\n"; }; if ($i > 0) { print ", "; }; s|([0-9\.]+) /home/([\p{L}\p{N}_]*?)/public_html/index.html (.*) (.*)|{ "username": "$2", "homepage": "http://tilde.club/~$2/", "modtime": "$4" }|; $i++' diff --git a/findmod.sh b/findmod.sh new file mode 100755 index 0000000..8732e02 --- /dev/null +++ b/findmod.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cat /usr/share/nginx/html/header1.php +find /home/*/public_html -regex "/home/\_?[0-9a-zA-Z]*/public_html/index.html" -type f -name "index.html" -mtime 0 -printf '%T@ %p %TD %Tr %TY-%Tm-%TdT%TTZ\n' 2> /dev/null | sort -r | perl -CSD -pe 's|([0-9\.]+) /home/([\p{L}\p{N}_]*?)/public_html/index.html (.*) (.*)|
  • $2
  • |' +cat /usr/share/nginx/html/footer.php diff --git a/make-recentlyupdated-html.sh b/make-recentlyupdated-html.sh new file mode 100755 index 0000000..ff818ef --- /dev/null +++ b/make-recentlyupdated-html.sh @@ -0,0 +1,4 @@ +#!/bin/bash +/usr/share/nginx/bin/findmod.sh > /usr/share/nginx/html/tilde.24h.php.tmp +ln -f /usr/share/nginx/html/tilde.24h.php.tmp /usr/share/nginx/html/tilde.24h.php +rm /usr/share/nginx/html/tilde.24h.php.tmp diff --git a/make-recentlyupdated-json.sh b/make-recentlyupdated-json.sh new file mode 100755 index 0000000..8e81446 --- /dev/null +++ b/make-recentlyupdated-json.sh @@ -0,0 +1,4 @@ +#!/bin/bash +/usr/share/nginx/bin/findmod-json.sh > /usr/share/nginx/html/tilde.24h.json.tmp +ln -f /usr/share/nginx/html/tilde.24h.json.tmp /usr/share/nginx/html/tilde.24h.json +rm /usr/share/nginx/html/tilde.24h.json.tmp