Support for logos in flat design

Closes #401
Part of #337
This commit is contained in:
Thaddee Tyl
2015-04-25 14:37:41 +02:00
parent 86476bca54
commit b1d3e00a21
4 changed files with 26 additions and 7 deletions

View File

@@ -174,7 +174,8 @@ function cache(f) {
incrMonthlyAnalytics(analytics.vendorFlatSquareMonthly);
}
var cacheIndex = match[0] + '?label=' + data.label + '&style=' + data.style;
var cacheIndex = match[0] + '?label=' + data.label + '&style=' + data.style
+ '&logo=' + data.logo + '&logoWidth=' + data.logoWidth;
// Should we return the data right away?
var cached = requestCache.get(cacheIndex);
var cachedVersionSent = false;
@@ -3509,6 +3510,7 @@ function getLabel(label, data) {
return data.label || label;
}
// data (URL query) can include `label`, `style`, `logo`, `logoWidth`.
function getBadgeData(defaultLabel, data) {
var label = getLabel(defaultLabel, data);
var template = data.style || 'default';
@@ -3516,7 +3518,17 @@ function getBadgeData(defaultLabel, data) {
template = data.style;
};
return {text:[label, 'n/a'], colorscheme:'lightgrey', template:template};
if (data.logo !== undefined && !/^data:/.test(data.logo)) {
data.logo = 'data:' + data.logo;
}
return {
text: [label, 'n/a'],
colorscheme: 'lightgrey',
template: template,
logo: data.logo,
logoWidth: +data.logoWidth
};
}
function makeSend(format, askres, end) {