From f1a5a804e834cebf71c10b83197b11d8fadd26a4 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 26 Aug 2018 18:44:08 -0700 Subject: Render bookclub messages better --- lib/render-msg.js | 56 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/render-msg.js b/lib/render-msg.js index 9a08a5d..aee5e4d 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -545,10 +545,15 @@ var knownAboutProps = { startDateTime: true, endDateTime: true, location: true, - /* + review: true, rating: true, ratingType: true, - */ + ratingMax: true, + authors: true, + shelve: true, + genre: true, + series: true, + seriesNo: true, 'talenet-version': true, } @@ -611,16 +616,30 @@ RenderMsg.prototype.about = function (cb) { h('small', '> ', this.link1(this.c.root, done())) ) : '', isSelf ? 'self-describes as ' : [ - 'describes ', + this.c.review ? 'reviews' : 'describes', ' ', !this.c.about ? '' : showComputedName ? this.link1(this.c.about, done()) : h('a', {href: this.toUrl(this.c.about)}, truncate(this.c.about, 10)), - ' as ' + ': ' ], this.c.name ? [h('ins', String(this.c.name)), ' '] : '', this.c.title ? h('h3', String(this.c.title)) : '', + this.c.series || this.c.seriesNo ? this.renderSeries(this.c) : '', + this.c.authors ? h('div', h('em', {title: 'authors'}, String(this.c.authors))) : '', + this.c.rating || this.c.ratingMax || this.c.ratingType ? h('div', [ + 'rating: ', + String(this.c.rating), + this.c.ratingMax ? '/' + this.c.ratingMax : '', + this.c.ratingType ? [' ', + h('span', {innerHTML: u.unwrapP(this.render.markdown(this.c.ratingType))}) + ] : '' + ]) : '', + this.c.genre ? h('div', ['genre: ', h('u', String(this.c.genre))]) : '', + this.c.shelve ? h('div', ['shelf: ', h('u', String(this.c.shelve))]) : '', this.c.description ? h('div', {innerHTML: this.render.markdown(this.c.description)}) : '', + this.c.review ? h('blockquote', + {innerHTML: this.render.markdown(this.c.review)}) : '', this.c.attendee ? h('div', this.link1(this.c.attendee.link, done()), this.c.attendee.remove ? ' is not attending' : ' is attending' @@ -635,32 +654,18 @@ 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) } -/* - * disabled until it's clearer how to do this -cel 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: u.unwrapP(this.render.markdown(type) + ' ')} - )) - } - return el + var max = Number(this.c.ratingMax) + var type = this.c.ratingType + } -*/ RenderMsg.prototype.contact = function (cb) { var self = this @@ -1472,6 +1477,14 @@ RenderMsg.prototype.acmeChallengesHttp01 = function (cb) { ), cb) } +RenderMsg.prototype.renderSeries = function (o) { + return h('div', [ + o.series ? h('span', {title: 'series'}, o.series) : '', + o.series && o.seriesNo ? ': ' : '', + o.seriesNo ? h('span', {title: 'series no'}, o.seriesNo) : '', + ]) +} + RenderMsg.prototype.bookclub = function (cb) { var self = this var props = self.c.common || self.c @@ -1487,6 +1500,7 @@ RenderMsg.prototype.bookclub = function (cb) { })), h('td', h('h4', String(props.title)), + props.series || props.seriesNo ? self.renderSeries(props) : '', props.authors ? h('p', h('em', String(props.authors))) : '', -- cgit v1.2.3