From 8c762aa599e4022654cf707125d7ac2ed6f194b0 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 26 Oct 2012 07:59:17 +0200 Subject: [PATCH] Part of #6: show changed files + line counts in updated feed --- data/templates/feed-updated.htm | 19 +++++++++++++++---- www/www-header.php | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/data/templates/feed-updated.htm b/data/templates/feed-updated.htm index 699dabd..ff1d609 100644 --- a/data/templates/feed-updated.htm +++ b/data/templates/feed-updated.htm @@ -12,13 +12,24 @@ {{repo.getLink('display', null, true)}} {{repo.getTitle}} {{repo.crdate|date('c')}} - {{repo.modate|date('c')}} + {% set commit = repo.getHistory().0 %} + {{commit.committerTime|date('c')}} - {% set owner=repo.getOwner() %} - {{owner.name}} - {{owner.email}} + {{commit.committerName}} + {{commit.committerEmail}} + {% 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 %} {% endfor %} \ No newline at end of file diff --git a/www/www-header.php b/www/www-header.php index 9aa8732..41b5e47 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -68,6 +68,14 @@ $twig = new \Twig_Environment( '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) { -- 2.30.2