Indefero

Indefero Commit Details


Date:2011-05-27 17:48:24 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:ee33cc1832c9c0df6c194fcfac61c0c4c7fe20d8
Parents: 82bb18fe10f1d3b337b5fae041485d73dafb40e9
Message:Address files by name rather than ID in the downloads section (issue 686)

Changes:

File differences

NEWS.mdtext
33
44
55
6
67
78
89
## New Features
- Mercurial source views now show parent revisions (if any) and detailed change information
- File download URLs now contain the file name rather than the upload id; old links still work though (issue 686)
## Bugfixes
src/IDF/Views/Download.php
5959
6060
6161
62
62
6363
6464
6565
......
7979
8080
8181
82
82
8383
8484
8585
......
9999
100100
101101
102
102
103103
104104
105105
106106
107107
108108
109
109
110110
111111
112
112
113113
114114
115115
......
162162
163163
164164
165
165
166166
167167
168168
......
171171
172172
173173
174
174
175175
176176
177177
178
178
179179
180180
181181
......
190190
191191
192192
193
193
194194
195195
196196
197197
198198
199
199
200
201
200202
201203
202204
......
204206
205207
206208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
207223
208224
209225
......
218234
219235
220236
221
237
222238
223239
224
240
225241
226242
227243
......
246262
247263
248264
249
265
250266
251267
252268
......
354370
355371
356372
357
373
358374
359375
360376
$sql .= ' AND id NOT IN ('.implode(',', $ids).')';
}
$pag->forced_where = new Pluf_SQL($sql, array($prj->id));
$list_display = array(
'file' => __('File'),
array('summary', 'IDF_Views_Download_SummaryAndLabels', __('Summary')),
'dlabel' => $dtag,
),
$request);
}
/**
$deprecated = Pluf_Model_InArray($dtag, $tags);
if ($request->method == 'POST' and
true === IDF_Precondition::projectMemberOrOwner($request)) {
$form = new IDF_Form_UpdateUpload($request->POST,
array('project' => $prj,
'upload' => $upload,
'user' => $request->user));
if ($form->isValid()) {
$upload = $form->save();
$urlfile = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view',
$urlfile = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view',
array($prj->shortname, $upload->id));
$request->user->setMessage(sprintf(__('The file <a href="%1$s">%2$s</a> has been updated.'), $urlfile, Pluf_esc($upload->file)));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
* [description]
*
* This signal allows an application to perform a set of tasks
* just before the deletion of the corresponding object in the
* just before the deletion of the corresponding object in the
* database but just after the deletion from the storage.
*
* [parameters]
*
*/
$params = array('upload' => $upload);
Pluf_Signal::send('IDF_Upload::delete',
Pluf_Signal::send('IDF_Upload::delete',
'IDF_Views_Download', $params);
$upload->delete();
$request->user->setMessage(__('The file has been deleted.'));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
}
/**
* Download a file.
* Download the file with the given name.
*/
public $download_precond = array('IDF_Precondition::accessDownloads');
public function download($request, $match)
{
$prj = $request->project;
$upload = Pluf_Shortcuts_GetObjectOr404('IDF_Upload', $match[2]);
$sql = new Pluf_SQL('file=%s', array($match[2]));
$upload = Pluf::factory('IDF_Upload')->getOne(array('filter' => $sql->gen()));
if (!$upload) throw new Pluf_HTTP_Error404();
$prj->inOr404($upload);
$upload->downloads += 1;
$upload->update();
}
/**
* Download the file with the given ID (for legacy links).
*/
public $downloadById_precond = array('IDF_Precondition::accessDownloads');
public function downloadById($request, $match)
{
$upload = Pluf_Shortcuts_GetObjectOr404('IDF_Upload', $match[2]);
return new Pluf_HTTP_Response_Redirect(
Pluf_HTTP_URL_urlForView('IDF_Views_Download::download', array(
$match[1], $upload->file
)), 301
);
}
/**
* Submit a new file for download.
*/
public $submit_precond = array('IDF_Precondition::accessDownloads',
'user' => $request->user));
if ($form->isValid()) {
$upload = $form->save();
$urlfile = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view',
$urlfile = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view',
array($prj->shortname, $upload->id));
$request->user->setMessage(sprintf(__('The <a href="%s">file</a> has been uploaded.'), $urlfile));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
{
$conf = new IDF_Conf();
$conf->setProject($project);
$st = preg_split("/\015\012|\015|\012/",
$st = preg_split("/\015\012|\015|\012/",
$conf->getVal('labels_download_predefined', IDF_Form_UploadConf::init_predefined), -1, PREG_SPLIT_NO_EMPTY);
$auto = '';
foreach ($st as $s) {
{
$tags = array();
foreach ($down->get_tags_list() as $tag) {
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::listLabel',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::listLabel',
array($down->shortname, $tag->id));
$tags[] = sprintf('<a href="%s" class="label">%s</a>', $url, Pluf_esc((string) $tag));
}
src/IDF/conf/urls.php
7373
7474
7575
76
76
7777
7878
7979
......
294294
295295
296296
297
297
298298
299299
300300
301301
302
303
304
305
306
302307
303308
304309
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'home');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/logo/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'model' => 'IDF_Views_Download',
'method' => 'view');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/downloads/(\d+)/get/$#',
$ctl[] = array('regex' => '#^/p/([\-\w]+)/downloads/get/(.+)$#',
'base' => $base,
'model' => 'IDF_Views_Download',
'method' => 'download');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/downloads/(\d+)/get/$#',
'base' => $base,
'model' => 'IDF_Views_Download',
'method' => 'downloadById');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/downloads/create/$#',
'base' => $base,
'model' => 'IDF_Views_Download',
src/IDF/templates/idf/downloads/delete.html
33
44
55
6
6
77
88
99
......
1515
1616
1717
18
18
1919
2020
2121
{block body}
<div class="download-file">
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.id)}">{$file}</a> - {$file.filesize|size}
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.file)}">{$file}</a> - {$file.filesize|size}
</div>
<p>{blocktrans}<strong>Attention!</strong> If you want to delete a specific version of your software, maybe, someone is depending on this specific version to run his systems. Are you sure, you will not affect anybody when removing this file?{/blocktrans}</p>
<table class="form" summary="">
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="{trans 'Delete File'}" name="submit" /> | <a href="{url 'IDF_Views_Download::index', array($project.shortname)}">{trans 'Cancel'}</a>
<td><input type="submit" value="{trans 'Delete File'}" name="submit" /> | <a href="{url 'IDF_Views_Download::index', array($project.shortname)}">{trans 'Cancel'}</a>
</td>
</tr>
</table>
src/IDF/templates/idf/downloads/view.html
44
55
66
7
7
88
99
1010
<div class="download-file">
{if $deprecated}<p class="smaller">{blocktrans}<strong>Attention!</strong> This file is marked as deprecated, download it only if you are sure you need this specific version.{/blocktrans}</p>{/if}
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.id)}">{$file}</a> - {$file.filesize|size}
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.file)}">{$file}</a> - {$file.filesize|size}
</div>
{if $file.changelog}
<h2 class="changes">{trans 'Changes'}</h2>

Archive Download the corresponding diff file

Page rendered in 0.09656s using 14 queries.