Indefero

Indefero Commit Details


Date:2008-12-30 11:00:59 (15 years 11 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:2078d69a838a7cb52ae984d42df75920358cfce7
Parents: e6b19a695bf65d92fcabc28933fde68dbe170738
Message:Added ticket 86, preview attached files to issues.

Changes:

File differences

src/IDF/Views/Issue.php
323323
324324
325325
326
327
328
329
330
326331
327
328
332
333
334
335
329336
330337
331338
332339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
333371
334372
335373
$prj = $request->project;
$attach = Pluf_Shortcuts_GetObjectOr404('IDF_IssueFile', $match[2]);
$prj->inOr404($attach->get_comment()->get_issue());
$info = IDF_Views_Source::getMimeType($attach->filename);
$mime = 'application/octet-stream';
if (strpos($info[0], 'image/') === 0) {
$mime = $info[0];
}
$res = new Pluf_HTTP_Response_File(Pluf::f('upload_issue_path').'/'.$attach->attachment,
'application/octet-stream');
$res->headers['Content-Disposition'] = 'attachment; filename="'.$attach->filename.'"';
$mime);
if ($mime == 'application/octet-stream') {
$res->headers['Content-Disposition'] = 'attachment; filename="'.$attach->filename.'"';
}
return $res;
}
/**
* View a given attachment.
*/
public $viewAttachment_precond = array('IDF_Precondition::accessIssues');
public function viewAttachment($request, $match)
{
$prj = $request->project;
$attach = Pluf_Shortcuts_GetObjectOr404('IDF_IssueFile', $match[2]);
$prj->inOr404($attach->get_comment()->get_issue());
// If one cannot see the attachement, redirect to the
// getAttachment view.
$info = IDF_Views_Source::getMimeType($attach->filename);
if (!IDF_Views_Source::isText($info)) {
return $this->getAttachment($request, $match);
}
// Now we want to look at the file but with links back to the
// issue.
$file = IDF_Views_Source::highLight($info,
file_get_contents(Pluf::f('upload_issue_path').'/'.$attach->attachment));
$title = sprintf(__('View %s'), $attach->filename);
return Pluf_Shortcuts_RenderToResponse('idf/issues/attachment.html',
array(
'attachment' => $attach,
'page_title' => $title,
'comment' => $attach->get_comment(),
'issue' => $attach->get_comment()->get_issue(),
'file' => $file,
),
$request);
}
/**
* View list of issues for a given project with a given status.
*/
public $listStatus_precond = array('IDF_Precondition::accessIssues');
src/IDF/Views/Source.php
401401
402402
403403
404
404
405405
406406
407407
if (0 === strpos($fileinfo[0], 'text/')) {
return true;
}
$ext = 'mdtext php js cpp php-dist h gitignore sh py pl rb '
$ext = 'mdtext php js cpp php-dist h gitignore sh py pl rb diff patch'
.Pluf::f('idf_extra_text_ext', '');
return (in_array($fileinfo[2], explode(' ', $ext)));
}
src/IDF/conf/urls.php
174174
175175
176176
177
178
179
180
181
182
177183
178184
179185
'model' => 'IDF_Views_Issue',
'method' => 'getAttachment');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/view/attachment/(\d+)/(.*)$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Issue',
'method' => 'viewAttachment');
// ---------- SCM ----------------------------------------
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/tree/([^/]+)/$#',
src/IDF/templates/idf/issues/attachment.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{extends "idf/issues/base.html"}
{block extraheader}<link rel="stylesheet" type="text/css" href="{media '/idf/css/prettify.css'}" />{/block}
{block docclass}yui-t2{assign $inIssue=true}{/block}
{block body}
<table class="code" summary=" ">
<tbody>
{$file}
</tbody>
</table>
{aurl 'url', 'IDF_Views_Issue::getAttachment', array($project.shortname, $attachment.id, $attachment.filename)}
<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}
{aurl 'url', 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
{assign $url = $url~'#ic'~$comment.id}
<p>{blocktrans}Attachment to issue <a href="{$url}">{$issue.id}</a>{/blocktrans}</p>
{ashowuser 'submitter', $attachment.get_submitter(), $request}
<p><strong>{trans 'Created:'}</strong> <span class="nobrk">{$attachment.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
{/block}
{block javascript}
<script type="text/javascript" src="{media '/idf/js/prettify.js'}"></script>
<script type="text/javascript">prettyPrint();</script>
{/block}
src/IDF/templates/idf/issues/base.html
88
99
1010
11
12
13
14
1115
1216
1317
<input accesskey="4" type="text" value="{$q}" name="q" size="20" />
<input type="submit" name="s" value="{trans 'Search'}" />
</form>
{if $inIssue} |
{aurl 'url', 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
<a href="{$url}">{trans 'Back to the issue'}</a>
{/if}
{superblock}
</div>
{/block}
src/IDF/templates/idf/issues/issue-created-email.txt
1616
1717
1818
19
19
2020
2121
2222
{if $attachments.count() > 0}
{trans 'Attachments:'}{foreach $attachments as $a}
- {$a.filename|safe} - {$a.filesize|ssize}
{$url_base}{url 'IDF_Views_Issue::getAttachment', array($project.shortname, $a.id, $a.filename)}{/foreach}
{$url_base}{url 'IDF_Views_Issue::viewAttachment', array($project.shortname, $a.id, $a.filename)}{/foreach}
{/if}
--
{trans 'Issue:'} {$url_base}{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
src/IDF/templates/idf/issues/issue-updated-email.txt
2020
2121
2222
23
23
2424
2525
2626
{trans 'Attachments:'}{foreach $attachments as $a}
- {$a.filename|safe} - {$a.filesize|ssize}
{$url_base}{url 'IDF_Views_Issue::getAttachment', array($project.shortname, $a.id, $a.filename)}{/foreach}
{$url_base}{url 'IDF_Views_Issue::viewAttachment', array($project.shortname, $a.id, $a.filename)}{/foreach}
{/if}
{/foreach}
src/IDF/templates/idf/issues/view.html
2020
2121
2222
23
23
2424
2525
2626
{if $attachments.count() > 0}
<hr align="left" class="attach" />
<ul>
{foreach $attachments as $a}<li><a href="{url 'IDF_Views_Issue::getAttachment', array($project.shortname, $a.id, $a.filename)}">{$a.filename}</a> - {$a.filesize|size}</li>{/foreach}
{foreach $attachments as $a}<li><a href="{url 'IDF_Views_Issue::viewAttachment', array($project.shortname, $a.id, $a.filename)}">{$a.filename}</a> - {$a.filesize|size}</li>{/foreach}
</ul>{/if}
{if $i> 0 and $c.changedIssue()}
<div class="issue-changes">

Archive Download the corresponding diff file

Page rendered in 0.09764s using 14 queries.