? .IcculusFinger_daemon.pl.swo ? .IcculusFinger_daemon.pl.swp ? IcculusFinger_daemon_zakks_edited_for_rss.diff Index: IcculusFinger_daemon.pl =================================================================== RCS file: /cvs/cvsroot/IcculusFinger/IcculusFinger_daemon.pl,v retrieving revision 1.21 diff -u -r1.21 IcculusFinger_daemon.pl --- IcculusFinger_daemon.pl 2002/07/24 14:02:16 1.21 +++ IcculusFinger_daemon.pl 2002/10/29 07:08:23 @@ -280,6 +280,11 @@ # the command line or as a daemon. my $digest_filename = '/webspace/icculus.org/fingerdigest.html'; +# Filename to write finger digest RSS to, "undef" will universally +# disable RSS digest generation, from the daemon or the command line. See +# other notes above. +my $digest_rss_filename = '/webspace/icculus.org/fingerdigest.rss'; + # Set this to a string you want to prepend to the finger digest. If you # aren't planning to include the digest in another webpage via PHP or # whatnot, you should put and tags, etc here. "undef" is @@ -287,6 +292,24 @@ #my $digest_prepend = undef; my $digest_prepend = "<html><head><title>.plan digest\n"; +# Set this to a url you want to set the about to +# for the finger digest RSS about field. Et cetera. +my $digest_rss_about = "http://icculus.org/fingerdigest.rdf" + +# Set this to a title you want for the RSS +my $digest_rss_title = "icculus.org finger digest" + +# Set this to the link you want for the finger digest (note that this +# relates to the RSS file linking to the actual piece of html, not +# itself) +my $digest_rss_url = "http://icculus.org/fingerdigest.html" + +# Set this to the description for the RSS +my $digest_rss_desc = "finger updates from icculus.org users" + +# Set this to the url for the RSS image +my $digest_rss_image = "http://icculus.org/icculus-org-now.png" + # Set this to a string you want to append to the finger digest. If you # aren't planning to include the digest in another webpage via PHP or # whatnot, you should put and tags, etc here. "undef" is @@ -394,7 +417,7 @@ } -sub enumerate_planfiles { +sub enumerate_planfiles {/ my $dirname = (($use_homedir) ? '/home' : $fingerspace); opendir(DIRH, $dirname) or return(undef); my @dirents = readdir(DIRH); @@ -473,6 +496,75 @@ close(DIGESTH); } +#ZWARNING - this is some copy and paste hax job allright, I can't be +# blamed for any exploding GNUs +sub do_rss_digest { + return if not defined $digest_rss_filename + my @plans = enumerate_planfiles(); + if (not @plans) { + syslog("info", "Failed to enumerate planfiles: $!\n") if ($use_syslog); + return; + } + + if (not open RSS_DIGESTH, '>', $digest_rss_filename) { + if ($use_syslog) { + syslog("info", "digest: failed to open $digest_rss_filename: $!\n"); + } + return; + } + my %plansdates; + + foreach (@plans) { + my $user = $_; + if ($use_homedir) { + $user =~ s#\A/home/(.*?)/\.plan\Z#$1#; + } else { + $user = basename($_); + } + + my @statbuf = stat($_); + my $filesize = $statbuf[7]; + next if ($filesize <= 0); # Skip empty .plans + + # construct the hash backward for easy + # sorting-by-time in the next loop + $plansdates{$statbuf[9]} = $user; + } + + #ZWARNING: can I really do this here, like this? + print RSS_DIGESTH " <?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n"; + print RSS_DIGESTH " <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; + print RSS_DIGESTH " xmlns=\"http://purl.org/rss/1.0/\">\n\n"; + print RSS_DIGESTH " <channel rdf:about=\"$digest_rss_about\">\n"; + print RSS_DIGESTH " <title>$digest_rss_title\n"; + print RSS_DIGESTH " $digest_rss_url\n"; + print RSS_DIGESTH " $digest_rss_desc\n"; + print RSS_DIGESTH " \n\n"; + print RSS_DIGESTH " \n"; + print RSS_DIGESTH " $digest_rss_title\n"; + print RSS_DIGESTH " $digest_rss_image\n"; + print RSS_DIGESTH " $digest_rss_url\n"; + print RSS_DIGESTH " \n\n"; + #ZWARNING - end + + foreach ( reverse sort keys %plansdates) { + my $user = $plansdates{$_}; + my $modtime = get_minimal_sqldate($_); + my $href = "href=\"$base_url?user=$user\""; + print RSS_DIGESTH "\n"; + print RSS_DIGESTH " $user - $modtime\n"; + print RSS_DIGESTH " $href\n"; + #I'm just putting the bare minimum of RSS content in here to see if it works, + # it might, but then it might not, who knows :=) + print RSS_DIGESTH ""\n; + } + + print RSS_DIGESTH " " + close(RSS_DIGESTH); +} + +#ZWARNING -ends here for this routine, but did the zakk do his job right?! my $did_output_start = 0; sub output_start { @@ -541,7 +633,6 @@ print("\n"); } } - sub parse_args { my $args = shift;