zuzak/gov.zk

View on GitHub
views/books/book-view.pug

Summary

Maintainability
Test Coverage
//- vim:ft=jade
extends ../skeleton
block title
  title #{book.title}
block breadcrumb
  li
    a(href=__('/book-club')) #{__('book-club')}
  li
    a(href=__('/book-club/long-list')) #{__('book')}
  li
    a #{book.title}
block css
  link(rel='stylesheet', href='/shortlist.css')
block content
  - title = book.title
  - author = book.author
  if book.upstream
    - title = book.upstream.title
    - author = book.upstream.authors.join(' & ')
  .grid-row
    .column-full
      h1.heading-xlarge.title #{title}
  .grid-row
    .column-two-thirds
      .grid-row
        .column-two-thirds
          if book.upstream
            p.lede #{__('book-' + book.upstream.printType.toLowerCase() + '-by', {author: author})} 
            if book.upstream.description
              for paragraph in book.upstream.description.split('\n')
                p #{paragraph}
          else
            p.lede
              span by 
              span.author #{author}
            p.notice
              i.icon.icon-important
              strong #{__('book-noinfo')}
          if book.difficult
            p.panel #{__('book-difficult')}
        .column-one-third.sidebar
          if book.upstream && book.upstream.imageLinks && book.upstream.imageLinks.thumbnail
            img(src=book.upstream.imageLinks.thumbnail.replace('http://', '//'))
          if book.upstream && book.upstream.previewLink
            p
              a(href=book.upstream.previewLink) #{__('book-preview')}
      .grid-row
        if book.readingList
          p.panel.font-medium.reading-list
            span #{__('book-onreadinglist')}
            if typeof book.readingList === 'string'
              span  (#{book.readingList})
        h2.heading-medium #{__('book-readingstatus')}
        include reading-table.pug
        include reading-form.pug
        h2.heading-medium #{__('book-ballot-title')}
        table
          thead
            tr
              th #{__('book-ballot-voter')}
              th #{__('book-ballot-approval')}
              th #{__('book-ballot-already-read')}
              th #{__('book-ballot-owns-copy')}
          - ballots = [].concat(book.approve).concat(book.disapprove).sort().filter(n=>n)
          if ballots.indexOf(req.user) == -1
            tr
              td(colspan=4).center #{__('book-ballot-notvotedyet')}
          else
            for name in ballots
              tr
                th
                  span #{name}
                  if name == book.longlistedBy
                    abbr(title="Longlister").green  ✎
                if book.approve.indexOf(name) !== -1
                  if book.oldVotes && book.oldVotes.disapprove && book.oldVotes.disapprove.indexOf(name) !== -1
                    td
                      span.green ☑  #{__('book-ballot-approval-yes')}
                      abbr(title=__('book-ballot-changedmind-title')).delta #{__('book-ballot-changedmind', {user: req.user})}
                  else
                    td.green ☑  #{__('book-ballot-approval-yes')}
                else
                  if book.oldVotes && book.oldVotes.approve && book.oldVotes.approve.indexOf(name) !== -1
                    td
                      span.red #{__('book-ballot-approval-no')}
                      sup: abbr(title=__('book-ballot-changedmind-title')).delta #{__('book-ballot-changedmind', {user: req.user})}
                  else
                    td.red #{__('book-ballot-approval-no')}
                if book.alreadyRead && book.alreadyRead.indexOf(name) !== -1
                  td #{__('book-ballot-already-read-yes')}
                else
                  td #{__('book-ballot-already-read-no')}
                if book.haveCopy && book.haveCopy.indexOf(name) !== -1
                  td #{__('book-ballot-owns-copy-yes')}
                else
                  td #{__('book-ballot-owns-copy-no')}
    if book.upstream
      .column-one-third
        .grid-row
          table
            if book.isbn
              tr
                th
                  abbr(title=__('book-isbn')) #{__('book-isbn-abbrev')}
                td
                  a(href='https://www.bookfinder.com/search/?st=sr&ac=qr&currency=GBP&isbn='+book.isbn) #{book.isbn}
            if book.upstream.publishedDate
              tr
                th #{__('book-publishedDate')}
                td #{book.upstream.publishedDate}
            if book.upstream.publisher
              tr
                th #{__('book-publisher')}
                td #{book.upstream.publisher}
            if book.upstream.pageCount
              tr
                th #{__('book-pagecount')}
                td #{book.upstream.pageCount}
            if book.upstream.categories
              tr(rowspan=book.upstream.categories.length)
              - j = 0
              for category in book.upstream.categories
                - j++
                if j !== 0
                  th #{__('book-categories')}
                td #{category}
            if book.upstream.language
              tr
                th #{__('book-language')}
                td #{__('book-language-'+ book.upstream.language)}
            if book.upstream.maturityRating
              tr
                th #{__('book-maturity-rating')}
                td #{__('book-maturity-rating-'+book.upstream.maturityRating.replace('_', '-').toLowerCase())}
            if book.upstream.oclc
              if book.upstream.oclc.dewey
                tr
                  th #{__('book-dewey')}
                  td.callNumber #{book.upstream.oclc.dewey}
              if book.upstream.oclc.congress
                tr
                  th #{__('book-congress')}
                  td.callNumber #{book.upstream.oclc.congress}
            if book.longlistedBy
              tr
                th #{__('book-longlisted-by')}
                td #{book.longlistedBy}
        .grid-row
          p
          p.font-xxsmall(style="float:right; margin-top:0; margin-left: 0.5em; margin-bottom: 0.5em;")
            a(href='/book-club/book/' + book.isbn + '/edit')
              if book.desc
                span #{__('book-edit-note')}
              else
                span #{__('book-add-note')}
          p.font-xsmall  #{book.desc}
        .grid-row
          if book.comments
            for comment in book.comments
              p.comment
                h3.bold-xsmall(title=new Date(comment.ts).toUTCString()) #{comment.user}
                span.font-xsmall #{comment.text}
          details(open)
            summary.summary.heading-xsmall #{__('add-comment-dropdown')}
            .panel
              form(method="POST",action="/book-club/book/"+book.isbn+"/add-comment")
                textarea.form-control(style="width:100%",name="comment").font-xsmall
                input(style="margin-top:0.2em",type="submit",value=__('add-comment-button')).button