PostComponent.vue 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. <template>
  2. <div>
  3. <div v-if="!loaded" style="height: 80vh;" class="d-flex justify-content-center align-items-center">
  4. <img src="/img/pixelfed-icon-grey.svg" class="">
  5. </div>
  6. <div v-if="loaded && warning" class="bg-white mt-n4 pt-3 border-bottom">
  7. <div class="container">
  8. <p class="text-center font-weight-bold">You are blocking this account</p>
  9. <p class="text-center font-weight-bold"><a href="#" class="btn btn-primary font-weight-bold px-5" @click.prevent="warning = false; fetchData()">View Status</a></p>
  10. </div>
  11. </div>
  12. <div v-if="loaded && warning == false" class="postComponent">
  13. <div v-if="layout == 'metro'" class="container px-0">
  14. <div class="card card-md-rounded-0 status-container orientation-unknown shadow-none border">
  15. <div class="row px-0 mx-0">
  16. <div class="d-flex d-md-none align-items-center justify-content-between card-header bg-white w-100">
  17. <div class="d-flex">
  18. <div class="status-avatar mr-2" @click="redirect(statusProfileUrl)">
  19. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;" class="cursor-pointer">
  20. </div>
  21. <div class="username">
  22. <span class="username-link font-weight-bold text-dark cursor-pointer" @click="redirect(statusProfileUrl)">{{ statusUsername }}</span>
  23. <span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
  24. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  25. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  26. </span>
  27. <p class="mb-0" style="font-size: 10px;">
  28. <span v-if="loaded && status.taggedPeople.length" class="mb-0">
  29. <span class="font-weight-light cursor-pointer" style="color:#718096" title="Tagged People" data-toggle="tooltip" data-placement="bottom" @click="showTaggedPeopleModal()"><i class="fas fa-tag text-lighter"></i> <span class="font-weight-bold">{{status.taggedPeople.length}} Tagged People</span></span>
  30. </span>
  31. <span v-if="loaded && status.place != null && status.taggedPeople.length" class="px-2 font-weight-bold text-lighter">&#8226;</span>
  32. <span v-if="loaded && status.place != null" class="mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)"><i class="fas fa-map-marked-alt text-lighter"></i> <span class="font-weight-bold">{{status.place.name}}, {{status.place.country}}</span></span>
  33. </p>
  34. </div>
  35. </div>
  36. <div v-if="user != false" class="float-right">
  37. <div class="post-actions">
  38. <div>
  39. <button class="btn btn-link text-dark no-caret" title="Post options" @click="ctxMenu()">
  40. <span class="fas fa-ellipsis-v text-muted"></span>
  41. </button>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="col-12 col-md-8 px-0 mx-0">
  47. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center" style="background: #000;">
  48. <div v-if="status.pf_type === 'text'" class="w-100">
  49. <div class="w-100 card-img-top border-bottom rounded-0" style="background-image: url(/storage/textimg/bg_1.jpg);background-size: cover;width: 100%;height: 540px;">
  50. <div class="w-100 h-100 d-flex justify-content-center align-items-center">
  51. <p class="text-center text-break h3 px-5 font-weight-bold" v-html="status.content"></p>
  52. </div>
  53. </div>
  54. </div>
  55. <div v-else-if="status.pf_type === 'photo'" class="w-100">
  56. <photo-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-presenter>
  57. </div>
  58. <div v-else-if="status.pf_type === 'video'" class="w-100">
  59. <video-presenter :status="status" v-on:togglecw="status.sensitive = false"></video-presenter>
  60. </div>
  61. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  62. <photo-album-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-album-presenter>
  63. </div>
  64. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  65. <video-album-presenter :status="status" v-on:togglecw="status.sensitive = false"></video-album-presenter>
  66. </div>
  67. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  68. <mixed-album-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></mixed-album-presenter>
  69. </div>
  70. <div v-else class="w-100">
  71. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="col-12 col-md-4 px-0 d-flex flex-column border-left border-md-left-0">
  76. <div class="d-md-flex d-none align-items-center justify-content-between card-header py-3 bg-white">
  77. <div class="d-flex align-items-center status-username text-truncate">
  78. <div class="status-avatar mr-2" @click="redirect(statusProfileUrl)">
  79. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;" class="cursor-pointer">
  80. </div>
  81. <div class="username">
  82. <span class="username-link font-weight-bold text-dark cursor-pointer" @click="redirect(statusProfileUrl)">{{ statusUsername }}</span>
  83. <span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
  84. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  85. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  86. </span>
  87. <p class="mb-0" style="font-size: 10px;">
  88. <span v-if="loaded && status.taggedPeople.length" class="mb-0">
  89. <span class="font-weight-light cursor-pointer" style="color:#718096" title="Tagged People" data-toggle="tooltip" data-placement="bottom" @click="showTaggedPeopleModal()"><i class="fas fa-tag text-lighter"></i> <span class="font-weight-bold">{{status.taggedPeople.length}} Tagged People</span></span>
  90. </span>
  91. <span v-if="loaded && status.place != null && status.taggedPeople.length" class="px-2 font-weight-bold text-lighter">&#8226;</span>
  92. <span v-if="loaded && status.place != null" class="mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)"><i class="fas fa-map-marked-alt text-lighter"></i> <span class="font-weight-bold">{{status.place.name}}, {{status.place.country}}</span></span>
  93. </p>
  94. </div>
  95. </div>
  96. <div class="float-right">
  97. <div class="post-actions">
  98. <div v-if="user != false">
  99. <button class="btn btn-link text-dark no-caret" title="Post options" @click="ctxMenu()">
  100. <span class="fas fa-ellipsis-v text-muted"></span>
  101. </button>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="d-flex flex-md-column flex-column-reverse h-100" style="overflow-y: auto;">
  107. <div class="card-body status-comments pt-0">
  108. <div v-if="status.pf_type != 'text'" class="status-comment">
  109. <div v-if="status.content.length" class="pt-3">
  110. <div v-if="status.sensitive">
  111. <span class="py-3">
  112. <a class="text-dark font-weight-bold mr-1" :href="status.account.url" v-bind:title="status.account.username">{{truncate(status.account.username,15)}}</a>
  113. <span class="text-break">
  114. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  115. <span class="text-primary cursor-pointer pl-1" @click="status.sensitive = false">Show</span>
  116. </span>
  117. </span>
  118. </div>
  119. <div v-else>
  120. <p :class="[status.content.length > 620 ? 'mb-1 read-more' : 'mb-1']" style="overflow: hidden;">
  121. <a class="font-weight-bold pr-1 text-dark text-decoration-none" :href="statusProfileUrl">{{statusUsername}}</a>
  122. <span class="comment-text" :id="status.id + '-status-readmore'" v-html="content"></span>
  123. </p>
  124. </div>
  125. <hr>
  126. </div>
  127. <div v-if="showComments">
  128. <div class="postCommentsLoader text-center py-2">
  129. <div class="spinner-border" role="status">
  130. <span class="sr-only">Loading...</span>
  131. </div>
  132. </div>
  133. <div class="postCommentsContainer d-none">
  134. <p class="mb-1 text-center load-more-link d-none my-4">
  135. <a href="#" class="text-dark" v-on:click="loadMore" title="Load more comments" data-toggle="tooltip" data-placement="bottom">
  136. <svg class="bi bi-plus-circle" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="font-size:2em;"> <path fill-rule="evenodd" d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z" clip-rule="evenodd"/> <path fill-rule="evenodd" d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z" clip-rule="evenodd"/> <path fill-rule="evenodd" d="M8 15A7 7 0 108 1a7 7 0 000 14zm0 1A8 8 0 108 0a8 8 0 000 16z" clip-rule="evenodd"/></svg>
  137. </a>
  138. </p>
  139. <div class="comments mt-3">
  140. <div v-for="(reply, index) in results" class="pb-4 media" :key="'tl' + reply.id + '_' + index">
  141. <img :src="reply.account.avatar" class="rounded-circle border mr-3" width="42px" height="42px">
  142. <div class="media-body">
  143. <div v-if="reply.sensitive == true">
  144. <span class="py-3">
  145. <a class="text-dark font-weight-bold mr-1" :href="profileUrl(reply)" v-bind:title="reply.account.username">{{!reply.account.local ? '@' : '' }}{{truncate(reply.account.username,15)}}</a>
  146. <span class="text-break">
  147. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  148. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  149. </span>
  150. </span>
  151. </div>
  152. <div v-else>
  153. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  154. <span>
  155. <a class="text-dark font-weight-bold mr-1 text-break" :href="profileUrl(reply)" v-bind:title="reply.account.username">{{!reply.account.local ? '@' : '' }}{{truncate(reply.account.username,15)}}</a>
  156. <span class="text-break comment-body" style="word-break: break-all;" v-html="reply.content"></span>
  157. </span>
  158. <span style="min-width:38px;">
  159. <span v-on:click="likeReply(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  160. <post-menu :status="reply" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block px-2" v-on:deletePost="deleteComment(reply.id, index)"></post-menu>
  161. </span>
  162. </p>
  163. <p class="">
  164. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(reply.created_at)" :href="permalinkUrl(reply)"></a>
  165. <span v-if="reply.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{reply.favourites_count == 1 ? '1 like' : reply.favourites_count + ' likes'}}</span>
  166. <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index, true)">Reply</span>
  167. </p>
  168. <div v-if="reply.reply_count > 0" class="cursor-pointer" v-on:click="toggleReplies(reply)">
  169. <span class="show-reply-bar"></span>
  170. <span class="comment-reaction font-weight-bold text-muted">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
  171. </div>
  172. <div v-if="reply.thread == true" class="comment-thread">
  173. <div v-for="(s, sindex) in reply.replies" class="pb-3 media" :key="'cr' + s.id + '_' + index">
  174. <img :src="s.account.avatar" class="rounded-circle border mr-3" width="25px" height="25px">
  175. <div class="media-body">
  176. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  177. <span>
  178. <a class="text-dark font-weight-bold mr-1" :href="profileUrl(s)" :title="s.account.username">{{!s.account.local ? '@' : '' }}{{s.account.username}}</a>
  179. <span class="text-break comment-body" style="word-break: break-all;" v-html="s.content"></span>
  180. </span>
  181. <span class="pl-2" style="min-width:38px">
  182. <span v-on:click="likeReply(s, $event)"><i v-bind:class="[s.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  183. <post-menu :status="s" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block pl-2" v-on:deletePost="deleteCommentReply(s.id, sindex, index) "></post-menu>
  184. </span>
  185. </p>
  186. <p class="">
  187. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(s.created_at)" :href="s.url"></a>
  188. <span v-if="s.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{s.favourites_count == 1 ? '1 like' : s.favourites_count + ' likes'}}</span>
  189. </p>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. <div v-if="reactionBarLoading" class="card-body flex-grow-0 py-4 text-center">
  202. <div class="spinner-border" role="status">
  203. <span class="sr-only">Loading...</span>
  204. </div>
  205. </div>
  206. <div v-else class="card-body flex-grow-0 py-1">
  207. <div v-if="loaded && user.hasOwnProperty('id')" class="reactions my-2 pb-1 d-flex justify-content-between">
  208. <h3 v-bind:class="[reactions.liked ? 'fas fa-heart text-danger mr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus"></h3>
  209. <h3 v-if="!status.comments_disabled" class="far fa-comment mr-3 m-0 cursor-pointer" title="Comment" v-on:click="replyFocus(status)"></h3>
  210. <h3 @click="redirect(status.media_attachments[0].url)" class="fas fa-expand m-0 mr-3 cursor-pointer"></h3>
  211. <!-- <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 float-right cursor-pointer' : 'far fa-bookmark m-0 float-right cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3> -->
  212. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 mr-3 cursor-pointer' : 'far fa-bookmark m-0 mr-3 cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
  213. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'fas fa-retweet m-0 text-primary cursor-pointer' : 'fas fa-retweet m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
  214. </div>
  215. <div class="reaction-counts mb-0">
  216. <div v-if="status.liked_by.username && status.liked_by.username !== user.username" class="likes mb-1">
  217. <span class="like-count">Liked by
  218. <a class="font-weight-bold text-dark" :href="status.liked_by.url">{{status.liked_by.username}}</a>
  219. <span v-if="status.liked_by.others == true">
  220. and <span class="font-weight-bold text-dark cursor-pointer" @click="likesModal"><span v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> others</span>
  221. </span>
  222. </span>
  223. </div>
  224. </div>
  225. <div class="timestamp d-flex align-items-bottom justify-content-between">
  226. <a v-bind:href="statusUrl" class="small text-muted" :title="status.created_at">
  227. {{timestampFormat()}}
  228. </a>
  229. <span class="small text-muted text-capitalize cursor-pointer" v-on:click="visibilityModal">{{status.visibility}}</span>
  230. </div>
  231. </div>
  232. </div>
  233. <div v-if="showComments" class="card-footer bg-white sticky-md-bottom p-0">
  234. <div v-if="user.length == 0" class="comment-form-guest p-3">
  235. <a href="/login">Login</a> to like or comment.
  236. </div>
  237. <form v-else class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="statusId" data-truncate="false">
  238. <textarea class="form-control border-0 rounded-0" name="comment" placeholder="Add a comment…" autocomplete="off" autocorrect="off" style="height:56px;line-height: 18px;max-height:80px;resize: none; padding-right:4.2rem;" @click="replyFocus(status)"></textarea>
  239. <input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" disabled/>
  240. </form>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <div class="container" v-if="showProfileMorePosts">
  246. <p class="text-lighter px-3 mt-5" style="font-weight: 600;font-size: 15px;">More posts from <a :href="'/'+statusUsername" class="text-dark">{{this.statusUsername}}</a></p>
  247. <div class="profile-timeline mt-md-4">
  248. <div class="row">
  249. <div class="col-4 p-1 p-md-3" v-for="(s, index) in profileMorePosts" :key="'tlob:'+index">
  250. <a class="card info-overlay card-md-border-0" :href="getStatusUrl(s)" v-once>
  251. <div :class="[s.sensitive ? 'square' : 'square ' + s.media_attachments[0].filter_class]">
  252. <span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
  253. <span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
  254. <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
  255. <div class="square-content" v-bind:style="previewBackground(s)">
  256. </div>
  257. <div class="info-overlay-text">
  258. <h5 class="text-white m-auto font-weight-bold">
  259. <span>
  260. <span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
  261. <span class="d-flex-inline">{{s.favourites_count}}</span>
  262. </span>
  263. <span>
  264. <span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span>
  265. <span class="d-flex-inline">{{s.reblogs_count}}</span>
  266. </span>
  267. </h5>
  268. </div>
  269. </div>
  270. </a>
  271. </div>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. <div v-if="layout == 'poll'" class="container px-0">
  277. <div class="row justify-content-center">
  278. <div class="col-12 col-md-6">
  279. <div v-if="loading || !user || !reactions" class="text-center">
  280. <div class="spinner-border" role="status">
  281. <span class="sr-only">Loading...</span>
  282. </div>
  283. </div>
  284. <div v-else>
  285. <poll-card
  286. :status="status"
  287. :profile="user"
  288. :showBorderTop="true"
  289. :fetch-state="true"
  290. :reactions="reactions"
  291. v-on:likeStatus="likeStatus" />
  292. <comment-feed :status="status" class="mt-3" />
  293. <!-- <div v-if="user.hasOwnProperty('id')" class="card card-body shadow-none border border-top-0 bg-light">
  294. <div class="media">
  295. <img src="/storage/avatars/default.png" class="rounded-circle mr-2" width="40" height="40">
  296. <div class="media-body">
  297. <div class="form-group mb-0" style="position:relative;">
  298. <input class="form-control rounded-pill" placeholder="Add a comment..." style="padding-right: 90px;">
  299. <div class="btn btn-primary btn-sm rounded-pill font-weight-bold px-3" style="position:absolute;top: 5px;right:6px;">Post</div>
  300. </div>
  301. </div>
  302. </div>
  303. </div>
  304. <div v-if="user.hasOwnProperty('id')" v-for="(reply, index) in results" :key="'replies:'+index" class="card card-body shadow-none border border-top-0">
  305. <div class="media">
  306. <img :src="reply.account.avatar" class="rounded-circle border mr-3" width="32px" height="32px">
  307. <div class="media-body">
  308. <div v-if="reply.sensitive == true">
  309. <span class="py-3">
  310. <a class="text-dark font-weight-bold mr-3" style="font-size: 13px;" :href="profileUrl(reply)" v-bind:title="reply.account.username">{{trimCaption(reply.account.username,15)}}</a>
  311. <span class="text-break" style="font-size: 13px;">
  312. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  313. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  314. </span>
  315. </span>
  316. </div>
  317. <div v-else>
  318. <p class="d-flex justify-content-between align-items-top read-more mb-0" style="overflow-y: hidden;">
  319. <span class="mr-3" style="font-size: 13px;">
  320. <a class="text-dark font-weight-bold mr-1 text-break" :href="profileUrl(reply)" v-bind:title="reply.account.username">{{trimCaption(reply.account.username,15)}}</a>
  321. <span class="text-break comment-body" style="word-break: break-all;" v-html="reply.content"></span>
  322. </span>
  323. <span class="text-right" style="min-width: 30px;">
  324. <span v-on:click="likeReply(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  325. <span class="pl-2 text-lighter cursor-pointer" @click="ctxMenu(reply)">
  326. <span class="fas fa-ellipsis-v text-lighter"></span>
  327. </span>
  328. </span>
  329. </p>
  330. <p class="mb-0">
  331. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(reply.created_at)" :href="getStatusUrl(reply)"></a>
  332. <span v-if="reply.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3 small">{{reply.favourites_count == 1 ? '1 like' : reply.favourites_count + ' likes'}}</span>
  333. <span class="small text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index, true)">Reply</span>
  334. </p>
  335. </div>
  336. </div>
  337. </div>
  338. </div> -->
  339. </div>
  340. </div>
  341. </div>
  342. </div>
  343. <div v-if="layout == 'text'" class="container px-0">
  344. <div class="row justify-content-center">
  345. <div class="col-12 col-md-6">
  346. <status-card :status="status" :hasTopBorder="true" />
  347. <comment-feed :status="status" class="mt-3" />
  348. </div>
  349. </div>
  350. </div>
  351. </div>
  352. <div class="modal-stack">
  353. <b-modal ref="likesModal"
  354. id="l-modal"
  355. hide-footer
  356. centered
  357. title="Likes"
  358. body-class="list-group-flush py-3 px-0">
  359. <div v-if="likedLoaded" class="list-group">
  360. <div class="list-group-item border-0 py-1" v-for="(user, index) in likes" :key="'modal_likes_'+index">
  361. <div class="media">
  362. <a :href="user.url">
  363. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';">
  364. </a>
  365. <div class="media-body">
  366. <p class="mb-0" style="font-size: 14px">
  367. <a :href="user.url" class="font-weight-bold text-dark">
  368. {{user.username}}
  369. </a>
  370. </p>
  371. <p v-if="!user.local" class="text-muted mb-0 text-truncate mr-3" style="font-size: 14px" :title="user.acct" data-toggle="dropdown" data-placement="bottom">
  372. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  373. </p>
  374. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  375. {{user.display_name}}
  376. </p>
  377. </div>
  378. </div>
  379. </div>
  380. <infinite-loading v-if="likesCanLoadMore" @infinite="infiniteLikesHandler" spinner="spiral">
  381. <div slot="no-more"></div>
  382. <div slot="no-results"></div>
  383. </infinite-loading>
  384. </div>
  385. <div v-else class="d-flex justify-content-center align-items-center h-100">
  386. <b-spinner />
  387. </div>
  388. </b-modal>
  389. <b-modal ref="lightboxModal"
  390. id="lightbox"
  391. :hide-header="true"
  392. :hide-footer="true"
  393. centered
  394. size="lg"
  395. body-class="p-0"
  396. >
  397. <div v-if="lightboxMedia" >
  398. <img :src="lightboxMedia.url" :class="lightboxMedia.filter_class + ' img-fluid'" style="min-height: 100%; min-width: 100%">
  399. </div>
  400. </b-modal>
  401. <b-modal ref="embedModal"
  402. id="ctx-embed-modal"
  403. hide-header
  404. hide-footer
  405. centered
  406. rounded
  407. size="md"
  408. body-class="p-2 rounded">
  409. <div>
  410. <div class="form-group">
  411. <textarea class="form-control disabled text-monospace" rows="8" style="overflow-y:hidden;border: 1px solid #efefef; font-size: 12px; line-height: 18px; margin: 0 0 7px;resize:none;" v-model="ctxEmbedPayload" disabled=""></textarea>
  412. </div>
  413. <div class="form-group pl-2 d-flex justify-content-center">
  414. <div class="form-check mr-3">
  415. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowCaption" :disabled="ctxEmbedCompactMode == true">
  416. <label class="form-check-label font-weight-light">
  417. Show Caption
  418. </label>
  419. </div>
  420. <div class="form-check mr-3">
  421. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowLikes" :disabled="ctxEmbedCompactMode == true">
  422. <label class="form-check-label font-weight-light">
  423. Show Likes
  424. </label>
  425. </div>
  426. <div class="form-check">
  427. <input class="form-check-input" type="checkbox" v-model="ctxEmbedCompactMode">
  428. <label class="form-check-label font-weight-light">
  429. Compact Mode
  430. </label>
  431. </div>
  432. </div>
  433. <hr>
  434. <button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
  435. <p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
  436. </div>
  437. </b-modal>
  438. <b-modal ref="taggedModal"
  439. id="tagged-modal"
  440. hide-footer
  441. centered
  442. title="Tagged People"
  443. body-class="list-group-flush py-3 px-0">
  444. <div class="list-group">
  445. <div class="list-group-item border-0 py-1" v-for="(taguser, index) in status.taggedPeople" :key="'modal_taggedpeople_'+index">
  446. <div class="media">
  447. <a :href="'/'+taguser.username">
  448. <img class="mr-3 rounded-circle box-shadow" :src="taguser.avatar" :alt="taguser.username + '’s avatar'" width="30px">
  449. </a>
  450. <div class="media-body">
  451. <p class="pt-1 d-flex justify-content-between" style="font-size: 14px">
  452. <a :href="'/'+taguser.username" class="font-weight-bold text-dark">
  453. {{taguser.username}}
  454. </a>
  455. <button v-if="taguser.id == user.id" class="btn btn-outline-primary btn-sm py-1 px-3" @click="untagMe()">Untag Me</button>
  456. </p>
  457. </div>
  458. </div>
  459. </div>
  460. </div>
  461. <p class="mb-0 text-center small text-muted font-weight-bold"><a href="/site/kb/tagging-people">Learn more</a> about Tagging People.</p>
  462. </b-modal>
  463. <b-modal ref="ctxModal"
  464. id="ctx-modal"
  465. hide-header
  466. hide-footer
  467. centered
  468. rounded
  469. size="sm"
  470. body-class="list-group-flush p-0 rounded">
  471. <div class="list-group text-center">
  472. <!-- <div v-if="user && user.id != status.account.id && relationship && relationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuUnfollow()">Unfollow</div>
  473. <div v-if="user && user.id != status.account.id && relationship && !relationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-primary" @click="ctxMenuFollow()">Follow</div> -->
  474. <div v-if="status && status.local == true" class="list-group-item rounded cursor-pointer" @click="showEmbedPostModal()">Embed</div>
  475. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
  476. <div v-if="status && user.id == status.account.id" class="list-group-item rounded cursor-pointer" @click="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</div>
  477. <a v-if="status && user.id == status.account.id" class="list-group-item rounded cursor-pointer text-dark text-decoration-none" :href="editUrl()">Edit</a>
  478. <div v-if="user && user.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenu()">Moderation Tools</div>
  479. <div v-if="status && user.id != status.account.id && !relationship.blocking && !user.is_admin" class="list-group-item rounded cursor-pointer text-danger" @click="blockProfile()">Block</div>
  480. <div v-if="status && user.id != status.account.id && relationship.blocking && !user.is_admin" class="list-group-item rounded cursor-pointer text-danger" @click="unblockProfile()">Unblock</div>
  481. <a v-if="user && user.id != status.account.id && !user.is_admin" class="list-group-item rounded cursor-pointer text-danger text-decoration-none" :href="reportUrl()">Report</a>
  482. <div v-if="status && user.id == status.account.id && status.visibility != 'archived'" class="list-group-item rounded cursor-pointer text-danger" @click="archivePost(status)">Archive</div>
  483. <div v-if="status && user.id == status.account.id && status.visibility == 'archived'" class="list-group-item rounded cursor-pointer text-danger" @click="unarchivePost(status)">Unarchive</div>
  484. <div v-if="status && (user.is_admin || user.id == status.account.id)" class="list-group-item rounded cursor-pointer text-danger" @click="deletePost(ctxMenuStatus)">Delete</div>
  485. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
  486. </div>
  487. </b-modal>
  488. <b-modal ref="ctxModModal"
  489. id="ctx-mod-modal"
  490. hide-header
  491. hide-footer
  492. centered
  493. rounded
  494. size="sm"
  495. body-class="list-group-flush p-0 rounded">
  496. <div class="list-group text-center">
  497. <div class="list-group-item rounded cursor-pointer" @click="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</div>
  498. <div class="list-group-item rounded cursor-pointer" @click="moderatePost('unlist')">Unlist from Timelines</div>
  499. <div v-if="status.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost('remcw')">Remove Content Warning</div>
  500. <div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost('addcw')">Add Content Warning</div>
  501. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
  502. </div>
  503. </b-modal>
  504. <b-modal ref="replyModal"
  505. id="ctx-reply-modal"
  506. hide-footer
  507. centered
  508. rounded
  509. :title-html="replyingToUsername ? 'Reply to <span class=text-dark>' + replyingToUsername + '</span>' : ''"
  510. title-tag="p"
  511. title-class="font-weight-bold text-muted"
  512. size="md"
  513. body-class="p-2 rounded">
  514. <div>
  515. <vue-tribute :options="tributeSettings">
  516. <textarea class="form-control" rows="4" style="border: none; font-size: 18px; resize: none; white-space: pre-wrap;outline: none;" placeholder="Reply here ..." v-model="replyText">
  517. </textarea>
  518. </vue-tribute>
  519. <div class="border-top border-bottom my-2">
  520. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  521. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  522. </ul>
  523. </div>
  524. <div class="d-flex justify-content-between align-items-center">
  525. <div>
  526. <span class="pl-2 small text-muted font-weight-bold text-monospace">
  527. <span :class="[replyText.length > config.uploader.max_caption_length ? 'text-danger':'text-dark']">{{replyText.length > config.uploader.max_caption_length ? config.uploader.max_caption_length - replyText.length : replyText.length}}</span>/{{config.uploader.max_caption_length}}
  528. </span>
  529. </div>
  530. <div class="d-flex align-items-center">
  531. <div class="custom-control custom-switch mr-3">
  532. <input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replySensitive">
  533. <label :class="[replySensitive ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label>
  534. </div>
  535. <!-- <select class="custom-select custom-select-sm my-0 mr-2">
  536. <option value="public" selected="">Public</option>
  537. <option value="unlisted">Unlisted</option>
  538. <option value="followers">Followers Only</option>
  539. </select> -->
  540. <button class="btn btn-primary btn-sm py-2 px-4 lead text-uppercase font-weight-bold" v-on:click.prevent="postReply()" :disabled="replyText.length == 0">
  541. {{replySending == true ? 'POSTING' : 'POST'}}
  542. </button>
  543. </div>
  544. </div>
  545. </div>
  546. </b-modal>
  547. </div>
  548. </div>
  549. </template>
  550. <style type="text/css" scoped>
  551. .status-comments,
  552. .reactions {
  553. background: #fff;
  554. }
  555. .postPresenterContainer {
  556. background: #fff;
  557. }
  558. @media(min-width: 720px) {
  559. .postPresenterContainer {
  560. min-height: 600px;
  561. }
  562. }
  563. ::-webkit-scrollbar {
  564. width: 0px;
  565. background: transparent;
  566. }
  567. .reply-btn {
  568. position: absolute;
  569. bottom: 12px;
  570. right: 20px;
  571. width: 60px;
  572. text-align: center;
  573. border-radius: 0 3px 3px 0;
  574. }
  575. .text-lighter {
  576. color:#B8C2CC !important;
  577. }
  578. .text-break {
  579. overflow-wrap: break-word;
  580. }
  581. .comments p {
  582. margin-bottom: 0;
  583. }
  584. .comment-reaction {
  585. font-size: 80%;
  586. }
  587. .show-reply-bar {
  588. display: inline-block;
  589. border-bottom: 1px solid #999;
  590. height: 0;
  591. margin-right: 16px;
  592. vertical-align: middle;
  593. width: 24px;
  594. }
  595. .comment-thread {
  596. margin-top: 1rem;
  597. }
  598. .emoji-reactions .nav-item {
  599. font-size: 1.2rem;
  600. padding: 9px;
  601. cursor: pointer;
  602. }
  603. .emoji-reactions::-webkit-scrollbar {
  604. width: 0px;
  605. height: 0px;
  606. background: transparent;
  607. }
  608. @media (min-width: 1200px) {
  609. .container {
  610. max-width: 1100px;
  611. }
  612. }
  613. </style>
  614. <script>
  615. import VueTribute from 'vue-tribute';
  616. import PollCard from './partials/PollCard.vue';
  617. import CommentFeed from './partials/CommentFeed.vue';
  618. import StatusCard from './partials/StatusCard.vue';
  619. import { parseLinkHeader } from '@web3-storage/parse-link-header';
  620. pixelfed.postComponent = {};
  621. export default {
  622. props: [
  623. 'status-id',
  624. 'status-username',
  625. 'status-template',
  626. 'status-url',
  627. 'status-profile-url',
  628. 'status-avatar',
  629. 'status-profile-id',
  630. 'profile-layout',
  631. 'profile-recent'
  632. ],
  633. components: {
  634. VueTribute,
  635. PollCard,
  636. CommentFeed,
  637. StatusCard
  638. },
  639. data() {
  640. return {
  641. config: window.App.config,
  642. status: false,
  643. media: {},
  644. user: false,
  645. reactions: {
  646. liked: false,
  647. shared: false
  648. },
  649. likes: [],
  650. likesCursor: null,
  651. likesCanLoadMore: true,
  652. likedLoaded: false,
  653. shares: [],
  654. lightboxMedia: false,
  655. replyText: '',
  656. replyStatus: {},
  657. replySensitive: false,
  658. relationship: {},
  659. results: [],
  660. pagination: {},
  661. min_id: 0,
  662. max_id: 0,
  663. reply_to_profile_id: 0,
  664. thread: false,
  665. showComments: false,
  666. warning: false,
  667. loaded: false,
  668. loading: null,
  669. replyingToId: this.statusId,
  670. replyingToUsername: this.statusUsername,
  671. replyToIndex: 0,
  672. replySending: false,
  673. emoji: window.App.util.emoji,
  674. showReadMore: true,
  675. showCaption: true,
  676. ctxEmbedPayload: false,
  677. copiedEmbed: false,
  678. ctxEmbedShowCaption: true,
  679. ctxEmbedShowLikes: false,
  680. ctxEmbedCompactMode: false,
  681. layout: this.profileLayout,
  682. showProfileMorePosts: false,
  683. profileMorePosts: [],
  684. reactionBarLoading: true,
  685. tributeSettings: {
  686. collection: [
  687. {
  688. trigger: '@',
  689. menuShowMinLength: 2,
  690. values: (function (text, cb) {
  691. let url = '/api/compose/v0/search/mention';
  692. axios.get(url, { params: { q: text }})
  693. .then(res => {
  694. cb(res.data);
  695. })
  696. .catch(err => {
  697. console.log(err);
  698. })
  699. })
  700. },
  701. {
  702. trigger: '#',
  703. menuShowMinLength: 2,
  704. values: (function (text, cb) {
  705. let url = '/api/compose/v0/search/hashtag';
  706. axios.get(url, { params: { q: text }})
  707. .then(res => {
  708. cb(res.data);
  709. })
  710. .catch(err => {
  711. console.log(err);
  712. })
  713. })
  714. }
  715. ]
  716. },
  717. content: undefined
  718. }
  719. },
  720. watch: {
  721. ctxEmbedShowCaption: function (n,o) {
  722. if(n == true) {
  723. this.ctxEmbedCompactMode = false;
  724. }
  725. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  726. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  727. },
  728. ctxEmbedShowLikes: function (n,o) {
  729. if(n == true) {
  730. this.ctxEmbedCompactMode = false;
  731. }
  732. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  733. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  734. },
  735. ctxEmbedCompactMode: function (n,o) {
  736. if(n == true) {
  737. this.ctxEmbedShowCaption = false;
  738. this.ctxEmbedShowLikes = false;
  739. }
  740. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  741. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  742. }
  743. },
  744. beforeMount() {
  745. this.layout = 'metro';
  746. },
  747. mounted() {
  748. this.fetchRelationships();
  749. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  750. this.showReadMore = false;
  751. } else {
  752. this.showReadMore = true;
  753. }
  754. },
  755. updated() {
  756. $('.carousel').carousel();
  757. $('[data-toggle="tooltip"]').tooltip();
  758. if(this.showReadMore == true) {
  759. window.pixelfed.readmore();
  760. }
  761. },
  762. methods: {
  763. reportUrl() {
  764. return '/i/report?type=post&id=' + this.status.id;
  765. },
  766. editUrl() {
  767. return this.status.url + '/edit';
  768. },
  769. timestampFormat() {
  770. let ts = new Date(this.status.created_at);
  771. return ts.toDateString() + ' · ' + ts.toLocaleTimeString();
  772. },
  773. fetchData() {
  774. let self = this;
  775. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  776. .then(response => {
  777. if(response.data.status.pf_type == 'poll') {
  778. self.layout = 'poll';
  779. }
  780. if(response.data.status.pf_type == 'text') {
  781. self.layout = 'text';
  782. }
  783. self.status = response.data.status;
  784. self.media = self.status.media_attachments;
  785. self.content = response.data.status.content;
  786. self.status.emojis.forEach(function(emoji) {
  787. let img = `<img draggable="false" class="emojione custom-emoji" alt="${emoji.shortcode}" title="${emoji.shortcode}" src="${emoji.url}" data-original="${emoji.url}" data-static="${emoji.static_url}" width="18" height="18" onerror="this.onerror=null;this.src='/storage/emoji/missing.png';" />`;
  788. self.content = self.content.replace(`:${emoji.shortcode}:`, img);
  789. });
  790. self.showCaption = !response.data.status.sensitive;
  791. if(self.status.comments_disabled == false) {
  792. self.showComments = true;
  793. this.fetchComments();
  794. }
  795. this.loaded = true;
  796. setTimeout(function() {
  797. self.fetchState();
  798. document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  799. i.href = App.util.format.rewriteLinks(i);
  800. });
  801. }, 500);
  802. }).catch(error => {
  803. swal('Oops!', 'An error occured, please try refreshing the page.', 'error');
  804. });
  805. },
  806. fetchState() {
  807. let self = this;
  808. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId+'/state')
  809. .then(res => {
  810. self.user = res.data.user;
  811. window._sharedData.curUser = self.user;
  812. window.App.util.navatar();
  813. self.likes = res.data.likes;
  814. self.shares = res.data.shares;
  815. self.reactions = res.data.reactions;
  816. self.reactionBarLoading = false;
  817. });
  818. },
  819. likesModal() {
  820. if($('body').hasClass('loggedIn') == false) {
  821. window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
  822. return;
  823. }
  824. if(this.likes && this.likes.length) {
  825. this.$refs.likesModal.show();
  826. return;
  827. }
  828. axios.get('/api/v1/statuses/'+ this.statusId + '/favourited_by', {
  829. params: {
  830. limit: 40,
  831. '_pe': 1
  832. }
  833. })
  834. .then(res => {
  835. this.likes = res.data;
  836. if(res.headers && res.headers.link) {
  837. const links = parseLinkHeader(res.headers.link);
  838. if(links.prev) {
  839. this.likesCursor = links.prev.cursor;
  840. this.likesCanLoadMore = true;
  841. } else {
  842. this.likesCanLoadMore = false;
  843. }
  844. } else {
  845. this.likesCanLoadMore = false;
  846. }
  847. this.$refs.likesModal.show();
  848. })
  849. .then(() => {
  850. setTimeout(() => { this.likedLoaded = true }, 1000);
  851. })
  852. },
  853. infiniteLikesHandler($state) {
  854. if(!this.likesCanLoadMore) {
  855. $state.complete();
  856. return;
  857. }
  858. axios.get('/api/v1/statuses/'+ this.statusId + '/favourited_by', {
  859. params: {
  860. cursor: this.likesCursor,
  861. limit: 20,
  862. '_pe': 1
  863. },
  864. }).then(res => {
  865. if (res && res.data.length) {
  866. this.likes.push(...res.data);
  867. }
  868. if(res.headers && res.headers.link) {
  869. const links = parseLinkHeader(res.headers.link);
  870. if(links.prev) {
  871. this.likesCursor = links.prev.cursor;
  872. this.likesCanLoadMore = true;
  873. } else {
  874. this.likesCanLoadMore = false;
  875. }
  876. } else {
  877. this.likesCanLoadMore = false;
  878. }
  879. return this.likesCanLoadMore;
  880. }).then(res => {
  881. if(res) {
  882. $state.loaded();
  883. } else {
  884. $state.complete();
  885. }
  886. });
  887. },
  888. likeStatus(event) {
  889. if($('body').hasClass('loggedIn') == false) {
  890. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  891. return;
  892. }
  893. axios.post('/i/like', {
  894. item: this.status.id
  895. }).then(res => {
  896. this.status.favourites_count = res.data.count;
  897. if(this.reactions.liked == true) {
  898. this.reactions.liked = false;
  899. let user = this.user.id;
  900. this.likes = this.likes.filter(function(like) {
  901. return like.id !== user;
  902. });
  903. } else {
  904. this.reactions.liked = true;
  905. let user = this.user;
  906. this.likes.unshift(user);
  907. setTimeout(function() {
  908. event.target.classList.add('animate__animated', 'animate__bounce');
  909. },100);
  910. }
  911. }).catch(err => {
  912. console.error(err);
  913. swal('Error', 'Something went wrong, please try again later.', 'error');
  914. });
  915. window.navigator.vibrate(200);
  916. },
  917. shareStatus() {
  918. if($('body').hasClass('loggedIn') == false) {
  919. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  920. return;
  921. }
  922. axios.post('/i/share', {
  923. item: this.status.id
  924. }).then(res => {
  925. this.status.reblogs_count = res.data.count;
  926. if(this.reactions.shared == true) {
  927. this.reactions.shared = false;
  928. let user = this.user.id;
  929. this.shares = this.shares.filter(function(reaction) {
  930. return reaction.id !== user;
  931. });
  932. } else {
  933. this.reactions.shared = true;
  934. let user = this.user;
  935. this.shares.push(user);
  936. }
  937. }).catch(err => {
  938. console.error(err);
  939. swal('Error', 'Something went wrong, please try again later.', 'error');
  940. });
  941. },
  942. bookmarkStatus() {
  943. if($('body').hasClass('loggedIn') == false) {
  944. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  945. return;
  946. }
  947. axios.post('/i/bookmark', {
  948. item: this.status.id
  949. }).then(res => {
  950. if(this.reactions.bookmarked == true) {
  951. this.reactions.bookmarked = false;
  952. } else {
  953. this.reactions.bookmarked = true;
  954. }
  955. }).catch(err => {
  956. swal('Error', 'Something went wrong, please try again later.', 'error');
  957. });
  958. },
  959. blockProfile() {
  960. if($('body').hasClass('loggedIn') == false) {
  961. return;
  962. }
  963. axios.post('/i/block', {
  964. type: 'user',
  965. item: this.status.account.id
  966. }).then(res => {
  967. this.$refs.ctxModal.hide();
  968. this.relationship.blocking = true;
  969. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  970. }).catch(err => {
  971. swal('Error', 'Something went wrong. Please try again later.', 'error');
  972. });
  973. },
  974. unblockProfile() {
  975. if($('body').hasClass('loggedIn') == false) {
  976. return;
  977. }
  978. axios.post('/i/unblock', {
  979. type: 'user',
  980. item: this.status.account.id
  981. }).then(res => {
  982. this.relationship.blocking = false;
  983. this.$refs.ctxModal.hide();
  984. swal('Success', 'You have successfully unblocked ' + this.status.account.acct, 'success');
  985. }).catch(err => {
  986. swal('Error', 'Something went wrong. Please try again later.', 'error');
  987. });
  988. },
  989. deletePost(status) {
  990. if(!this.ownerOrAdmin()) {
  991. return;
  992. }
  993. var result = confirm('Are you sure you want to delete this post?');
  994. if (result) {
  995. if($('body').hasClass('loggedIn') == false) {
  996. return;
  997. }
  998. axios.post('/i/delete', {
  999. type: 'status',
  1000. item: this.status.id
  1001. }).then(res => {
  1002. swal('Success', 'You have successfully deleted this post', 'success');
  1003. setTimeout(function() {
  1004. window.location.href = '/';
  1005. }, 3000);
  1006. }).catch(err => {
  1007. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1008. });
  1009. }
  1010. },
  1011. owner() {
  1012. return this.user.id === this.status.account.id;
  1013. },
  1014. admin() {
  1015. return this.user.is_admin == true;
  1016. },
  1017. ownerOrAdmin() {
  1018. return this.owner() || this.admin();
  1019. },
  1020. lightbox(src) {
  1021. this.lightboxMedia = src;
  1022. this.$refs.lightboxModal.show();
  1023. },
  1024. postReply() {
  1025. let self = this;
  1026. this.replySending = true;
  1027. if(this.replyText.length == 0 ||
  1028. this.replyText.trim() == '@'+this.status.account.acct) {
  1029. self.replyText = null;
  1030. $('textarea[name="comment"]').blur();
  1031. return;
  1032. }
  1033. let data = {
  1034. item: this.replyingToId,
  1035. comment: this.replyText,
  1036. sensitive: this.replySensitive
  1037. }
  1038. this.replyText = '';
  1039. axios.post('/i/comment', data)
  1040. .then(function(res) {
  1041. let entity = res.data.entity;
  1042. if(entity.in_reply_to_id == self.status.id) {
  1043. if(self.layout == 'metro') {
  1044. self.results.push(entity);
  1045. } else {
  1046. self.results.unshift(entity);
  1047. }
  1048. let elem = $('.status-comments')[0];
  1049. elem.scrollTop = elem.clientHeight * 2;
  1050. } else {
  1051. if(self.replyToIndex >= 0) {
  1052. let el = self.results[self.replyToIndex];
  1053. el.replies.push(entity);
  1054. el.reply_count = el.reply_count + 1;
  1055. }
  1056. }
  1057. self.$refs.replyModal.hide();
  1058. self.replySending = false;
  1059. });
  1060. },
  1061. deleteComment(id, i) {
  1062. axios.post('/i/delete', {
  1063. type: 'comment',
  1064. item: id
  1065. }).then(res => {
  1066. this.results.splice(i, 1);
  1067. }).catch(err => {
  1068. swal('Something went wrong!', 'Please try again later', 'error');
  1069. });
  1070. },
  1071. deleteCommentReply(id, i, pi) {
  1072. axios.post('/i/delete', {
  1073. type: 'comment',
  1074. item: id
  1075. }).then(res => {
  1076. this.results[pi].replies.splice(i, 1);
  1077. --this.results[pi].reply_count;
  1078. }).catch(err => {
  1079. swal('Something went wrong!', 'Please try again later', 'error');
  1080. });
  1081. },
  1082. l(e) {
  1083. let len = e.length;
  1084. if(len < 10) { return e; }
  1085. return e.substr(0, 10)+'...';
  1086. },
  1087. replyFocus(e, index, prependUsername = false) {
  1088. if($('body').hasClass('loggedIn') == false) {
  1089. this.redirect('/login?next=' + encodeURIComponent(window.location.pathname));
  1090. return;
  1091. }
  1092. if(this.status.comments_disabled) {
  1093. return;
  1094. }
  1095. this.replyToIndex = index;
  1096. this.replyingToId = e.id;
  1097. this.replyingToUsername = e.account.username;
  1098. this.reply_to_profile_id = e.account.id;
  1099. let username = e.account.local ? '@' + e.account.username + ' '
  1100. : '@' + e.account.acct + ' ';
  1101. if(prependUsername == true) {
  1102. this.replyText = username;
  1103. }
  1104. this.$refs.replyModal.show();
  1105. },
  1106. fetchComments() {
  1107. let url = '/api/v2/comments/'+this.statusProfileId+'/status/'+this.statusId;
  1108. axios.get(url)
  1109. .then(response => {
  1110. let self = this;
  1111. this.results = response.data.data.filter(p => {
  1112. return p.pf_type == 'text';
  1113. });
  1114. this.pagination = response.data.meta.pagination;
  1115. if(this.results.length > 0) {
  1116. $('.load-more-link').removeClass('d-none');
  1117. }
  1118. $('.postCommentsLoader').addClass('d-none');
  1119. $('.postCommentsContainer').removeClass('d-none');
  1120. setTimeout(function() {
  1121. document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  1122. i.href = App.util.format.rewriteLinks(i);
  1123. });
  1124. }, 500);
  1125. }).catch(error => {
  1126. if(!error.response) {
  1127. $('.postCommentsLoader .lds-ring')
  1128. .attr('style','width:100%')
  1129. .addClass('pt-4 font-weight-bold text-muted')
  1130. .text('An error occurred, cannot fetch comments. Please try again later.');
  1131. } else {
  1132. switch(error.response.status) {
  1133. case 401:
  1134. $('.postCommentsLoader .lds-ring')
  1135. .attr('style','width:100%')
  1136. .addClass('pt-4 font-weight-bold text-muted')
  1137. .text('Please login to view.');
  1138. break;
  1139. default:
  1140. $('.postCommentsLoader .lds-ring')
  1141. .attr('style','width:100%')
  1142. .addClass('pt-4 font-weight-bold text-muted')
  1143. .text('An error occurred, cannot fetch comments. Please try again later.');
  1144. break;
  1145. }
  1146. }
  1147. });
  1148. },
  1149. loadMore(e) {
  1150. e.preventDefault();
  1151. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  1152. $('.load-more-link').addClass('d-none');
  1153. return;
  1154. }
  1155. $('.load-more-link').addClass('d-none');
  1156. $('.postCommentsLoader').removeClass('d-none');
  1157. let next = this.pagination.links.next;
  1158. axios.get(next)
  1159. .then(response => {
  1160. let self = this;
  1161. let res = response.data.data;
  1162. $('.postCommentsLoader').addClass('d-none');
  1163. for(let i=0; i < res.length; i++) {
  1164. this.results.unshift(res[i]);
  1165. }
  1166. this.pagination = response.data.meta.pagination;
  1167. $('.load-more-link').removeClass('d-none');
  1168. });
  1169. },
  1170. likeReply(status, $event) {
  1171. if($('body').hasClass('loggedIn') == false) {
  1172. swal('Login', 'Please login to perform this action.', 'info');
  1173. return;
  1174. }
  1175. axios.post('/i/like', {
  1176. item: status.id
  1177. }).then(res => {
  1178. status.favourites_count = res.data.count;
  1179. if(status.favourited == true) {
  1180. status.favourited = false;
  1181. } else {
  1182. status.favourited = true;
  1183. }
  1184. }).catch(err => {
  1185. swal('Error', 'Something went wrong, please try again later.', 'error');
  1186. });
  1187. },
  1188. truncate(str,lim) {
  1189. return _.truncate(str,{
  1190. length: lim
  1191. });
  1192. },
  1193. timeAgo(ts) {
  1194. return App.util.format.timeAgo(ts);
  1195. },
  1196. emojiReaction() {
  1197. let em = event.target.innerText;
  1198. if(this.replyText.length == 0) {
  1199. this.reply_to_profile_id = this.status.account.id;
  1200. this.replyText = em + ' ';
  1201. $('textarea[name="comment"]').focus();
  1202. } else {
  1203. this.reply_to_profile_id = this.status.account.id;
  1204. this.replyText += em + ' ';
  1205. $('textarea[name="comment"]').focus();
  1206. }
  1207. },
  1208. toggleCommentVisibility() {
  1209. if(this.ownerOrAdmin() == false) {
  1210. return;
  1211. }
  1212. let state = this.status.comments_disabled;
  1213. let self = this;
  1214. if(state == true) {
  1215. // re-enable comments
  1216. axios.post('/i/visibility', {
  1217. item: self.status.id,
  1218. disableComments: false
  1219. }).then(function(res) {
  1220. self.status.comments_disabled = false;
  1221. self.$refs.ctxModal.hide();
  1222. window.location.reload();
  1223. }).catch(function(err) {
  1224. return;
  1225. });
  1226. } else {
  1227. // disable comments
  1228. axios.post('/i/visibility', {
  1229. item: self.status.id,
  1230. disableComments: true
  1231. }).then(function(res) {
  1232. self.status.comments_disabled = true;
  1233. self.showComments = false;
  1234. self.$refs.ctxModal.hide();
  1235. }).catch(function(err) {
  1236. return;
  1237. });
  1238. }
  1239. },
  1240. fetchRelationships() {
  1241. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1242. this.fetchData();
  1243. return;
  1244. } else {
  1245. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1246. params: {
  1247. 'id[]': this.statusProfileId
  1248. }
  1249. }).then(res => {
  1250. if(res.data[0] == null) {
  1251. this.fetchData();
  1252. return;
  1253. }
  1254. this.relationship = res.data[0];
  1255. if(res.data[0].blocking == true) {
  1256. this.loaded = true;
  1257. this.warning = true;
  1258. return;
  1259. } else {
  1260. this.fetchData();
  1261. return;
  1262. }
  1263. });
  1264. }
  1265. },
  1266. visibilityModal() {
  1267. switch(this.status.visibility) {
  1268. case 'public':
  1269. swal('Public Post', 'This post is visible to everyone.', 'info');
  1270. break;
  1271. case 'unlisted':
  1272. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1273. break;
  1274. case 'private':
  1275. swal('Private Post', 'This post is only visible to followers.', 'info');
  1276. break;
  1277. }
  1278. },
  1279. toggleReplies(reply) {
  1280. if(reply.thread) {
  1281. reply.thread = false;
  1282. } else {
  1283. if(reply.replies.length > 0) {
  1284. reply.thread = true;
  1285. return;
  1286. }
  1287. let url = '/api/v2/comments/'+reply.account.id+'/status/'+reply.id;
  1288. axios.get(url)
  1289. .then(response => {
  1290. reply.replies = _.reverse(response.data.data);
  1291. reply.thread = true;
  1292. });
  1293. }
  1294. },
  1295. redirect(url) {
  1296. window.location.href = url;
  1297. },
  1298. showEmbedPostModal() {
  1299. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  1300. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  1301. this.$refs.ctxModal.hide();
  1302. this.$refs.embedModal.show();
  1303. },
  1304. ctxCopyEmbed() {
  1305. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1306. this.$refs.embedModal.hide();
  1307. },
  1308. permalinkUrl(reply, showOrigin = false) {
  1309. let profile = reply.account;
  1310. if(profile.local == true) {
  1311. return reply.url;
  1312. } else {
  1313. return showOrigin ?
  1314. reply.url :
  1315. '/i/web/post/_/' + profile.id + '/' + reply.id;
  1316. }
  1317. },
  1318. fetchProfilePosts() {
  1319. if(!$('body').hasClass('loggedIn') && this.loaded) {
  1320. return;
  1321. }
  1322. let self = this;
  1323. let apiUrl = '/api/pixelfed/v1/accounts/' + this.statusProfileId + '/statuses';
  1324. axios.get(apiUrl, {
  1325. params: {
  1326. only_media: true,
  1327. min_id: 1,
  1328. limit: 9
  1329. }
  1330. })
  1331. .then(res => {
  1332. let data = res.data.filter(function(status) {
  1333. return status.media_attachments.length > 0 &&
  1334. status.id != self.statusId &&
  1335. status.sensitive == false
  1336. });
  1337. let ids = data.map(status => status.id);
  1338. if(data.length >= 3) {
  1339. self.showProfileMorePosts = true;
  1340. }
  1341. self.profileMorePosts = data.slice(0,6);
  1342. })
  1343. },
  1344. previewUrl(status) {
  1345. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  1346. },
  1347. previewBackground(status) {
  1348. let preview = this.previewUrl(status);
  1349. return 'background-image: url(' + preview + ');';
  1350. },
  1351. getStatusUrl(status) {
  1352. if(status.local == true) {
  1353. return status.url;
  1354. }
  1355. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1356. },
  1357. profileUrl(status) {
  1358. if(status.local == true) {
  1359. return status.account.url;
  1360. }
  1361. return '/i/web/profile/_/' + status.account.id;
  1362. },
  1363. showTaggedPeopleModal() {
  1364. if(!$('body').hasClass('loggedIn') && this.loaded) {
  1365. return;
  1366. }
  1367. this.$refs.taggedModal.show();
  1368. },
  1369. untagMe() {
  1370. this.$refs.taggedModal.hide();
  1371. let id = this.user.id;
  1372. axios.post('/api/local/compose/tag/untagme', {
  1373. status_id: this.statusId,
  1374. profile_id: id
  1375. }).then(res => {
  1376. this.status.taggedPeople = this.status.taggedPeople.filter(t => {
  1377. return t.id != id;
  1378. });
  1379. swal('Untagged', 'You have been untagged from this post.', 'success');
  1380. }).catch(err => {
  1381. swal('An Error Occurred', 'Please try again later.', 'error');
  1382. });
  1383. },
  1384. copyPostUrl() {
  1385. navigator.clipboard.writeText(this.statusUrl);
  1386. return;
  1387. },
  1388. moderatePost(action, $event) {
  1389. let status = this.status;
  1390. let username = status.account.username;
  1391. let msg = '';
  1392. let self = this;
  1393. switch(action) {
  1394. case 'addcw':
  1395. msg = 'Are you sure you want to add a content warning to this post?';
  1396. swal({
  1397. title: 'Confirm',
  1398. text: msg,
  1399. icon: 'warning',
  1400. buttons: true,
  1401. dangerMode: true
  1402. }).then(res => {
  1403. if(res) {
  1404. axios.post('/api/v2/moderator/action', {
  1405. action: action,
  1406. item_id: status.id,
  1407. item_type: 'status'
  1408. }).then(res => {
  1409. swal('Success', 'Successfully added content warning', 'success');
  1410. status.sensitive = true;
  1411. self.ctxModMenuClose();
  1412. }).catch(err => {
  1413. swal(
  1414. 'Error',
  1415. 'Something went wrong, please try again later.',
  1416. 'error'
  1417. );
  1418. self.ctxModMenuClose();
  1419. });
  1420. }
  1421. });
  1422. break;
  1423. case 'remcw':
  1424. msg = 'Are you sure you want to remove the content warning on this post?';
  1425. swal({
  1426. title: 'Confirm',
  1427. text: msg,
  1428. icon: 'warning',
  1429. buttons: true,
  1430. dangerMode: true
  1431. }).then(res => {
  1432. if(res) {
  1433. axios.post('/api/v2/moderator/action', {
  1434. action: action,
  1435. item_id: status.id,
  1436. item_type: 'status'
  1437. }).then(res => {
  1438. swal('Success', 'Successfully added content warning', 'success');
  1439. status.sensitive = false;
  1440. self.ctxModMenuClose();
  1441. }).catch(err => {
  1442. swal(
  1443. 'Error',
  1444. 'Something went wrong, please try again later.',
  1445. 'error'
  1446. );
  1447. self.ctxModMenuClose();
  1448. });
  1449. }
  1450. });
  1451. break;
  1452. case 'unlist':
  1453. msg = 'Are you sure you want to unlist this post?';
  1454. swal({
  1455. title: 'Confirm',
  1456. text: msg,
  1457. icon: 'warning',
  1458. buttons: true,
  1459. dangerMode: true
  1460. }).then(res => {
  1461. if(res) {
  1462. axios.post('/api/v2/moderator/action', {
  1463. action: action,
  1464. item_id: status.id,
  1465. item_type: 'status'
  1466. }).then(res => {
  1467. // this.feed = this.feed.filter(f => {
  1468. // return f.id != status.id;
  1469. // });
  1470. swal('Success', 'Successfully unlisted post', 'success');
  1471. self.ctxModMenuClose();
  1472. }).catch(err => {
  1473. self.ctxModMenuClose();
  1474. swal(
  1475. 'Error',
  1476. 'Something went wrong, please try again later.',
  1477. 'error'
  1478. );
  1479. });
  1480. }
  1481. });
  1482. break;
  1483. }
  1484. },
  1485. ctxMenu() {
  1486. this.$refs.ctxModal.show();
  1487. return;
  1488. },
  1489. closeCtxMenu(truncate) {
  1490. this.$refs.ctxModal.hide();
  1491. },
  1492. ctxModMenu() {
  1493. this.$refs.ctxModal.hide();
  1494. this.$refs.ctxModModal.show();
  1495. },
  1496. ctxModMenuClose() {
  1497. this.$refs.ctxModal.hide();
  1498. this.$refs.ctxModModal.hide();
  1499. },
  1500. ctxMenuCopyLink() {
  1501. let status = this.status;
  1502. navigator.clipboard.writeText(status.url);
  1503. this.closeCtxMenu();
  1504. return;
  1505. },
  1506. ctxMenuFollow() {
  1507. let id = this.status.account.id;
  1508. axios.post('/i/follow', {
  1509. item: id
  1510. }).then(res => {
  1511. let username = this.status.account.acct;
  1512. this.relationship.following = true;
  1513. this.$refs.ctxModal.hide();
  1514. setTimeout(function() {
  1515. swal('Follow successful!', 'You are now following ' + username, 'success');
  1516. }, 500);
  1517. });
  1518. },
  1519. ctxMenuUnfollow() {
  1520. let id = this.status.account.id;
  1521. axios.post('/i/follow', {
  1522. item: id
  1523. }).then(res => {
  1524. let username = this.status.account.acct;
  1525. this.relationship.following = false;
  1526. this.$refs.ctxModal.hide();
  1527. setTimeout(function() {
  1528. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1529. }, 500);
  1530. });
  1531. },
  1532. archivePost(status) {
  1533. if(window.confirm('Are you sure you want to archive this post?') == false) {
  1534. return;
  1535. }
  1536. axios.post('/api/pixelfed/v2/status/' + status.id + '/archive')
  1537. .then(res => {
  1538. this.$refs.ctxModal.hide();
  1539. window.location.href = '/';
  1540. });
  1541. },
  1542. unarchivePost(status) {
  1543. if(window.confirm('Are you sure you want to unarchive this post?') == false) {
  1544. return;
  1545. }
  1546. axios.post('/api/pixelfed/v2/status/' + status.id + '/unarchive')
  1547. .then(res => {
  1548. this.$refs.ctxModal.hide();
  1549. });
  1550. },
  1551. statusLike(s) {
  1552. this.reactions.liked = !!this.reactions.liked;
  1553. },
  1554. trimCaption(caption, len = 60) {
  1555. return _.truncate(caption, {
  1556. length: len
  1557. });
  1558. },
  1559. },
  1560. }
  1561. </script>