Indefero

Indefero Commit Details

Date:2008-11-11 22:32:01 (5 years 9 months ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:9ac6e38e819d181191d1b9e09b4c5e476e0aa289
Parents: 297d7290df3745da610f62183e4b0ff1f15daa23
Message:Added inline visualization of text files from the repository.

Changes:
Asrc/IDF/templates/source/git/file.html (full)
Asrc/IDF/templates/source/svn/file.html (full)
Msrc/IDF/Diff.php (2 diffs)
Msrc/IDF/Views/Source.php (3 diffs)
Msrc/IDF/conf/views.php (1 diff)
Msrc/IDF/templates/source/commit.html (1 diff)
Msrc/IDF/templates/source/git/tree.html (1 diff)
Msrc/IDF/templates/source/svn/tree.html (1 diff)
Mwww/media/idf/css/style.css (2 diffs)

File differences

src/IDF/Diff.php
127127
128128
129129
130
130
131131
132132
133133
......
136136
137137
138138
139
139
140140
141141
142142
143
143
144144
145145
146146
} else {
$class = 'diff-a';
}
$line_content = $this->padLine(Pluf_esc($line[2]));
$line_content = self::padLine(Pluf_esc($line[2]));
$out .= sprintf('<tr class="diff-line"><td class="diff-lc">%s</td><td class="diff-lc">%s</td><td class="%s mono">%s</td></tr>'."\n", $line[0], $line[1], $class, $line_content);
}
if (count($file['chunks']) > $cc)
}
$out .= '</table>';
}
return $out;
return Pluf_Template::markSafe($out);
}
public function padLine($line)
public static function padLine($line)
{
$n = strlen($line);
for ($i=0;$i<$n;$i++) {
src/IDF/Views/Source.php
128128
129129
130130
131
131132
132133
133
134
134
135
136
137
138
139
140
135141
136
137142
138143
139144
......
216221
217222
218223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
219301
220302
221303
......
289371
290372
291373
374
375
376
377
378
379
380
381
382
383
384
385
292386
293387
294388
$rep = new Pluf_HTTP_Response($scm->getBlob($request_file_info, $commit),
$info[0]);
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$info[1].'"';
return $rep;
} else {
// We want to display the content of the file as text
$rep = new Pluf_HTTP_Response($scm->getBlob($request_file_info, $commit),
'text/plain');
$extra = array('branches' => $branches,
'commit' => $commit,
'request_file' => $request_file,
'request_file_info' => $request_file_info,
'mime' => $info,
);
return $this->viewFile($request, $match, $extra);
}
return $rep;
}
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file);
$page_title = $bc.' - '.$title;
}
/**
* Should only be called through self::tree
*/
public function viewFile($request, $match, $extra)
{
$title = sprintf(__('%1$s %2$s Source Tree'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_Scm::get($request);
$branches = $extra['branches'];
$commit = $extra['commit'];
$request_file = $extra['request_file'];
$request_file_info = $extra['request_file_info'];
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file);
$page_title = $bc.' - '.$title;
$cobject = $scm->getCommit($commit);
$tree_in = in_array($commit, $branches);
// try to find the previous level if it exists.
$prev = split('/', $request_file);
$l = array_pop($prev);
$previous = substr($request_file, 0, -strlen($l.' '));
$scmConf = $request->conf->getVal('scm', 'git');
$props = null;
if ($scmConf === 'svn') {
$props = $scm->getProperties($commit, $request_file);
}
$content = self::highLight($extra['mime'], $scm->getBlob($request_file_info, $commit));
return Pluf_Shortcuts_RenderToResponse('source/'.$scmConf.'/file.html',
array(
'page_title' => $page_title,
'title' => $title,
'breadcrumb' => $bc,
'file' => $content,
'commit' => $commit,
'cobject' => $cobject,
'fullpath' => $request_file,
'base' => $request_file_info->file,
'prev' => $previous,
'tree_in' => $tree_in,
'branches' => $branches,
'props' => $props,
),
$request);
}
/**
* Get a given file at a given commit.
*
*/
public $getFile_precond = array('IDF_Precondition::accessSource');
public function getFile($request, $match)
{
$scm = IDF_Scm::get($request);
$branches = $scm->getBranches();
$commit = $match[2];
$request_file = $match[3];
if ('commit' != $scm->testHash($commit, $request_file)) {
// Redirect to the first branch
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
array($request->project->shortname,
$branches[0]));
return new Pluf_HTTP_Response_Redirect($url);
}
$request_file_info = $scm->getFileInfo($request_file, $commit);
if (!$request_file_info or $request_file_info->type == 'tree') {
// Redirect to the first branch
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
array($request->project->shortname,
$branches[0]));
return new Pluf_HTTP_Response_Redirect($url);
}
$info = self::getMimeType($request_file_info->file);
$rep = new Pluf_HTTP_Response($scm->getBlob($request_file_info, $commit),
$info[0]);
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$info[1].'"';
return $rep;
}
/**
* Get a zip archive of the current commit.
*
*/
return (in_array($fileinfo[2], explode(' ', $ext)));
}
public static function highLight($fileinfo, $content)
{
$table = array();
$i = 1;
foreach (preg_split("/\015\012|\015|\012/", $content) as $line) {
$table[] = '<tr class="c-line"><td class="code-lc" id="L'.$i.'"><a href="#L'.$i.'">'.$i.'</a></td>'
.'<td class="code mono">'.IDF_Diff::padLine(Pluf_esc($line)).'</td></tr>';
$i++;
}
return Pluf_Template::markSafe(implode("\n", $table));
}
/**
* Get the scm type for page title
*
src/IDF/conf/views.php
165165
166166
167167
168
169
170
171
172
173
168174
169175
170176
'model' => 'IDF_Views_Source',
'method' => 'download');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/file/(\w+)/(.*)$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Source',
'method' => 'getFile');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/treerev/$#',
'base' => $base,
'priority' => 4,
src/IDF/templates/source/commit.html
3232
3333
3434
35
35
3636
3737
3838
{if count($diff.files)}
<h2>{trans 'Change Details'}</h2>
{$diff.as_html()|safe}
{$diff.as_html()}
{/if}
{/block}
{block context}
src/IDF/templates/source/git/file.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{extends "source/base.html"}
{block docclass}yui-t1{assign $inSourceTree=true}{/block}
{block body}
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<table class="code" summary=" ">
{$file}
</table>
{aurl 'url', 'IDF_Views_Source::getFile', array($project.shortname, $commit, $fullpath)}
<p class="right soft"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <a href="{$url}">{trans 'Download this file'}</a></p>
{/block}
{block context}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
{/block}
src/IDF/templates/source/git/tree.html
11
22
33
4
4
55
66
77
{extends "source/base.html"}
{block docclass}yui-t1{assign $inSourceTree=true}{/block}
{block body}
<h2><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<table summary="" class="tree-list">
<thead>
src/IDF/templates/source/svn/file.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{extends "source/base.html"}
{block docclass}yui-t1{assign $inSourceTree=true}{/block}
{block body}
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<table class="code" summary=" ">
{$file}
</table>
{aurl 'url', 'IDF_Views_Source::getFile', array($project.shortname, $commit, $fullpath)}
<p class="right soft"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <a href="{$url}">{trans 'Download this file'}</a></p>
{/block}
{block context}
<form class="star" action="{url 'IDF_Views_Source_Svn::treeRev', array($project.shortname)}" method="get">
<p><strong>{trans 'Revision:'}</strong> {$commit}</p>
<p>
<input accesskey="4" type="text" value="{$commit}" name="rev" size="5" />
<input type="hidden" name="sourcefile" value="{$base}"/>
<input type="submit" name="s" value="{trans 'Go to revision'}" /></p>
</form>
{/block}
src/IDF/templates/source/svn/tree.html
11
22
33
4
4
55
66
77
{extends "source/base.html"}
{block docclass}yui-t1{assign $inSourceTree=true}{/block}
{block body}
<h2><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<table summary="" class="tree-list">
<thead>
www/media/idf/css/style.css
1919
2020
2121
22
23
24
25
2226
2327
2428
......
481485
482486
483487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
484539
485540
486541
#
# ***** END LICENSE BLOCK ***** */
h2.top {
margin-top: 0;
}
.yui-g {
padding: 0 1em;
}
}
/**
* view file content
*/
table.code {
border-bottom: 1px solid #d3d7cf;
border-top: 1px solid #d3d7cf;
width: 100%;
}
table.code tr {
border-left: 1px solid #d3d7cf;
border-right: 1px solid #d3d7cf;
border-bottom: none;
border-top: none;
}
table.code td {
font-size: 90%;
vertical-align: top;
padding: 1px;
border-color: inherit;
}
table.code td.code {
border: none;
/* Whitespace hacking from: http://ln.hixie.ch/ */
white-space: pre; /* CSS2 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP printers */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
word-wrap: break-word; /* IE */
padding-left: 5px;
}
table.code td.code-lc {
text-align: right;
padding: 1px 5px;
border-color: inherit;
border-top: 1px solid #d3d7cf;
border-bottom: 1px solid #d3d7cf;
width: 3em;
}
table.code td.code-lc a {
color: #555753;
text-decoration: none;
}
/**
* Download
*/
div.download-file {

Archive Download the corresponding diff file