Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit fdb5fcd

Browse files
committed
show 16px icons for creatured apps (bug 784557)
1 parent 66e6917 commit fdb5fcd

8 files changed

Lines changed: 113 additions & 13 deletions

File tree

media/css/mkt/tile.less

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,72 @@
3131
}
3232

3333
.product-details .mkt-tile .icon.mobile_tile,
34-
.listing .mkt-tile .icon.mobile_tile {
34+
.listing .mkt-tile .icon.mobile_tile,
35+
.mkt-tile .icon.featured_tile {
3536
display: none;
3637
}
3738

39+
.creatured .mkt-tile .icon,
3840
.featured .mkt-tile .icon {
3941
display: none;
4042
&.mobile_tile {
4143
display: block;
4244
}
4345
}
4446

47+
@media (max-width: 480px) {
48+
.creatured .grid,
49+
.creatured .grid li {
50+
padding: 0;
51+
}
52+
.creatured .grid li + li {
53+
border-left: 1px solid rgba(0,0,0,.4);
54+
}
55+
.creatured .grid {
56+
.mkt-tile {
57+
background: @grain-src darken(@grain, 15%);
58+
.info, &:hover .info, &:active .info {
59+
background: transparent;
60+
}
61+
&:hover {
62+
background-color: darken(@grain, 12%);
63+
}
64+
&:active {
65+
.depressed;
66+
}
67+
.info {
68+
.box-shadow(none);
69+
height: auto;
70+
position: static;
71+
}
72+
h3 {
73+
color: @white;
74+
padding-left: 18px;
75+
}
76+
.rating {
77+
color: @medium-gray;
78+
font-size: 11px;
79+
}
80+
canvas {
81+
display: none;
82+
}
83+
.icon {
84+
&.featured_tile {
85+
display: block;
86+
position: absolute;
87+
top: 6px;
88+
left: 2px;
89+
height: 16px;
90+
width: 16px;
91+
}
92+
&.mobile_tile {
93+
display: none;
94+
}
95+
}
96+
}
97+
}
98+
}
99+
45100
// Listing
46101
// name + icon + price + rating in a vertical listview.
47102
// also used as standalone "card" on detail pages.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from amo.utils import chunked
2+
3+
from mkt.developers.tasks import generate_image_assets
4+
from mkt.webapps.models import Webapp
5+
6+
7+
def run():
8+
"""Generate featured tiles."""
9+
for chunk in chunked(Webapp.objects.all(), 50):
10+
for app in chunk:
11+
generate_image_assets.delay(app, slug='featured_tile')
12+
print u'Generated feature tile for %s' % app

mkt/constants/submit.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@
1111

1212
# The sizes for the image assets for apps.
1313
APP_IMAGE_SIZES = [
14+
{'size': (32, 32),
15+
'has_background': False,
16+
'required': False,
17+
'slug': 'featured_tile',
18+
'name': 'Featured Tile',
19+
'description': _("The icon shown when your app is featured at the top of "
20+
"category landing pages.")},
1421
{'size': (106, 106),
1522
'has_background': False,
1623
'required': False,
1724
'slug': 'mobile_tile',
1825
'name': 'Mobile Tile',
19-
'description': _("The image that's actually used for the app's tile in "
20-
"the Marketplace.")},
26+
'description': _("The image used for the app's tile in the mobile "
27+
"Marketplace.")},
2128
{'size': (150, 130),
2229
'has_background': False,
2330
'required': False,

mkt/developers/tasks.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,12 @@ def generate_image_assets(addon, **kw):
228228

229229
backdrop = _generate_image_asset_backdrop(icon_hue, biggest_size)
230230

231+
# Sometimes you want to regenerate only assets of a particular type.
232+
slug = kw.get('slug')
233+
231234
for asset in APP_IMAGE_SIZES:
235+
if slug and slug != asset['slug']:
236+
continue
232237
try:
233238
generate_image_asset(addon, asset, icon, hue=icon_hue,
234239
backdrop=backdrop.copy(), **kw)
@@ -263,8 +268,13 @@ def generate_image_asset(addon, asset, icon, **kw):
263268

264269
# Get a copy of the icon.
265270
asset_icon = icon.copy()
266-
# The icon will be 95% of the size of the shortest edge of the asset.
267-
min_edge = int(min(asset['size']) * 0.75)
271+
272+
# The icon will be 75% of the size of the shortest edge of the asset if
273+
# larger than 32px.
274+
min_edge = min(asset['size'])
275+
if min_edge > 32:
276+
min_edge = int(min_edge * 0.75)
277+
268278
if min_edge < asset_icon.size[0]:
269279
asset_icon = asset_icon.resize((min_edge, min_edge), Image.ANTIALIAS)
270280

mkt/developers/tests/test_tasks.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _uploader(resize_size, final_size):
8989
with storage.open("%s-%s.png" % (dest_name, rsize)) as fp:
9090
dest_image = Image.open(fp)
9191
dest_image.load()
92-
92+
9393
# Assert that the width is always identical.
9494
eq_(dest_image.size[0], fsize[0])
9595
# Assert that the height can be a wee bit fuzzy.
@@ -106,7 +106,7 @@ def _uploader(resize_size, final_size):
106106
with storage.open(dest.name) as fp:
107107
dest_image = Image.open(fp)
108108
dest_image.load()
109-
109+
110110
# Assert that the width is always identical.
111111
eq_(dest_image.size[0], final_size[0])
112112
# Assert that the height can be a wee bit fuzzy.
@@ -124,7 +124,7 @@ def test_resize_image_asset():
124124
src_image = Image.open(fp)
125125
eq_(src_image.size, original_size)
126126

127-
dest = tempfile.NamedTemporaryFile(mode='r+w+b', suffix=".png")
127+
dest = tempfile.NamedTemporaryFile(mode='r+w+b', suffix='.png')
128128
# Make it resize to some arbitrary size that's larger on both sides than
129129
# the source image. This is where the behavior differs from resize_image.
130130
tasks.resize_imageasset(img, dest.name, (500, 500), locally=True)
@@ -195,7 +195,6 @@ def _mock_hide_64px_icon(path, *args, **kwargs):
195195

196196
class TestGenerateImageAssets(amo.tests.TestCase):
197197
"""Test that image assets get generated properly."""
198-
199198
fixtures = ['webapps/337141-steamcube']
200199

201200
def setUp(self):
@@ -213,6 +212,20 @@ def test_generated_image_assets(self):
213212
im.load()
214213
eq_(im.size, asset['size'])
215214

215+
def test_generated_image_assets_slug(self):
216+
# We're going to generate assets for only one type.
217+
asset = APP_IMAGE_SIZES[0]
218+
slug = asset['slug']
219+
220+
tasks.generate_image_assets(self.app, slug=slug)
221+
ia = ImageAsset.objects.filter(addon=self.app)
222+
eq_(list(a.slug for a in ia), [slug])
223+
224+
with storage.open(ia[0].image_path) as fp:
225+
im = Image.open(fp)
226+
im.load()
227+
eq_(im.size, asset['size'])
228+
216229
@mock.patch('django.core.files.storage.default_storage.open',
217230
_mock_hide_64px_icon)
218231
def test_use_64(self):

mkt/search/templates/search/results.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,18 @@ <h2>{{ _('Sort by') }}</h2>
110110
</form>
111111
</div>
112112
</section>
113-
<section id="search-results" class="full c">
113+
<section id="featured" class="creatured full c">
114114
{% if featured %}
115-
<ol class="grid featured c">
115+
<ol class="grid c">
116116
{% for app in featured %}
117117
<li>
118118
{{ market_tile(app, src=src + '-featured') }}
119119
</li>
120120
{% endfor %}
121121
</ol>
122122
{% endif %}
123+
</section>
124+
<section id="search-results" class="full c">
123125
{% if pager.object_list %}
124126
<ol class="listing c" start="{{ pager.start_index() }}">
125127
{{ search_results(pager.object_list, field=query.sort, src=src) }}

mkt/site/templates/site/tiles/app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<{{ tag }} class="{{ classes }}"
88
{% if link %}href="{{ product.get_url_path()|urlparams(src=data_attrs.src) }}"{% endif %}
99
{% for k, v in data_attrs.items() %} data-{{ k }}="{{ v }}"{% endfor %}>
10+
<div class="icon featured_tile" style="background-image:url({{ product.get_image_asset_url('featured_tile', 16) }})"></div>
1011
<img class="icon mobile_tile" alt="{{ _('icon') }}"
1112
src="{{ product.get_image_asset_url('mobile_tile') }}"
1213
data-hue="{{ product.get_image_asset_hue('mobile_tile') }}">

mkt/webapps/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def get_stats_inapp_url(self, action='revenue', inapp='', args=None):
219219
args=[self.app_slug, urlquote(inapp)])
220220
return url
221221

222-
def get_image_asset_url(self, slug):
222+
def get_image_asset_url(self, slug, default=64):
223223
"""
224224
Returns the URL for an app's image asset that uses the slug specified
225225
by `slug`.
@@ -231,7 +231,7 @@ def get_image_asset_url(self, slug):
231231
try:
232232
return ImageAsset.objects.get(addon=self, slug=slug).image_url
233233
except ImageAsset.DoesNotExist:
234-
return settings.MEDIA_URL + 'img/hub/default-64.png'
234+
return settings.MEDIA_URL + 'img/hub/default-%s.png' % str(default)
235235

236236
def get_image_asset_hue(self, slug):
237237
"""

0 commit comments

Comments
 (0)