Unfinished activity ('quantified self') tracker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dmdircsvn.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?PHP
  2. class DMDircSvnSource implements Source {
  3. private $data;
  4. public function __construct() {
  5. $cache = dirname(dirname(__FILE__)) . '/cache/dmdircsvn.dat';
  6. if (file_exists($cache)) {
  7. $this->data = unserialize(file_get_contents($cache));
  8. } else {
  9. $this->data = array('data' => array(), 'processed' => 0);
  10. }
  11. $repo = '/home/dmdirc/repo';
  12. $name = 'DMDirc';
  13. $titl = '<strong>' . $name . '</strong>';
  14. $revs = count(glob($repo . '/db/revs/*'));
  15. $done = max(1, (int) $this->data['processed']);
  16. for ($i = $done; $i < $revs; $i++) {
  17. $auth = trim(`svnlook author $repo -r $i`);
  18. if ($auth == 'chris87') {
  19. $date = strtotime(substr(`svnlook date $repo -r $i`, 0, 19));
  20. $revh = '<strong>' . $i . '</strong>';
  21. $mesg = '<code>' . htmlentities(trim(`svnlook log $repo -r $i`)) . '</code>';
  22. $mesg = 'Committed revision ' . $revh . ' to ' . $titl . ' with log message ' . $mesg;
  23. $this->data['data'][] = new Event($date, $mesg);
  24. }
  25. }
  26. $this->data['processed'] = $revs;
  27. file_put_contents($cache, serialize($this->data));
  28. unset($this->data['processed']);
  29. }
  30. public function getData() {
  31. return $this->data['data'];
  32. }
  33. }
  34. $_SOURCES[] =& new DMDircSvnSource();
  35. ?>