Added the link to the author profile when possible.

This commit is contained in:
Loic d'Anterroches 2008-12-05 14:51:51 +01:00
parent b660c6782f
commit 6c5da01319
7 changed files with 77 additions and 18 deletions

View File

@ -86,6 +86,7 @@ class IDF_Middleware
'timeline' => 'IDF_Template_TimelineFragment', 'timeline' => 'IDF_Template_TimelineFragment',
'markdown' => 'IDF_Template_Markdown', 'markdown' => 'IDF_Template_Markdown',
'showuser' => 'IDF_Template_ShowUser', 'showuser' => 'IDF_Template_ShowUser',
'ashowuser' => 'IDF_Template_AssignShowUser',
)); ));
$params['modifiers'] = array_merge($params['modifiers'], $params['modifiers'] = array_merge($params['modifiers'],
array( array(

View File

@ -0,0 +1,55 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
/**
* Show the name of a user in a template.
*
* It will automatically make the link to the profile if needed. In
* the future it will allow us to add little badges on the side of the
* user based on karma or whatever.
*
* This will also provide a consistent display of a user name in the
* application.
*/
class IDF_Template_AssignShowUser extends Pluf_Template_Tag
{
/**
* We need the user object and the request.
*
* If the user object is null (for example a non associated
* commit), we can use the $text value for an alternative display.
*
* @param string Which variable to assign
* @param Pluf_User
* @param Pluf_HTTP_Request
* @param string Alternate text ('')
*/
function start($var, $user, $request, $text='')
{
$t = new IDF_Template_ShowUser($this->context);
$this->context->set($var,
Pluf_Template::markSafe($t->start($user, $request, $text, false)));
}
}

View File

@ -53,17 +53,18 @@ class IDF_Views_Source
return new Pluf_HTTP_Response_Redirect($url); return new Pluf_HTTP_Response_Redirect($url);
} }
$changes = $scm->getChangeLog($commit, 25); $changes = $scm->getChangeLog($commit, 25);
$rchanges = array();
// Sync with the database // Sync with the database
foreach ($changes as $change) { foreach ($changes as $change) {
IDF_Commit::getOrAdd($change, $request->project); $rchanges[] = IDF_Commit::getOrAdd($change, $request->project);
} }
$changes = new Pluf_Template_ContextVars($changes); $rchanges = new Pluf_Template_ContextVars($rchanges);
$scmConf = $request->conf->getVal('scm', 'git'); $scmConf = $request->conf->getVal('scm', 'git');
return Pluf_Shortcuts_RenderToResponse('idf/source/changelog.html', return Pluf_Shortcuts_RenderToResponse('idf/source/changelog.html',
array( array(
'page_title' => $title, 'page_title' => $title,
'title' => $title, 'title' => $title,
'changes' => $changes, 'changes' => $rchanges,
'commit' => $commit, 'commit' => $commit,
'branches' => $branches, 'branches' => $branches,
'scm' => $scmConf, 'scm' => $scmConf,
@ -216,6 +217,7 @@ class IDF_Views_Source
$title = sprintf(__('%s Commit Details'), (string) $request->project); $title = sprintf(__('%s Commit Details'), (string) $request->project);
$page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit); $page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit);
$cobject = $scm->getCommit($commit); $cobject = $scm->getCommit($commit);
$rcommit = IDF_Commit::getOrAdd($cobject, $request->project);
$diff = new IDF_Diff($cobject->changes); $diff = new IDF_Diff($cobject->changes);
$diff->parse(); $diff->parse();
$scmConf = $request->conf->getVal('scm', 'git'); $scmConf = $request->conf->getVal('scm', 'git');
@ -228,6 +230,7 @@ class IDF_Views_Source
'commit' => $commit, 'commit' => $commit,
'branches' => $branches, 'branches' => $branches,
'scm' => $scmConf, 'scm' => $scmConf,
'rcommit' => $rcommit,
), ),
$request); $request);
} }

View File

@ -47,7 +47,7 @@
{/if} {/if}
{/block} {/block}
{block context} {block context}
{assign $submitter = $file.get_submitter()} {ashowuser 'submitter', $file.get_submitter(), $request}
<p><strong>{trans 'Uploaded:'}</strong> <span class="nobrk">{$file.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p> <p><strong>{trans 'Uploaded:'}</strong> <span class="nobrk">{$file.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
{if $file.modif_dtime != $file.creation_dtime}<p> {if $file.modif_dtime != $file.creation_dtime}<p>
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$file.modif_dtime|dateago}</span></p>{/if} <strong>{trans 'Updated:'}</strong> <span class="nobrk">{$file.modif_dtime|dateago}</span></p>{/if}

View File

@ -3,15 +3,15 @@
{block body} {block body}
{assign $i = 0} {assign $i = 0}
{assign $nc = $comments.count()} {assign $nc = $comments.count()}
{foreach $comments as $c} {foreach $comments as $c}{ashowuser 'submitter', $c.get_submitter(), $request}{assign $who = $c.get_submitter()}
<div class="issue-comment{if $i == 0} issue-comment-first{/if}{if $i == ($nc-1)} issue-comment-last{/if}" id="ic{$c.id}">{assign $who = $c.get_submitter()}{aurl 'whourl', 'IDF_Views_User::view', array($who.login)}<img style="float:right; position: relative;" src="http://www.gravatar.com/avatar/{$who.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " /> <div class="issue-comment{if $i == 0} issue-comment-first{/if}{if $i == ($nc-1)} issue-comment-last{/if}" id="ic{$c.id}"><img style="float:right; position: relative;" src="http://www.gravatar.com/avatar/{$who.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " />
{if $i == 0} {if $i == 0}
<p>{blocktrans}Reported by <a href="{$whourl}">{$who}</a>, {$c.creation_dtime|date}{/blocktrans}</p> <p>{blocktrans}Reported by {$submitter}, {$c.creation_dtime|date}{/blocktrans}</p>
{else} {else}
{aurl 'url', 'IDF_Views_Issue::view', array($project.shortname, $issue.id)} {aurl 'url', 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
{assign $id = $c.id} {assign $id = $c.id}
{assign $url = $url~'#ic'~$c.id} {assign $url = $url~'#ic'~$c.id}
<p>{blocktrans}Comment <a href="{$url}">{$i}</a> by <a href="{$whourl}">{$who}</a>, {$c.creation_dtime|date}{/blocktrans}</p> <p>{blocktrans}Comment <a href="{$url}">{$i}</a> by {$submitter}, {$c.creation_dtime|date}{/blocktrans}</p>
{/if} {/if}
@ -118,14 +118,14 @@
{/block} {/block}
{block context} {block context}
<div class="issue-info"> <div class="issue-info">
{assign $submitter = $issue.get_submitter()}{aurl 'url', 'IDF_Views_User::view', array($submitter.login)} {ashowuser 'submitter', $issue.get_submitter(), $request}
<p><strong>{trans 'Created:'}</strong> <span class="nobrk">{$issue.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by <a href="{$url}">{$submitter}</a>{/blocktrans}</span></p> <p><strong>{trans 'Created:'}</strong> <span class="nobrk">{$issue.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
{if $issue.modif_dtime != $issue.creation_dtime}<p> {if $issue.modif_dtime != $issue.creation_dtime}<p>
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$issue.modif_dtime|dateago}</span></p>{/if} <strong>{trans 'Updated:'}</strong> <span class="nobrk">{$issue.modif_dtime|dateago}</span></p>{/if}
<p> <p>
<strong>{trans 'Status:'}</strong> {$issue.get_status.name}</p> <strong>{trans 'Status:'}</strong> {$issue.get_status.name}</p>
{if $issue.get_owner != null}<p>{aurl 'url', 'IDF_Views_User::view', array($issue.get_owner().login)} {if $issue.get_owner != null}<p>
<strong>{trans 'Owner:'}</strong> <a href="{$url}">{$issue.get_owner}</a> <strong>{trans 'Owner:'}</strong> {showuser $issue.get_owner(), $request}
</p>{/if}{assign $tags = $issue.get_tags_list()}{if $tags.count()} </p>{/if}{assign $tags = $issue.get_tags_list()}{if $tags.count()}
<p> <p>
<strong>{trans 'Labels:'}</strong><br /> <strong>{trans 'Labels:'}</strong><br />

View File

@ -10,15 +10,15 @@
</thead> </thead>
<tbody> <tbody>
{foreach $changes as $change} {foreach $changes as $change}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $change.commit)} {aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $change.scm_id)}
<tr class="log"> <tr class="log">
<td><a href="{$url}">{$change.date|dateago:"wihtout"}</a></td> <td><a href="{$url}">{$change.creation_dtime|dateago:"wihtout"}</a></td>
<td>{issuetext $change.title, $request}{if $change.full_message}<br /><br />{issuetext $change.full_message, $request}{/if}</td> <td>{issuetext $change.summary, $request}{if $change.fullmessage}<br /><br />{issuetext $change.fullmessage, $request}{/if}</td>
</tr> </tr>
<tr class="extra"> <tr class="extra">
<td colspan="2"> <td colspan="2">
<div class="helptext right">{trans 'Commit'}&nbsp;<a href="{$url}" class="mono">{$change.commit}</a>, <div class="helptext right">{trans 'Commit'}&nbsp;<a href="{$url}" class="mono">{$change.scm_id}</a>,
{trans 'by'} {$change.author|strip_tags} {* this remove the email address *} {trans 'by'} {showuser $change.get_author(), $request, $change.origauthor}
</div> </div>
</td> </td>

View File

@ -7,7 +7,7 @@
<th><strong>{trans 'Date:'}</strong></th><td>{$cobject.date|date:"%Y-%m-%d %H:%M:%S"} ({$cobject.date|dateago})</td> <th><strong>{trans 'Date:'}</strong></th><td>{$cobject.date|date:"%Y-%m-%d %H:%M:%S"} ({$cobject.date|dateago})</td>
</tr> </tr>
<tr> <tr>
<th><strong>{trans 'Author:'}</strong></th><td>{$cobject.author|strip_tags}</td> <th><strong>{trans 'Author:'}</strong></th><td>{showuser $rcommit.get_author(), $request}</td>
</tr> </tr>
<tr> <tr>
<th><strong>{trans 'Commit:'}</strong></th><td class="mono"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}" title="{trans 'View corresponding source tree'}">{$cobject.commit}</a></td> <th><strong>{trans 'Commit:'}</strong></th><td class="mono"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}" title="{trans 'View corresponding source tree'}">{$cobject.commit}</a></td>