Part of #6: show changed files + line counts in updated feed
authorChristian Weiske <cweiske@cweiske.de>
Fri, 26 Oct 2012 05:59:17 +0000 (07:59 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 26 Oct 2012 05:59:17 +0000 (07:59 +0200)
data/templates/feed-updated.htm
www/www-header.php

index 699dabd3d00c5dc61c75e4a718f5edb046d0e42d..ff1d609ef0a91b43429ce92bc062ebcbce968527 100644 (file)
   <id>{{repo.getLink('display', null, true)}}</id>
   <title>{{repo.getTitle}}</title>
   <published>{{repo.crdate|date('c')}}</published>
   <id>{{repo.getLink('display', null, true)}}</id>
   <title>{{repo.getTitle}}</title>
   <published>{{repo.crdate|date('c')}}</published>
-  <updated>{{repo.modate|date('c')}}</updated>
+  {% set commit = repo.getHistory().0 %}
+  <updated>{{commit.committerTime|date('c')}}</updated>
   <link rel="alternate" type="text/html" href="{{repo.getLink('display', null, true)}}" />
   <author>
   <link rel="alternate" type="text/html" href="{{repo.getLink('display', null, true)}}" />
   <author>
-   {% set owner=repo.getOwner() %}
-   <name>{{owner.name}}</name>
-   <email>{{owner.email}}</email>
+   <name>{{commit.committerName}}</name>
+   <email>{{commit.committerEmail}}</email>
   </author>
   </author>
+  <summary>{% spaceless %}
+   {% if commit.filesChanged %}
+     {{ntext(commit.filesChanged, "%d file", "%d files")}} changed{% if commit.linesAdded %},{% endif %}
+   {% endif %}
+   {% if commit.linesAdded %}
+     {{ntext(commit.linesAdded, "%d line", "%d lines")}} added{% if commit.linesDeleted %},{% endif %}
+   {% endif %}
+   {% if commit.linesDeleted %}
+     {{ntext(commit.linesDeleted, "%d line", "%d lines")}} deleted
+   {% endif %}
+  {% endspaceless %}</summary>
  </entry>
 {% endfor %}
 </feed>
\ No newline at end of file
  </entry>
 {% endfor %}
 </feed>
\ No newline at end of file
index 9aa873240aa2a3dff64a909f1c57b2c50e391f75..41b5e4731889961080f511e2a5474473ea4bb49e 100644 (file)
@@ -68,6 +68,14 @@ $twig = new \Twig_Environment(
         'debug' => true
     )
 );
         'debug' => true
     )
 );
+$twig->addFunction('ntext', new \Twig_Function_Function('\phorkie\ntext'));
+function ntext($value, $singular, $plural)
+{
+    if (abs($value) == 1) {
+        return sprintf($singular, $value);
+    }
+    return sprintf($plural, $value);
+}
 //$twig->addExtension(new \Twig_Extension_Debug());
 
 if (!isset($noSecurityCheck) || $noSecurityCheck !== true) {
 //$twig->addExtension(new \Twig_Extension_Debug());
 
 if (!isset($noSecurityCheck) || $noSecurityCheck !== true) {