mirror of
https://github.com/zyachel/quetre.git
synced 2025-04-03 04:57:37 +03:00
94 lines
4.2 KiB
Text
94 lines
4.2 KiB
Text
//- putting spans in semantically correct tags(to the extent possible)
|
|
mixin spansChecker(spans)
|
|
each span in spans
|
|
- if(span.modifiers.math)
|
|
//- setting that var in the base.pug value to true here.
|
|
- someAnswerContainsMath = true;
|
|
span.answer__span-math= `\\(${span.text}\\)`
|
|
- else if (span.modifiers.code)
|
|
code.answer__span-code= span.text
|
|
- else if (span.modifiers.embed)
|
|
a.answer__span-link.answers__link(href=span.modifiers.embed.url)= span.modifiers.embed.title || 'link'
|
|
- else if (span.modifiers.link)
|
|
//- removing quora.com from the link in case it is a quora.com link.
|
|
a.answer__span-link.answers__link(href=span.modifiers.link.url.split('https://www.quora.com')[1] || span.modifiers.link.url)=span.text
|
|
- else if (span.modifiers.bold)
|
|
strong.answer__span-bold= span.text
|
|
- else if (span.modifiers.italic)
|
|
em.answer__span-bold= span.text
|
|
- else
|
|
span.answer__span-plain= span.text
|
|
|
|
//- mixin to format date and stuff
|
|
mixin addDate(date)
|
|
- const dateObj = new Date(date / 1000);
|
|
time.answer__metadata-data(datetime= dateObj.toISOString(), title=dateObj.toUTCString())= Intl.DateTimeFormat('en-US', {year: '2-digit', month: 'short', day: 'numeric' }).format(dateObj)
|
|
|
|
article.answer
|
|
//- stuff about author
|
|
figure.answer__author
|
|
figcaption.answer__author-name
|
|
if answerObj.author.isAnon
|
|
span Anonymous
|
|
else
|
|
a.answers__link(href=answerObj.author.profile)= answerObj.author.name
|
|
if answerObj.author.isVerified
|
|
svg.answer__icon
|
|
title verified
|
|
use(href='/misc/sprite.svg#icon-verified')
|
|
img.answer__author-image(src=answerObj.author.avatar, alt=`${answerObj.author.name}'s profile photo`)
|
|
p.answer__author-credentials(aria-label=`${answerObj.author.name}'s credentials`)= answerObj.author.credential || ''
|
|
|
|
h3.answer__question.heading.heading__tertiary
|
|
span Originally answered to
|
|
a.answer__link.answers__link(href=answerObj.OriginalQuestion.url)
|
|
+spansChecker(answerObj.OriginalQuestion.text.spans)
|
|
|
|
//- main answer goes here
|
|
.answer__text
|
|
//- putting paragraphs in semantically correct tags(to the extent possible)
|
|
each para in answerObj.text
|
|
-if(para.type==='image')
|
|
img.answer__para.answer__image(src=para.spans[0].modifiers.master_url, alt='User embedded image')
|
|
- else if (para.type==='code')
|
|
pre.answer__para.answer__code: code
|
|
+spansChecker(para.spans)
|
|
- else if(para.quoted)
|
|
blockquote.answer__para.answer__quote
|
|
+spansChecker(para.spans)
|
|
- else
|
|
p(class=`answer__para answer__${para.type}`)
|
|
+spansChecker(para.spans)
|
|
//- for quora plus answers. since quora only shows half answer, we gotta warn viewer.
|
|
unless answerObj.isViewable
|
|
p.answer__unviewable
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-danger')
|
|
| This is a Quora plus answer and hence full answer is not viewable.
|
|
|
|
//- metadata about answer(likes, shares, etc)
|
|
.answer__metadata
|
|
p.answer__metadata-item
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-clock')
|
|
+addDate(answerObj.creationTime)
|
|
span.answer__metadata-text Answered
|
|
if answerObj.updatedTime
|
|
p.answer__metadata-item
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-clock-edit')
|
|
+addDate(answerObj.updatedTime)
|
|
span.answer__metadata-text Edited
|
|
p.answer__metadata-item
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-eye')
|
|
span.answer__metadata-data= answerObj.numViews
|
|
span.answer__metadata-text Views
|
|
p.answer__metadata-item
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-arrow-up')
|
|
span.answer__metadata-data= answerObj.numUpvotes
|
|
span.answer__metadata-text Upvotes
|
|
p.answer__metadata-item
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-comments')
|
|
span.answer__metadata-data= answerObj.numComments
|
|
span.answer__metadata-text Comments
|
|
p.answer__metadata-item
|
|
svg.answer__icon: use(href='/misc/sprite.svg#icon-share')
|
|
span.answer__metadata-data= answerObj.numShares
|
|
span.answer__metadata-text Shares
|