tilde.club/~brennen/

git-feed.pl 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env perl
  2. # TODO: this really just ought to be a general-purpose utility
  3. use warnings;
  4. use strict;
  5. use 5.10.0;
  6. use XML::Atom::SimpleFeed;
  7. use HTML::Entities;
  8. my $page_url = "http://tilde.club/~brennen/";
  9. my $feed_url = "http://tilde.club/~brennen/feed.xml";
  10. my $log = `git log -10 --pretty=format:"%H _ %ai _ %s"`;
  11. my $feed = XML::Atom::SimpleFeed->new(
  12. title => "Brennen's tilde.club page",
  13. link => $page_url,
  14. link => { rel => 'self', href => $feed_url, },
  15. author => 'Brennen Bearnes',
  16. id => $page_url,
  17. generator => 'XML::Atom::SimpleFeed',
  18. # updated => iso_date(Wala::get_mtime($month_file)),
  19. );
  20. while ($log =~ m/^([a-z0-9]+) _ (.*) _ (.*)$/gm) {
  21. my $hash = $1;
  22. my $full_commit = `git show $hash`;
  23. my $formatted_commit = '<pre>' . encode_entities($full_commit) . '</pre>';
  24. my $date = $2;
  25. my $subj = $3;
  26. $feed->add_entry(
  27. title => $subj,
  28. link => $page_url,
  29. id => $hash,
  30. content => $formatted_commit,
  31. updated => $date,
  32. );
  33. }
  34. print $feed->as_string;
  35. sub iso_date {
  36. my ($time) = @_;
  37. return strftime("%Y-%m-%dT%H:%M:%SZ", localtime($time));
  38. }