diff options
-rw-r--r-- | lib/render-msg.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index 72ab73b..1fd4d83 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -262,6 +262,7 @@ RenderMsg.prototype.message = function (cb) { case 'npm-packages': return this.npmPackages(cb) case 'npm-prebuilds': return this.npmPrebuilds(cb) case 'acme-challenges-http-01': return this.acmeChallengesHttp01(cb) + case 'bookclub': return this.bookclub(cb) default: return this.object(cb) } } @@ -383,6 +384,8 @@ RenderMsg.prototype.title1 = function (cb) { cb(null, title(self.c.msg)) else if (self.c.type === 'chess_invite') self.chessInviteTitle(cb) + else if (self.c.type === 'bookclub') + self.bookclubTitle(cb) else self.app.getAbout(self.msg.key, function (err, about) { if (err) return cb(err) @@ -456,6 +459,8 @@ var knownAboutProps = { startDateTime: true, endDateTime: true, location: true, + rating: true, + ratingType: true, } RenderMsg.prototype.about = function (cb) { @@ -519,12 +524,28 @@ RenderMsg.prototype.about = function (cb) { src: this.render.imageUrl(img), alt: ' ', })) : '', + this.c.rating != null ? this.aboutRating() : '', extras ? this.valueTable(extras, 1, done()) : '' ], elCb) done(cb) } +RenderMsg.prototype.aboutRating = function (cb) { + var rating = Number(this.c.rating) + var type = this.c.ratingType || '★' + var text = rating + ' ' + type + if (isNaN(rating)) return 'rating: ' + text + if (rating > 5) rating = 5 + var el = h('div', {title: text}) + for (var i = 0; i < rating; i++) { + el.appendChild(h('span', + {innerHTML: unwrapP(this.render.markdown(type) + ' ')} + )) + } + return el +} + RenderMsg.prototype.contact = function (cb) { var self = this self.link(self.c.contact, function (err, a) { @@ -1287,3 +1308,33 @@ RenderMsg.prototype.acmeChallengesHttp01 = function (cb) { }), ', ', ', and ') ), cb) } + +RenderMsg.prototype.bookclub = function (cb) { + var self = this + var props = self.c.common || self.c + var images = u.toLinkArray(props.image || props.images) + self.wrap(h('table', h('tr', + h('td', + images.map(function (image) { + return h('a', {href: self.render.toUrl(image.link)}, h('img', { + src: self.render.imageUrl(image.link), + alt: image.name || ' ', + width: 180, + })) + })), + h('td', + h('h4', props.title), + props.authors ? + h('p', h('em', props.authors)) + : '', + props.description + ? h('div', {innerHTML: self.render.markdown(props.description)}) + : '' + ) + )), cb) +} + +RenderMsg.prototype.bookclubTitle = function (cb) { + var props = this.c.common || this.c + cb(null, props.title || 'book') +} |