author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 26 May 2010 12:31:37 +0200 | |
branch | stable |
changeset 5585 | e1cbf6b304ea |
parent 5424 | 8ecbcbff9777 |
child 5444 | f7fdb5dd82f6 |
child 5866 | e676a869a3e9 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""Specific views for entities implementing IDownloadable |
19 |
||
20 |
""" |
|
21 |
__docformat__ = "restructuredtext en" |
|
1639 | 22 |
_ = unicode |
0 | 23 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
24 |
from logilab.mtconverter import BINARY_ENCODINGS, TransformError, xml_escape |
0 | 25 |
|
1639 | 26 |
from cubicweb.view import EntityView |
692
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
631
diff
changeset
|
27 |
from cubicweb.selectors import (one_line_rset, score_entity, |
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
631
diff
changeset
|
28 |
implements, match_context_prop) |
0 | 29 |
from cubicweb.interfaces import IDownloadable |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
30 |
from cubicweb.mttransforms import ENGINE |
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
31 |
from cubicweb.web.box import EntityBoxTemplate |
1639 | 32 |
from cubicweb.web.views import primary, baseviews |
0 | 33 |
|
34 |
||
985
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
35 |
def is_image(entity): |
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
36 |
mt = entity.download_content_type() |
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
37 |
if not (mt and mt.startswith('image/')): |
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
38 |
return 0 |
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
39 |
return 1 |
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
40 |
|
3846
1a7d10864628
new argument to provide extra content
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3789
diff
changeset
|
41 |
def download_box(w, entity, title=None, label=None, footer=u''): |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
42 |
req = entity._cw |
1885
c2011d238e98
replace sideRelated with sideBox
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1639
diff
changeset
|
43 |
w(u'<div class="sideBox">') |
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
44 |
if title is None: |
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
45 |
title = req._('download') |
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
46 |
w(u'<div class="sideBoxTitle downloadBoxTitle"><span>%s</span></div>' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
47 |
% xml_escape(title)) |
0 | 48 |
w(u'<div class="sideBox downloadBox"><div class="sideBoxBody">') |
49 |
w(u'<a href="%s"><img src="%s" alt="%s"/> %s</a>' |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
50 |
% (xml_escape(entity.download_url()), |
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
51 |
req.external_resource('DOWNLOAD_ICON'), |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
52 |
_('download icon'), xml_escape(label or entity.dc_title()))) |
3846
1a7d10864628
new argument to provide extra content
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3789
diff
changeset
|
53 |
w(u'%s</div>' % footer) |
1a7d10864628
new argument to provide extra content
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3789
diff
changeset
|
54 |
w(u'</div></div>\n') |
0 | 55 |
|
985
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
56 |
|
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
57 |
class DownloadBox(EntityBoxTemplate): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3072
diff
changeset
|
58 |
__regid__ = 'download_box' |
985
6a25c58a1c23
backport stable branch, take care a lot of conflicts occured, this may be the revision you're looking for...
sylvain.thenault@logilab.fr
diff
changeset
|
59 |
# no download box for images |
957
b1f68f725fe9
don't show download box nor download link for images, by default hide name attribute even if not specified in the interface
sylvain.thenault@logilab.fr
parents:
431
diff
changeset
|
60 |
# XXX primary_view selector ? |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
61 |
__select__ = (one_line_rset() & implements(IDownloadable) & |
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
62 |
match_context_prop() & ~score_entity(is_image)) |
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
63 |
order = 10 |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
64 |
|
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
65 |
def cell_call(self, row, col, title=None, label=None, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
66 |
entity = self.cw_rset.get_entity(row, col) |
249
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
67 |
download_box(self.w, entity, title, label) |
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
68 |
|
5ab64969df20
define an actual download box, keeping download_box function for bw compat
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
69 |
|
1639 | 70 |
class DownloadView(EntityView): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
431
diff
changeset
|
71 |
"""this view is replacing the deprecated 'download' controller and allow |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
431
diff
changeset
|
72 |
downloading of entities providing the necessary interface |
0 | 73 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3072
diff
changeset
|
74 |
__regid__ = 'download' |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
75 |
__select__ = one_line_rset() & implements(IDownloadable) |
0 | 76 |
|
77 |
templatable = False |
|
78 |
content_type = 'application/octet-stream' |
|
79 |
binary = True |
|
80 |
add_to_breadcrumbs = False |
|
81 |
||
82 |
def set_request_content_type(self): |
|
83 |
"""overriden to set the correct filetype and filename""" |
|
4382
6fb02edd05da
3.6 api update, cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
84 |
entity = self.cw_rset.complete_entity(0, 0) |
0 | 85 |
encoding = entity.download_encoding() |
86 |
if encoding in BINARY_ENCODINGS: |
|
87 |
contenttype = 'application/%s' % encoding |
|
88 |
encoding = None |
|
89 |
else: |
|
90 |
contenttype = entity.download_content_type() |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
91 |
self._cw.set_content_type(contenttype or self.content_type, |
0 | 92 |
filename=entity.download_file_name(), |
93 |
encoding=encoding) |
|
94 |
||
95 |
def call(self): |
|
4382
6fb02edd05da
3.6 api update, cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
96 |
self.w(self.cw_rset.complete_entity(0, 0).download_data()) |
0 | 97 |
|
98 |
||
1639 | 99 |
class DownloadLinkView(EntityView): |
0 | 100 |
"""view displaying a link to download the file""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3072
diff
changeset
|
101 |
__regid__ = 'downloadlink' |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
102 |
__select__ = implements(IDownloadable) |
0 | 103 |
title = None # should not be listed in possible views |
104 |
||
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
105 |
|
0 | 106 |
def cell_call(self, row, col, title=None, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
107 |
entity = self.cw_rset.get_entity(row, col) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
108 |
url = xml_escape(entity.download_url()) |
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
109 |
self.w(u'<a href="%s">%s</a>' % (url, xml_escape(title or entity.dc_title()))) |
0 | 110 |
|
111 |
||
1639 | 112 |
class IDownloadablePrimaryView(primary.PrimaryView): |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
113 |
__select__ = implements(IDownloadable) |
0 | 114 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1498
diff
changeset
|
115 |
def render_entity_attributes(self, entity): |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1498
diff
changeset
|
116 |
super(IDownloadablePrimaryView, self).render_entity_attributes(entity) |
0 | 117 |
self.w(u'<div class="content">') |
118 |
contenttype = entity.download_content_type() |
|
119 |
if contenttype.startswith('image/'): |
|
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
120 |
self.wview('image', entity.cw_rset, row=entity.cw_row) |
0 | 121 |
else: |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
122 |
self.wview('downloadlink', entity.cw_rset, title=self._cw._('download'), row=entity.cw_row) |
0 | 123 |
try: |
124 |
if ENGINE.has_input(contenttype): |
|
125 |
self.w(entity.printable_value('data')) |
|
126 |
except TransformError: |
|
127 |
pass |
|
128 |
except Exception, ex: |
|
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
129 |
msg = self._cw._("can't display data, unexpected error: %s") \ |
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
130 |
% xml_escape(str(ex)) |
0 | 131 |
self.w('<div class="error">%s</div>' % msg) |
132 |
self.w(u'</div>') |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
133 |
|
0 | 134 |
|
135 |
class IDownloadableLineView(baseviews.OneLineView): |
|
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
136 |
__select__ = implements(IDownloadable) |
0 | 137 |
|
138 |
def cell_call(self, row, col, title=None, **kwargs): |
|
2530 | 139 |
"""the oneline view is a link to download the file""" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
140 |
entity = self.cw_rset.get_entity(row, col) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
141 |
url = xml_escape(entity.absolute_url()) |
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
142 |
name = xml_escape(title or entity.download_file_name()) |
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2136
diff
changeset
|
143 |
durl = xml_escape(entity.download_url()) |
0 | 144 |
self.w(u'<a href="%s">%s</a> [<a href="%s">%s</a>]' % |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
145 |
(url, name, durl, self._cw._('download'))) |
0 | 146 |
|
147 |
||
1639 | 148 |
class ImageView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3072
diff
changeset
|
149 |
__regid__ = 'image' |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
150 |
__select__ = implements(IDownloadable) & score_entity(is_image) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
151 |
|
0 | 152 |
title = _('image') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
153 |
|
0 | 154 |
def call(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
155 |
rset = self.cw_rset |
0 | 156 |
for i in xrange(len(rset)): |
157 |
self.w(u'<div class="efile">') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
158 |
self.wview(self.__regid__, rset, row=i, col=0) |
0 | 159 |
self.w(u'</div>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
987
diff
changeset
|
160 |
|
2524
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
161 |
def cell_call(self, row, col, width=None, height=None, link=False): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
162 |
entity = self.cw_rset.get_entity(row, col) |
0 | 163 |
#if entity.data_format.startswith('image/'): |
3065
694c03f7d72f
<a> doesn't have alt attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2530
diff
changeset
|
164 |
imgtag = u'<img src="%s" alt="%s" ' % ( |
694c03f7d72f
<a> doesn't have alt attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2530
diff
changeset
|
165 |
xml_escape(entity.download_url()), |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
166 |
(self._cw._('download %s') % xml_escape(entity.download_file_name()))) |
2524
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
167 |
if width: |
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
168 |
imgtag += u'width="%i" ' % width |
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
169 |
if height: |
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
170 |
imgtag += u'height="%i" ' % height |
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
171 |
imgtag += u'/>' |
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
172 |
if link: |
3065
694c03f7d72f
<a> doesn't have alt attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2530
diff
changeset
|
173 |
self.w(u'<a href="%s">%s</a>' % (entity.absolute_url(vid='download'), |
694c03f7d72f
<a> doesn't have alt attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2530
diff
changeset
|
174 |
imgtag)) |
2524
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
175 |
else: |
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
176 |
self.w(imgtag) |
0 | 177 |
|
2524
2d0c04c8cbe4
#344787: add options to idownloadable
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2470
diff
changeset
|
178 |