Added DateTime format configuration to config.ini, fixes #362

This commit is contained in:
Klaus Silveira
2014-05-17 10:18:12 -03:00
parent f8b29db8c3
commit dbde52ca7e
7 changed files with 16 additions and 8 deletions

View File

@@ -30,3 +30,4 @@ theme = "default"
; set the timezone
[date]
; timezone = UTC
; format = 'd/m/Y H:i:s'

View File

@@ -30,6 +30,7 @@ class Application extends SilexApplication
$this->path = realpath($root);
$this['debug'] = $config->get('app', 'debug');
$this['date.format'] = $config->get('date', 'format') ? $config->get('date', 'format') : 'd/m/Y H:i:s';
$this['theme'] = $config->get('app', 'theme') ? $config->get('app', 'theme') : 'default';
$this['filetypes'] = $config->getSection('filetypes');
$this['cache.archives'] = $this->getCachePath() . 'archives';
@@ -59,8 +60,9 @@ class Application extends SilexApplication
$this->register(new RoutingUtilServiceProvider());
$this['twig'] = $this->share($this->extend('twig', function ($twig, $app) {
$twig->addFilter('htmlentities', new \Twig_Filter_Function('htmlentities'));
$twig->addFilter('md5', new \Twig_Filter_Function('md5'));
$twig->addFilter(new \Twig_SimpleFilter('htmlentities', 'htmlentities'));
$twig->addFilter(new \Twig_SimpleFilter('md5', 'md5'));
$twig->addFilter(new \Twig_SimpleFilter('format_date', array($this, 'formatDate')));
return $twig;
}));
@@ -77,6 +79,11 @@ class Application extends SilexApplication
});
}
public function formatDate($date)
{
return $date->format($this['date.format']);
}
public function getPath()
{
return $this->path . DIRECTORY_SEPARATOR;

View File

@@ -18,7 +18,7 @@
<p>{{ commit.body | nl2br }}</p>
{% endif %}
<img src="https://gravatar.com/avatar/{{ commit.author.email | lower | md5 }}?s=32" class="pull-left space-right" />
<span><a href="mailto:{{ commit.author.email }}">{{ commit.author.name }}</a> authored on {{ commit.date | date('d/m/Y \\a\\t H:i:s') }}<br />Showing {{ commit.changedFiles }} changed files</span>
<span><a href="mailto:{{ commit.author.email }}">{{ commit.author.name }}</a> authored on {{ commit.date | format_date }}<br />Showing {{ commit.changedFiles }} changed files</span>
</div>
</div>

View File

@@ -13,7 +13,7 @@
<td width="95%">
<span class="pull-right"><a class="btn btn-default btn-sm" href="{{ path('commit', {repo: repo, commit: item.hash}) }}"><span class="fa fa-list-alt"></span> View {{ item.shortHash }}</a></span>
<h4>{{ item.message }}</h4>
<span><a href="mailto:{{ item.author.email }}">{{ item.author.name }}</a> authored on {{ item.date | date('d/m/Y \\a\\t H:i:s') }}</span>
<span><a href="mailto:{{ item.author.email }}">{{ item.author.name }}</a> authored on {{ item.date | format_date }}</span>
</td>
</tr>
{% endfor %}

View File

@@ -17,7 +17,7 @@
<p>{{ commit.body | nl2br }}</p>
{% endif %}
<img src="https://gravatar.com/avatar/{{ commit.author.email | lower | md5 }}?s=32" class="pull-left space-right" />
<span><a href="mailto:{{ commit.author.email }}">{{ commit.author.name }}</a> authored on {{ commit.date | date('d/m/Y \\a\\t H:i:s') }}<br />Showing {{ commit.changedFiles }} changed files</span>
<span><a href="mailto:{{ commit.author.email }}">{{ commit.author.name }}</a> authored on {{ commit.date | format_date }}<br />Showing {{ commit.changedFiles }} changed files</span>
</div>
</div>

View File

@@ -13,7 +13,7 @@
<td width="95%">
<span class="pull-right"><a class="btn btn-small" href="{{ path('commit', {repo: repo, commit: item.hash}) }}"><i class="icon-list-alt"></i> View {{ item.shortHash }}</a></span>
<h4>{{ item.message }}</h4>
<span><a href="mailto:{{ item.author.email }}">{{ item.author.name }}</a> authored on {{ item.date | date('d/m/Y \\a\\t H:i:s') }}</span>
<span><a href="mailto:{{ item.author.email }}">{{ item.author.name }}</a> authored on {{ item.date | format_date }}</span>
</td>
</tr>
{% endfor %}

View File

@@ -8,7 +8,7 @@
{% for commit in commits %}
<item>
<title>{{ commit.message }}</title>
<description>{{ commit.author.name }} authored {{ commit.shortHash }} in {{ commit.date | date('d/m/Y \\a\\t H:i:s') }}</description>
<description>{{ commit.author.name }} authored {{ commit.shortHash }} in {{ commit.date | format_date }}</description>
<link>{{ url('commit', {repo: repo, commit: commit.hash}) }}</link>
<pubDate>{{ commit.date | date('r') }}</pubDate>
</item>