aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-14 13:55:55 -0800
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-15 14:54:42 -1000
commit3688ed73dfac0fcb85ef0aaedfa18febc4f175aa (patch)
tree62a601e2c7bb3c0472f8dedb647e971df78b0ecf
parent602514bc8c31a554b1723fd994306c1515b3999d (diff)
downloadpatchfoo-3688ed73dfac0fcb85ef0aaedfa18febc4f175aa.tar.gz
patchfoo-3688ed73dfac0fcb85ef0aaedfa18febc4f175aa.zip
Render image-map messages
e.g. %VD9QdTWl4oNZtkrkEeKX6rhXPwchrB7J7EiPUqz78xY=.sha256
-rw-r--r--lib/render-msg.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index cb5ae8a..825bb02 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -276,6 +276,7 @@ RenderMsg.prototype.message = function (cb) {
case 'macaco_maluco-sombrio-tombstone': return this.sombrioTombstone(cb)
case 'macaco_maluco-sombrio-score': return this.sombrioScore(cb)
case 'blog': return this.blog(cb)
+ case 'image-map': return this.imageMap(cb)
default: return this.object(cb)
}
}
@@ -1439,3 +1440,29 @@ RenderMsg.prototype.blog = function (cb) {
self.c.summary || '')
)), cb)
}
+
+RenderMsg.prototype.imageMap = function (cb) {
+ var self = this
+ var imgLink = u.toLink(self.c.image)
+ var imgRef = imgLink && imgLink.link
+ var mapName = 'map' + token()
+ self.wrap(h('div', [
+ h('map', {name: mapName},
+ u.toArray(self.c.areas).map(function (areaLink) {
+ var href = areaLink && self.toUrl(areaLink.link)
+ return href ? h('area', {
+ shape: String(areaLink.shape),
+ coords: String(areaLink.coords),
+ href: href,
+ }) : ''
+ })
+ ),
+ imgRef && imgRef[0] === '&' ? h('img', {
+ src: self.render.imageUrl(imgRef),
+ width: Number(imgLink.width) || undefined,
+ height: Number(imgLink.height) || undefined,
+ alt: String(imgLink.name || ''),
+ usemap: '#' + mapName,
+ }) : ''
+ ]), cb)
+}