Add a new view modifier which allows the shortening of long strings such as branch or tag names. Use that in the tree view and display the full name in a title tag.
This commit is contained in:
parent
cf22909722
commit
995f1a13c3
@ -92,6 +92,7 @@ class IDF_Middleware
|
|||||||
array(
|
array(
|
||||||
'size' => 'IDF_Views_Source_PrettySize',
|
'size' => 'IDF_Views_Source_PrettySize',
|
||||||
'ssize' => 'IDF_Views_Source_PrettySizeSimple',
|
'ssize' => 'IDF_Views_Source_PrettySizeSimple',
|
||||||
|
'shorten' => 'IDF_Views_Source_ShortenString',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,9 +105,9 @@ function IDF_Middleware_ContextPreProcessor($request)
|
|||||||
$c['isAdmin'] = ($request->user->administrator or $request->user->staff);
|
$c['isAdmin'] = ($request->user->administrator or $request->user->staff);
|
||||||
if (isset($request->project)) {
|
if (isset($request->project)) {
|
||||||
$c['project'] = $request->project;
|
$c['project'] = $request->project;
|
||||||
$c['isOwner'] = $request->user->hasPerm('IDF.project-owner',
|
$c['isOwner'] = $request->user->hasPerm('IDF.project-owner',
|
||||||
$request->project);
|
$request->project);
|
||||||
$c['isMember'] = $request->user->hasPerm('IDF.project-member',
|
$c['isMember'] = $request->user->hasPerm('IDF.project-member',
|
||||||
$request->project);
|
$request->project);
|
||||||
$c = array_merge($c, $request->rights);
|
$c = array_merge($c, $request->rights);
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,10 @@ class IDF_Views_Source
|
|||||||
* Extension supported by the syntax highlighter.
|
* Extension supported by the syntax highlighter.
|
||||||
*/
|
*/
|
||||||
public static $supportedExtenstions = array(
|
public static $supportedExtenstions = array(
|
||||||
'ascx', 'ashx', 'asmx', 'aspx', 'browser', 'bsh', 'c', 'cc',
|
'ascx', 'ashx', 'asmx', 'aspx', 'browser', 'bsh', 'c', 'cc',
|
||||||
'config', 'cpp', 'cs', 'csh', 'csproj', 'css', 'cv', 'cyc',
|
'config', 'cpp', 'cs', 'csh', 'csproj', 'css', 'cv', 'cyc',
|
||||||
'html', 'html', 'java', 'js', 'master', 'perl', 'php', 'pl',
|
'html', 'html', 'java', 'js', 'master', 'perl', 'php', 'pl',
|
||||||
'pm', 'py', 'rb', 'sh', 'sitemap', 'skin', 'sln', 'svc', 'vala',
|
'pm', 'py', 'rb', 'sh', 'sitemap', 'skin', 'sln', 'svc', 'vala',
|
||||||
'vb', 'vbproj', 'wsdl', 'xhtml', 'xml', 'xsd', 'xsl', 'xslt');
|
'vb', 'vbproj', 'wsdl', 'xhtml', 'xml', 'xsd', 'xsl', 'xslt');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -415,7 +415,7 @@ class IDF_Views_Source
|
|||||||
$scm->getMainBranch()));
|
$scm->getMainBranch()));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
$info = self::getRequestedFileMimeType($request_file_info,
|
$info = self::getRequestedFileMimeType($request_file_info,
|
||||||
$commit, $scm);
|
$commit, $scm);
|
||||||
$rep = new Pluf_HTTP_Response($scm->getFile($request_file_info),
|
$rep = new Pluf_HTTP_Response($scm->getFile($request_file_info),
|
||||||
$info[0]);
|
$info[0]);
|
||||||
@ -476,7 +476,7 @@ class IDF_Views_Source
|
|||||||
public static function getMimeTypeFromContent($file, $filedata)
|
public static function getMimeTypeFromContent($file, $filedata)
|
||||||
{
|
{
|
||||||
$info = pathinfo($file);
|
$info = pathinfo($file);
|
||||||
$res = array('application/octet-stream',
|
$res = array('application/octet-stream',
|
||||||
$info['basename'],
|
$info['basename'],
|
||||||
isset($info['extension']) ? $info['extension'] : 'bin');
|
isset($info['extension']) ? $info['extension'] : 'bin');
|
||||||
if (function_exists('finfo_open')) {
|
if (function_exists('finfo_open')) {
|
||||||
@ -597,3 +597,16 @@ function IDF_Views_Source_PrettySizeSimple($size)
|
|||||||
return Pluf_Utils::prettySize($size);
|
return Pluf_Utils::prettySize($size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function IDF_Views_Source_ShortenString($string, $length)
|
||||||
|
{
|
||||||
|
$ellipse = "...";
|
||||||
|
$length = max(strlen($ellipse) + 2, $length);
|
||||||
|
$preflen = ceil($length / 10);
|
||||||
|
|
||||||
|
if (mb_strlen($string) < $length)
|
||||||
|
return $string;
|
||||||
|
|
||||||
|
return substr($string, 0, $preflen).$ellipse.
|
||||||
|
substr($string, -($length - $preflen - mb_strlen($ellipse)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -58,14 +58,18 @@
|
|||||||
<p><strong>{trans 'Branches:'}</strong><br/>
|
<p><strong>{trans 'Branches:'}</strong><br/>
|
||||||
{foreach $branches as $branch => $path}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
||||||
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br/>
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label" title="{if $path}{$path}{else}{$branch}{/if}">
|
||||||
|
{if $path}{$path|shorten:25}{else}{$branch|shorten:25}{/if}
|
||||||
|
</a></span><br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
{if $tags}
|
{if $tags}
|
||||||
<p><strong>{trans 'Tags:'}</strong><br/>
|
<p><strong>{trans 'Tags:'}</strong><br/>
|
||||||
{foreach $tags as $tag => $path}
|
{foreach $tags as $tag => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $tag)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $tag)}
|
||||||
<span class="label{if in_array($tag, $tags_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$tag}{/if}</a></span><br/>
|
<span class="label{if in_array($tag, $tags_in)} active{/if}"><a href="{$url}" class="label" title="{if $path}{$path}{else}{$tag}{/if}">
|
||||||
|
{if $path}{$path|shorten:25}{else}{$tag|shorten:25}{/if}
|
||||||
|
</a></span><br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user