PostComponent.vue 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877
  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="status.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 == 'moment'" class="momentui">
  277. <div class="bg-dark mt-md-n4">
  278. <div class="container" style="max-width: 700px;">
  279. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center bg-dark">
  280. <div v-if="status.pf_type === 'photo'" class="w-100">
  281. <photo-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-presenter>
  282. </div>
  283. <div v-else-if="status.pf_type === 'video'" class="w-100">
  284. <video-presenter :status="status" v-on:togglecw="status.sensitive = false"></video-presenter>
  285. </div>
  286. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  287. <photo-album-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-album-presenter>
  288. </div>
  289. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  290. <video-album-presenter :status="status" v-on:togglecw="status.sensitive = false"></video-album-presenter>
  291. </div>
  292. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  293. <mixed-album-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></mixed-album-presenter>
  294. </div>
  295. <div v-else class="w-100">
  296. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. <div class="bg-white">
  302. <div class="container">
  303. <div class="row pb-5">
  304. <div class="col-12 col-md-8 py-4">
  305. <div class="reactions d-flex align-items-center">
  306. <div class="text-center mr-5">
  307. <div v-bind:class="[reactions.liked ? 'fas fa-heart text-danger m-0 cursor-pointer' : 'far fa-heart m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus" style="font-size:1.575rem">
  308. </div>
  309. <div class="like-count font-weight-bold mt-2 rounded border" style="cursor:pointer;" v-on:click="likesModal">
  310. {{ownerOrAdmin == true ? (status.liked_by.total_count + 1) : 0}}
  311. </div>
  312. </div>
  313. <div class="text-center">
  314. <div v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'h3 far fa-share-square m-0 text-primary cursor-pointer' : 'h3 far fa-share-square m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus">
  315. </div>
  316. <div class="share-count font-weight-bold mt-2 rounded border" v-if="status.visibility == 'public'" style="cursor:pointer;" v-on:click="sharesModal">{{status.reblogs_count || 0}}</div>
  317. </div>
  318. </div>
  319. <div v-if="status.length && status.content_text.includes('#') || status.content_text.includes('https://') || status.content_text.includes('@') || status.content_text.length > 45" class="media align-items-center mt-3">
  320. <div class="media-body">
  321. <p class="lead mr-2" v-html="status.content">
  322. </p>
  323. <p class="lead mb-0">
  324. by <a :href="statusProfileUrl">{{statusUsername}}</a>
  325. <span v-if="relationship && profile && user && !relationship.following && profile.id != user.id">
  326. <span class="px-1 text-lighter">•</span>
  327. <a class="font-weight-bold small" href="#">Follow</a>
  328. </span>
  329. </p>
  330. </div>
  331. <a :href="statusProfileUrl" :title="statusUsername"><img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="72px" height="72px"></a>
  332. </div>
  333. <div v-else class="media align-items-center mt-3">
  334. <div class="media-body">
  335. <h2 class="font-weight-bold mr-2">
  336. {{status.content_text.length ? status.content_text : 'Untitled Post'}}
  337. </h2>
  338. <p class="lead mb-0">
  339. by <a :href="statusProfileUrl">{{statusUsername}}</a>
  340. <!-- <span class="px-1 text-lighter">•</span>
  341. <a class="font-weight-bold small" href="#">Follow</a> -->
  342. </p>
  343. </div>
  344. <a :href="statusProfileUrl" :title="statusUsername"><img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="72px" height="72px"></a>
  345. </div>
  346. <hr>
  347. <div>
  348. <p class="lead">
  349. <span v-if="status.place" class="text-truncate">
  350. <i class="fas fa-map-marker-alt text-lighter mr-3"></i> {{status.place.name}}, {{status.place.country}}
  351. </span>
  352. <span v-once class="float-right">
  353. <i class="far fa-clock text-lighter mr-3"></i> {{timeAgo(status.created_at)}} ago
  354. </span>
  355. </p>
  356. <!-- <div class="">
  357. <p class="lead">
  358. <span class="mr-3"><i class="fas fa-camera text-lighter"></i></span>
  359. <span>Nikon D850</span>
  360. </p>
  361. <p class="lead">
  362. <span class="mr-3"><i class="fas fa-ruler-horizontal text-lighter"></i></span>
  363. <span>200-500mm</span>
  364. </p>
  365. <p class="lead">
  366. <span class="mr-3"><i class="fas fa-stream text-lighter"></i></span>
  367. <span>500mm <span class="px-1"></span> ƒ/7.1 <span class="px-1"></span> 1/1600s <span class="px-1"></span> ISO 800</span>
  368. </p>
  369. </div> -->
  370. <div v-if="status.tags" class="pt-4">
  371. <p class="lead">
  372. <a v-for="(tag, index) in status.tags" class="btn btn-outline-dark mr-1 mb-1" :href="tag.url + '?src=mp'">{{tag.name}}</a>
  373. </p>
  374. </div>
  375. </div>
  376. </div>
  377. <div class="col-12 col-md-4 pt-4 pl-md-3">
  378. <p class="lead font-weight-bold">Comments</p>
  379. <div v-if="user != false" class="moment-comments">
  380. <div class="form-group">
  381. <textarea class="form-control" rows="3" placeholder="Add a comment ..." v-model="replyText"></textarea>
  382. <p class="d-flex justify-content-between align-items-center mt-3">
  383. <span class="small text-lighter font-weight-bold">
  384. {{replyText.length}}/{{config.uploader.max_caption_length}}
  385. </span>
  386. <span v-if="replyText.length > 2">
  387. <div class="custom-control custom-switch">
  388. <input type="checkbox" class="custom-control-input" @click="!!replySensitive" v-model="replySensitive" id="sensitiveReply">
  389. <label class="custom-control-label small font-weight-bold text-muted" style="padding-top: 3px" for="sensitiveReply">Add Content Warning</label>
  390. </div>
  391. </span>
  392. <button class="btn btn-sm font-weight-bold btn-outline-primary py-1"
  393. v-if="replyText.length > 2" @click="postReply">Post</button>
  394. </p>
  395. </div>
  396. </div>
  397. <div class="comment mt-4" style="max-height: 500px; overflow-y: auto;">
  398. <div v-for="(reply, index) in results" :key="'tl' + reply.id + '_' + index" class="media mb-3 mt-2">
  399. <a :href="reply.account.url" :title="reply.account.username"><img :src="reply.account.avatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px"></a>
  400. <div class="media-body">
  401. <div class="d-flex justify-content-between">
  402. <span>
  403. <a class="font-weight-bold text-dark" :href="reply.account.url">{{reply.account.username}}</a>
  404. </span>
  405. <span class="text-lighter">
  406. <span v-if="reply.favourited" class="cursor-pointer mr-2" @click="likeReply(reply)">
  407. <i class="fas fa-heart text-danger"></i>
  408. </span>
  409. <span v-else class="cursor-pointer mr-2" @click="likeReply(reply)">
  410. <i class="far fa-heart"></i>
  411. </span>
  412. <span class="">
  413. <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>
  414. </span>
  415. </span>
  416. </div>
  417. <div v-if="reply.sensitive == true">
  418. <span class="py-3">
  419. <span class="text-break">
  420. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  421. <span class="badge badge-primary cursor-pointer ml-2 py-1" @click="reply.sensitive = false;">Show</span>
  422. </span>
  423. </span>
  424. </div>
  425. <div v-else class="read-more" style="overflow-y: hidden;">
  426. <p v-html="reply.content" class="mb-0">loading ...</p>
  427. </div>
  428. <p>
  429. <span class="small">
  430. <a class="text-lighter text-decoration-none" :href="reply.url">{{timeAgo(reply.created_at)}}</a>
  431. </span>
  432. </p>
  433. </div>
  434. </div>
  435. </div>
  436. </div>
  437. </div>
  438. </div>
  439. </div>
  440. </div>
  441. <div v-if="layout == 'poll'" class="container px-0">
  442. <div class="row justify-content-center">
  443. <div class="col-12 col-md-6">
  444. <div v-if="loading || !user || !reactions" class="text-center">
  445. <div class="spinner-border" role="status">
  446. <span class="sr-only">Loading...</span>
  447. </div>
  448. </div>
  449. <div v-else>
  450. <poll-card
  451. :status="status"
  452. :profile="user"
  453. :showBorderTop="true"
  454. :fetch-state="true"
  455. :reactions="reactions"
  456. v-on:likeStatus="likeStatus" />
  457. <comment-feed :status="status" class="mt-3" />
  458. <!-- <div v-if="user.hasOwnProperty('id')" class="card card-body shadow-none border border-top-0 bg-light">
  459. <div class="media">
  460. <img src="/storage/avatars/default.png" class="rounded-circle mr-2" width="40" height="40">
  461. <div class="media-body">
  462. <div class="form-group mb-0" style="position:relative;">
  463. <input class="form-control rounded-pill" placeholder="Add a comment..." style="padding-right: 90px;">
  464. <div class="btn btn-primary btn-sm rounded-pill font-weight-bold px-3" style="position:absolute;top: 5px;right:6px;">Post</div>
  465. </div>
  466. </div>
  467. </div>
  468. </div>
  469. <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">
  470. <div class="media">
  471. <img :src="reply.account.avatar" class="rounded-circle border mr-3" width="32px" height="32px">
  472. <div class="media-body">
  473. <div v-if="reply.sensitive == true">
  474. <span class="py-3">
  475. <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>
  476. <span class="text-break" style="font-size: 13px;">
  477. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  478. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  479. </span>
  480. </span>
  481. </div>
  482. <div v-else>
  483. <p class="d-flex justify-content-between align-items-top read-more mb-0" style="overflow-y: hidden;">
  484. <span class="mr-3" style="font-size: 13px;">
  485. <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>
  486. <span class="text-break comment-body" style="word-break: break-all;" v-html="reply.content"></span>
  487. </span>
  488. <span class="text-right" style="min-width: 30px;">
  489. <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>
  490. <span class="pl-2 text-lighter cursor-pointer" @click="ctxMenu(reply)">
  491. <span class="fas fa-ellipsis-v text-lighter"></span>
  492. </span>
  493. </span>
  494. </p>
  495. <p class="mb-0">
  496. <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>
  497. <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>
  498. <span class="small text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index, true)">Reply</span>
  499. </p>
  500. </div>
  501. </div>
  502. </div>
  503. </div> -->
  504. </div>
  505. </div>
  506. </div>
  507. </div>
  508. <div v-if="layout == 'text'" class="container px-0">
  509. <div class="row justify-content-center">
  510. <div class="col-12 col-md-6">
  511. <status-card :status="status" :hasTopBorder="true" />
  512. <comment-feed :status="status" class="mt-3" />
  513. </div>
  514. </div>
  515. </div>
  516. </div>
  517. <div class="modal-stack">
  518. <b-modal ref="likesModal"
  519. id="l-modal"
  520. hide-footer
  521. centered
  522. title="Likes"
  523. body-class="list-group-flush py-3 px-0">
  524. <div class="list-group">
  525. <div class="list-group-item border-0 py-1" v-for="(user, index) in likes" :key="'modal_likes_'+index">
  526. <div class="media">
  527. <a :href="user.url">
  528. <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';">
  529. </a>
  530. <div class="media-body">
  531. <p class="mb-0" style="font-size: 14px">
  532. <a :href="user.url" class="font-weight-bold text-dark">
  533. {{user.username}}
  534. </a>
  535. </p>
  536. <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">
  537. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  538. </p>
  539. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  540. {{user.display_name}}
  541. </p>
  542. </div>
  543. </div>
  544. </div>
  545. <infinite-loading @infinite="infiniteLikesHandler" spinner="spiral">
  546. <div slot="no-more"></div>
  547. <div slot="no-results"></div>
  548. </infinite-loading>
  549. </div>
  550. </b-modal>
  551. <b-modal ref="sharesModal"
  552. id="s-modal"
  553. hide-footer
  554. centered
  555. title="Shares"
  556. body-class="list-group-flush py-3 px-0">
  557. <div class="list-group">
  558. <div class="list-group-item border-0 py-1" v-for="(user, index) in shares" :key="'modal_shares_'+index">
  559. <div class="media">
  560. <a :href="user.url">
  561. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  562. </a>
  563. <div class="media-body">
  564. <div class="d-inline-block">
  565. <p class="mb-0" style="font-size: 14px">
  566. <a :href="user.url" class="font-weight-bold text-dark">
  567. {{user.username}}
  568. </a>
  569. </p>
  570. <p class="text-muted mb-0" style="font-size: 14px">
  571. {{user.display_name}}
  572. </a>
  573. </p>
  574. </div>
  575. <p class="float-right"><!-- <a class="btn btn-primary font-weight-bold py-1" href="#">Follow</a> --></p>
  576. </div>
  577. </div>
  578. </div>
  579. <infinite-loading @infinite="infiniteSharesHandler" spinner="spiral">
  580. <div slot="no-more"></div>
  581. <div slot="no-results"></div>
  582. </infinite-loading>
  583. </div>
  584. </b-modal>
  585. <b-modal ref="lightboxModal"
  586. id="lightbox"
  587. :hide-header="true"
  588. :hide-footer="true"
  589. centered
  590. size="lg"
  591. body-class="p-0"
  592. >
  593. <div v-if="lightboxMedia" >
  594. <img :src="lightboxMedia.url" :class="lightboxMedia.filter_class + ' img-fluid'" style="min-height: 100%; min-width: 100%">
  595. </div>
  596. </b-modal>
  597. <b-modal ref="embedModal"
  598. id="ctx-embed-modal"
  599. hide-header
  600. hide-footer
  601. centered
  602. rounded
  603. size="md"
  604. body-class="p-2 rounded">
  605. <div>
  606. <div class="form-group">
  607. <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>
  608. </div>
  609. <div class="form-group pl-2 d-flex justify-content-center">
  610. <div class="form-check mr-3">
  611. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowCaption" :disabled="ctxEmbedCompactMode == true">
  612. <label class="form-check-label font-weight-light">
  613. Show Caption
  614. </label>
  615. </div>
  616. <div class="form-check mr-3">
  617. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowLikes" :disabled="ctxEmbedCompactMode == true">
  618. <label class="form-check-label font-weight-light">
  619. Show Likes
  620. </label>
  621. </div>
  622. <div class="form-check">
  623. <input class="form-check-input" type="checkbox" v-model="ctxEmbedCompactMode">
  624. <label class="form-check-label font-weight-light">
  625. Compact Mode
  626. </label>
  627. </div>
  628. </div>
  629. <hr>
  630. <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>
  631. <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>
  632. </div>
  633. </b-modal>
  634. <b-modal ref="taggedModal"
  635. id="tagged-modal"
  636. hide-footer
  637. centered
  638. title="Tagged People"
  639. body-class="list-group-flush py-3 px-0">
  640. <div class="list-group">
  641. <div class="list-group-item border-0 py-1" v-for="(taguser, index) in status.taggedPeople" :key="'modal_taggedpeople_'+index">
  642. <div class="media">
  643. <a :href="'/'+taguser.username">
  644. <img class="mr-3 rounded-circle box-shadow" :src="taguser.avatar" :alt="taguser.username + '’s avatar'" width="30px">
  645. </a>
  646. <div class="media-body">
  647. <p class="pt-1 d-flex justify-content-between" style="font-size: 14px">
  648. <a :href="'/'+taguser.username" class="font-weight-bold text-dark">
  649. {{taguser.username}}
  650. </a>
  651. <button v-if="taguser.id == user.id" class="btn btn-outline-primary btn-sm py-1 px-3" @click="untagMe()">Untag Me</button>
  652. </p>
  653. </div>
  654. </div>
  655. </div>
  656. </div>
  657. <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>
  658. </b-modal>
  659. <b-modal ref="ctxModal"
  660. id="ctx-modal"
  661. hide-header
  662. hide-footer
  663. centered
  664. rounded
  665. size="sm"
  666. body-class="list-group-flush p-0 rounded">
  667. <div class="list-group text-center">
  668. <!-- <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>
  669. <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> -->
  670. <div v-if="status && status.local == true" class="list-group-item rounded cursor-pointer" @click="showEmbedPostModal()">Embed</div>
  671. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
  672. <div v-if="status && user.id == status.account.id" class="list-group-item rounded cursor-pointer" @click="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</div>
  673. <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>
  674. <div v-if="user && user.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenu()">Moderation Tools</div>
  675. <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>
  676. <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>
  677. <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>
  678. <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>
  679. <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>
  680. <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>
  681. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
  682. </div>
  683. </b-modal>
  684. <b-modal ref="ctxModModal"
  685. id="ctx-mod-modal"
  686. hide-header
  687. hide-footer
  688. centered
  689. rounded
  690. size="sm"
  691. body-class="list-group-flush p-0 rounded">
  692. <div class="list-group text-center">
  693. <div class="list-group-item rounded cursor-pointer" @click="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</div>
  694. <div class="list-group-item rounded cursor-pointer" @click="moderatePost('unlist')">Unlist from Timelines</div>
  695. <div v-if="status.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost('remcw')">Remove Content Warning</div>
  696. <div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost('addcw')">Add Content Warning</div>
  697. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
  698. </div>
  699. </b-modal>
  700. <b-modal ref="replyModal"
  701. id="ctx-reply-modal"
  702. hide-footer
  703. centered
  704. rounded
  705. :title-html="replyingToUsername ? 'Reply to <span class=text-dark>' + replyingToUsername + '</span>' : ''"
  706. title-tag="p"
  707. title-class="font-weight-bold text-muted"
  708. size="md"
  709. body-class="p-2 rounded">
  710. <div>
  711. <vue-tribute :options="tributeSettings">
  712. <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">
  713. </textarea>
  714. </vue-tribute>
  715. <div class="border-top border-bottom my-2">
  716. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  717. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  718. </ul>
  719. </div>
  720. <div class="d-flex justify-content-between align-items-center">
  721. <div>
  722. <span class="pl-2 small text-muted font-weight-bold text-monospace">
  723. <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}}
  724. </span>
  725. </div>
  726. <div class="d-flex align-items-center">
  727. <div class="custom-control custom-switch mr-3">
  728. <input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replySensitive">
  729. <label :class="[replySensitive ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label>
  730. </div>
  731. <!-- <select class="custom-select custom-select-sm my-0 mr-2">
  732. <option value="public" selected="">Public</option>
  733. <option value="unlisted">Unlisted</option>
  734. <option value="followers">Followers Only</option>
  735. </select> -->
  736. <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">
  737. {{replySending == true ? 'POSTING' : 'POST'}}
  738. </button>
  739. </div>
  740. </div>
  741. </div>
  742. </b-modal>
  743. </div>
  744. </div>
  745. </template>
  746. <style type="text/css" scoped>
  747. .status-comments,
  748. .reactions {
  749. background: #fff;
  750. }
  751. .postPresenterContainer {
  752. background: #fff;
  753. }
  754. @media(min-width: 720px) {
  755. .postPresenterContainer {
  756. min-height: 600px;
  757. }
  758. }
  759. ::-webkit-scrollbar {
  760. width: 0px;
  761. background: transparent;
  762. }
  763. .reply-btn {
  764. position: absolute;
  765. bottom: 12px;
  766. right: 20px;
  767. width: 60px;
  768. text-align: center;
  769. border-radius: 0 3px 3px 0;
  770. }
  771. .text-lighter {
  772. color:#B8C2CC !important;
  773. }
  774. .text-break {
  775. overflow-wrap: break-word;
  776. }
  777. .comments p {
  778. margin-bottom: 0;
  779. }
  780. .comment-reaction {
  781. font-size: 80%;
  782. }
  783. .show-reply-bar {
  784. display: inline-block;
  785. border-bottom: 1px solid #999;
  786. height: 0;
  787. margin-right: 16px;
  788. vertical-align: middle;
  789. width: 24px;
  790. }
  791. .comment-thread {
  792. margin-top: 1rem;
  793. }
  794. .emoji-reactions .nav-item {
  795. font-size: 1.2rem;
  796. padding: 9px;
  797. cursor: pointer;
  798. }
  799. .emoji-reactions::-webkit-scrollbar {
  800. width: 0px;
  801. height: 0px;
  802. background: transparent;
  803. }
  804. @media (min-width: 1200px) {
  805. .container {
  806. max-width: 1100px;
  807. }
  808. }
  809. </style>
  810. <style type="text/css" scoped>
  811. .momentui .bg-dark {
  812. background: #000 !important;
  813. }
  814. .momentui .carousel.slide,
  815. .momentui .carousel-item {
  816. background: #000 !important;
  817. }
  818. .reply-btn[disabled] {
  819. opacity: .3;
  820. color: #3897f0;
  821. }
  822. </style>
  823. <script>
  824. import VueTribute from 'vue-tribute';
  825. import PollCard from './partials/PollCard.vue';
  826. import CommentFeed from './partials/CommentFeed.vue';
  827. import StatusCard from './partials/StatusCard.vue';
  828. pixelfed.postComponent = {};
  829. export default {
  830. props: [
  831. 'status-id',
  832. 'status-username',
  833. 'status-template',
  834. 'status-url',
  835. 'status-profile-url',
  836. 'status-avatar',
  837. 'status-profile-id',
  838. 'profile-layout',
  839. 'profile-recent'
  840. ],
  841. components: {
  842. VueTribute,
  843. PollCard,
  844. CommentFeed,
  845. StatusCard
  846. },
  847. data() {
  848. return {
  849. config: window.App.config,
  850. status: false,
  851. media: {},
  852. user: false,
  853. reactions: {
  854. liked: false,
  855. shared: false
  856. },
  857. likes: [],
  858. likesPage: 1,
  859. shares: [],
  860. sharesPage: 1,
  861. lightboxMedia: false,
  862. replyText: '',
  863. replyStatus: {},
  864. replySensitive: false,
  865. relationship: {},
  866. results: [],
  867. pagination: {},
  868. min_id: 0,
  869. max_id: 0,
  870. reply_to_profile_id: 0,
  871. thread: false,
  872. showComments: false,
  873. warning: false,
  874. loaded: false,
  875. loading: null,
  876. replyingToId: this.statusId,
  877. replyingToUsername: this.statusUsername,
  878. replyToIndex: 0,
  879. replySending: false,
  880. emoji: window.App.util.emoji,
  881. showReadMore: true,
  882. showCaption: true,
  883. ctxEmbedPayload: false,
  884. copiedEmbed: false,
  885. ctxEmbedShowCaption: true,
  886. ctxEmbedShowLikes: false,
  887. ctxEmbedCompactMode: false,
  888. layout: this.profileLayout,
  889. showProfileMorePosts: false,
  890. profileMorePosts: [],
  891. replySending: false,
  892. reactionBarLoading: true,
  893. tributeSettings: {
  894. collection: [
  895. {
  896. trigger: '@',
  897. menuShowMinLength: 2,
  898. values: (function (text, cb) {
  899. let url = '/api/compose/v0/search/mention';
  900. axios.get(url, { params: { q: text }})
  901. .then(res => {
  902. cb(res.data);
  903. })
  904. .catch(err => {
  905. console.log(err);
  906. })
  907. })
  908. },
  909. {
  910. trigger: '#',
  911. menuShowMinLength: 2,
  912. values: (function (text, cb) {
  913. let url = '/api/compose/v0/search/hashtag';
  914. axios.get(url, { params: { q: text }})
  915. .then(res => {
  916. cb(res.data);
  917. })
  918. .catch(err => {
  919. console.log(err);
  920. })
  921. })
  922. }
  923. ]
  924. }
  925. }
  926. },
  927. watch: {
  928. ctxEmbedShowCaption: function (n,o) {
  929. if(n == true) {
  930. this.ctxEmbedCompactMode = false;
  931. }
  932. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  933. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  934. },
  935. ctxEmbedShowLikes: function (n,o) {
  936. if(n == true) {
  937. this.ctxEmbedCompactMode = false;
  938. }
  939. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  940. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  941. },
  942. ctxEmbedCompactMode: function (n,o) {
  943. if(n == true) {
  944. this.ctxEmbedShowCaption = false;
  945. this.ctxEmbedShowLikes = false;
  946. }
  947. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  948. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  949. }
  950. },
  951. beforeMount() {
  952. this.layout = 'metro';
  953. },
  954. mounted() {
  955. this.fetchRelationships();
  956. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  957. this.showReadMore = false;
  958. } else {
  959. this.showReadMore = true;
  960. }
  961. },
  962. updated() {
  963. $('.carousel').carousel();
  964. $('[data-toggle="tooltip"]').tooltip();
  965. if(this.showReadMore == true) {
  966. window.pixelfed.readmore();
  967. }
  968. },
  969. methods: {
  970. reportUrl() {
  971. return '/i/report?type=post&id=' + this.status.id;
  972. },
  973. editUrl() {
  974. return this.status.url + '/edit';
  975. },
  976. timestampFormat() {
  977. let ts = new Date(this.status.created_at);
  978. return ts.toDateString() + ' · ' + ts.toLocaleTimeString();
  979. },
  980. fetchData() {
  981. let self = this;
  982. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  983. .then(response => {
  984. if(response.data.status.pf_type == 'poll') {
  985. self.layout = 'poll';
  986. }
  987. if(response.data.status.pf_type == 'text') {
  988. self.layout = 'text';
  989. }
  990. self.status = response.data.status;
  991. self.media = self.status.media_attachments;
  992. self.likesPage = 2;
  993. self.sharesPage = 2;
  994. self.showCaption = !response.data.status.sensitive;
  995. if(self.status.comments_disabled == false) {
  996. self.showComments = true;
  997. this.fetchComments();
  998. }
  999. this.loaded = true;
  1000. if(this.profileRecent !== false) {
  1001. setTimeout(function() {
  1002. self.fetchProfilePosts();
  1003. }, 3000);
  1004. }
  1005. setTimeout(function() {
  1006. self.fetchState();
  1007. document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  1008. i.href = App.util.format.rewriteLinks(i);
  1009. });
  1010. }, 500);
  1011. }).catch(error => {
  1012. swal('Oops!', 'An error occured, please try refreshing the page.', 'error');
  1013. });
  1014. },
  1015. fetchState() {
  1016. let self = this;
  1017. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId+'/state')
  1018. .then(res => {
  1019. self.user = res.data.user;
  1020. window._sharedData.curUser = self.user;
  1021. window.App.util.navatar();
  1022. self.likes = res.data.likes;
  1023. self.shares = res.data.shares;
  1024. self.reactions = res.data.reactions;
  1025. self.reactionBarLoading = false;
  1026. });
  1027. },
  1028. likesModal() {
  1029. if($('body').hasClass('loggedIn') == false) {
  1030. window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
  1031. return;
  1032. }
  1033. if(this.likes.length) {
  1034. this.$refs.likesModal.show();
  1035. return;
  1036. }
  1037. axios.get('/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId)
  1038. .then(res => {
  1039. this.likes = res.data.data;
  1040. this.$refs.likesModal.show();
  1041. });
  1042. },
  1043. sharesModal() {
  1044. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  1045. window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
  1046. return;
  1047. }
  1048. if(this.shares.length) {
  1049. this.$refs.sharesModal.show();
  1050. return;
  1051. }
  1052. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId)
  1053. .then(res => {
  1054. this.shares = res.data.data;
  1055. this.$refs.sharesModal.show();
  1056. });
  1057. },
  1058. infiniteLikesHandler($state) {
  1059. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  1060. axios.get(api, {
  1061. params: {
  1062. page: this.likesPage,
  1063. },
  1064. }).then(({ data }) => {
  1065. if (data.data.length > 0) {
  1066. this.likes.push(...data.data);
  1067. this.likesPage++;
  1068. $state.loaded();
  1069. } else {
  1070. $state.complete();
  1071. }
  1072. });
  1073. },
  1074. infiniteSharesHandler($state) {
  1075. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  1076. params: {
  1077. page: this.sharesPage,
  1078. },
  1079. }).then(({ data }) => {
  1080. if (data.data.length > 0) {
  1081. this.shares.push(...data.data);
  1082. this.sharesPage++;
  1083. $state.loaded();
  1084. } else {
  1085. $state.complete();
  1086. }
  1087. });
  1088. },
  1089. likeStatus(event) {
  1090. if($('body').hasClass('loggedIn') == false) {
  1091. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  1092. return;
  1093. }
  1094. axios.post('/i/like', {
  1095. item: this.status.id
  1096. }).then(res => {
  1097. this.status.favourites_count = res.data.count;
  1098. if(this.reactions.liked == true) {
  1099. this.reactions.liked = false;
  1100. let user = this.user.id;
  1101. this.likes = this.likes.filter(function(like) {
  1102. return like.id !== user;
  1103. });
  1104. } else {
  1105. this.reactions.liked = true;
  1106. let user = this.user;
  1107. this.likes.unshift(user);
  1108. setTimeout(function() {
  1109. event.target.classList.add('animate__animated', 'animate__bounce');
  1110. },100);
  1111. }
  1112. }).catch(err => {
  1113. console.error(err);
  1114. swal('Error', 'Something went wrong, please try again later.', 'error');
  1115. });
  1116. window.navigator.vibrate(200);
  1117. },
  1118. shareStatus() {
  1119. if($('body').hasClass('loggedIn') == false) {
  1120. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  1121. return;
  1122. }
  1123. axios.post('/i/share', {
  1124. item: this.status.id
  1125. }).then(res => {
  1126. this.status.reblogs_count = res.data.count;
  1127. if(this.reactions.shared == true) {
  1128. this.reactions.shared = false;
  1129. let user = this.user.id;
  1130. this.shares = this.shares.filter(function(reaction) {
  1131. return reaction.id !== user;
  1132. });
  1133. } else {
  1134. this.reactions.shared = true;
  1135. let user = this.user;
  1136. this.shares.push(user);
  1137. }
  1138. }).catch(err => {
  1139. console.error(err);
  1140. swal('Error', 'Something went wrong, please try again later.', 'error');
  1141. });
  1142. },
  1143. bookmarkStatus() {
  1144. if($('body').hasClass('loggedIn') == false) {
  1145. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  1146. return;
  1147. }
  1148. axios.post('/i/bookmark', {
  1149. item: this.status.id
  1150. }).then(res => {
  1151. if(this.reactions.bookmarked == true) {
  1152. this.reactions.bookmarked = false;
  1153. } else {
  1154. this.reactions.bookmarked = true;
  1155. }
  1156. }).catch(err => {
  1157. swal('Error', 'Something went wrong, please try again later.', 'error');
  1158. });
  1159. },
  1160. blockProfile() {
  1161. if($('body').hasClass('loggedIn') == false) {
  1162. return;
  1163. }
  1164. axios.post('/i/block', {
  1165. type: 'user',
  1166. item: this.status.account.id
  1167. }).then(res => {
  1168. this.$refs.ctxModal.hide();
  1169. this.relationship.blocking = true;
  1170. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  1171. }).catch(err => {
  1172. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1173. });
  1174. },
  1175. unblockProfile() {
  1176. if($('body').hasClass('loggedIn') == false) {
  1177. return;
  1178. }
  1179. axios.post('/i/unblock', {
  1180. type: 'user',
  1181. item: this.status.account.id
  1182. }).then(res => {
  1183. this.relationship.blocking = false;
  1184. this.$refs.ctxModal.hide();
  1185. swal('Success', 'You have successfully unblocked ' + this.status.account.acct, 'success');
  1186. }).catch(err => {
  1187. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1188. });
  1189. },
  1190. deletePost(status) {
  1191. if(!this.ownerOrAdmin()) {
  1192. return;
  1193. }
  1194. var result = confirm('Are you sure you want to delete this post?');
  1195. if (result) {
  1196. if($('body').hasClass('loggedIn') == false) {
  1197. return;
  1198. }
  1199. axios.post('/i/delete', {
  1200. type: 'status',
  1201. item: this.status.id
  1202. }).then(res => {
  1203. swal('Success', 'You have successfully deleted this post', 'success');
  1204. setTimeout(function() {
  1205. window.location.href = '/';
  1206. }, 3000);
  1207. }).catch(err => {
  1208. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1209. });
  1210. }
  1211. },
  1212. owner() {
  1213. return this.user.id === this.status.account.id;
  1214. },
  1215. admin() {
  1216. return this.user.is_admin == true;
  1217. },
  1218. ownerOrAdmin() {
  1219. return this.owner() || this.admin();
  1220. },
  1221. lightbox(src) {
  1222. this.lightboxMedia = src;
  1223. this.$refs.lightboxModal.show();
  1224. },
  1225. postReply() {
  1226. let self = this;
  1227. this.replySending = true;
  1228. if(this.replyText.length == 0 ||
  1229. this.replyText.trim() == '@'+this.status.account.acct) {
  1230. self.replyText = null;
  1231. $('textarea[name="comment"]').blur();
  1232. return;
  1233. }
  1234. let data = {
  1235. item: this.replyingToId,
  1236. comment: this.replyText,
  1237. sensitive: this.replySensitive
  1238. }
  1239. this.replyText = '';
  1240. axios.post('/i/comment', data)
  1241. .then(function(res) {
  1242. let entity = res.data.entity;
  1243. if(entity.in_reply_to_id == self.status.id) {
  1244. if(self.layout == 'metro') {
  1245. self.results.push(entity);
  1246. } else {
  1247. self.results.unshift(entity);
  1248. }
  1249. let elem = $('.status-comments')[0];
  1250. elem.scrollTop = elem.clientHeight * 2;
  1251. } else {
  1252. if(self.replyToIndex >= 0) {
  1253. let el = self.results[self.replyToIndex];
  1254. el.replies.push(entity);
  1255. el.reply_count = el.reply_count + 1;
  1256. }
  1257. }
  1258. self.$refs.replyModal.hide();
  1259. self.replySending = false;
  1260. });
  1261. },
  1262. deleteComment(id, i) {
  1263. axios.post('/i/delete', {
  1264. type: 'comment',
  1265. item: id
  1266. }).then(res => {
  1267. this.results.splice(i, 1);
  1268. }).catch(err => {
  1269. swal('Something went wrong!', 'Please try again later', 'error');
  1270. });
  1271. },
  1272. deleteCommentReply(id, i, pi) {
  1273. axios.post('/i/delete', {
  1274. type: 'comment',
  1275. item: id
  1276. }).then(res => {
  1277. this.results[pi].replies.splice(i, 1);
  1278. --this.results[pi].reply_count;
  1279. }).catch(err => {
  1280. swal('Something went wrong!', 'Please try again later', 'error');
  1281. });
  1282. },
  1283. l(e) {
  1284. let len = e.length;
  1285. if(len < 10) { return e; }
  1286. return e.substr(0, 10)+'...';
  1287. },
  1288. replyFocus(e, index, prependUsername = false) {
  1289. if($('body').hasClass('loggedIn') == false) {
  1290. this.redirect('/login?next=' + encodeURIComponent(window.location.pathname));
  1291. return;
  1292. }
  1293. if(this.status.comments_disabled) {
  1294. return;
  1295. }
  1296. this.replyToIndex = index;
  1297. this.replyingToId = e.id;
  1298. this.replyingToUsername = e.account.username;
  1299. this.reply_to_profile_id = e.account.id;
  1300. let username = e.account.local ? '@' + e.account.username + ' '
  1301. : '@' + e.account.acct + ' ';
  1302. if(prependUsername == true) {
  1303. this.replyText = username;
  1304. }
  1305. this.$refs.replyModal.show();
  1306. },
  1307. fetchComments() {
  1308. let url = '/api/v2/comments/'+this.statusProfileId+'/status/'+this.statusId;
  1309. axios.get(url)
  1310. .then(response => {
  1311. let self = this;
  1312. this.results = this.layout == 'metro' ?
  1313. _.reverse(response.data.data) :
  1314. response.data.data;
  1315. this.pagination = response.data.meta.pagination;
  1316. if(this.results.length > 0) {
  1317. $('.load-more-link').removeClass('d-none');
  1318. }
  1319. $('.postCommentsLoader').addClass('d-none');
  1320. $('.postCommentsContainer').removeClass('d-none');
  1321. setTimeout(function() {
  1322. document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  1323. i.href = App.util.format.rewriteLinks(i);
  1324. });
  1325. }, 500);
  1326. }).catch(error => {
  1327. if(!error.response) {
  1328. $('.postCommentsLoader .lds-ring')
  1329. .attr('style','width:100%')
  1330. .addClass('pt-4 font-weight-bold text-muted')
  1331. .text('An error occurred, cannot fetch comments. Please try again later.');
  1332. } else {
  1333. switch(error.response.status) {
  1334. case 401:
  1335. $('.postCommentsLoader .lds-ring')
  1336. .attr('style','width:100%')
  1337. .addClass('pt-4 font-weight-bold text-muted')
  1338. .text('Please login to view.');
  1339. break;
  1340. default:
  1341. $('.postCommentsLoader .lds-ring')
  1342. .attr('style','width:100%')
  1343. .addClass('pt-4 font-weight-bold text-muted')
  1344. .text('An error occurred, cannot fetch comments. Please try again later.');
  1345. break;
  1346. }
  1347. }
  1348. });
  1349. },
  1350. loadMore(e) {
  1351. e.preventDefault();
  1352. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  1353. $('.load-more-link').addClass('d-none');
  1354. return;
  1355. }
  1356. $('.load-more-link').addClass('d-none');
  1357. $('.postCommentsLoader').removeClass('d-none');
  1358. let next = this.pagination.links.next;
  1359. axios.get(next)
  1360. .then(response => {
  1361. let self = this;
  1362. let res = response.data.data;
  1363. $('.postCommentsLoader').addClass('d-none');
  1364. for(let i=0; i < res.length; i++) {
  1365. this.results.unshift(res[i]);
  1366. }
  1367. this.pagination = response.data.meta.pagination;
  1368. $('.load-more-link').removeClass('d-none');
  1369. });
  1370. },
  1371. likeReply(status, $event) {
  1372. if($('body').hasClass('loggedIn') == false) {
  1373. swal('Login', 'Please login to perform this action.', 'info');
  1374. return;
  1375. }
  1376. axios.post('/i/like', {
  1377. item: status.id
  1378. }).then(res => {
  1379. status.favourites_count = res.data.count;
  1380. if(status.favourited == true) {
  1381. status.favourited = false;
  1382. } else {
  1383. status.favourited = true;
  1384. }
  1385. }).catch(err => {
  1386. swal('Error', 'Something went wrong, please try again later.', 'error');
  1387. });
  1388. },
  1389. truncate(str,lim) {
  1390. return _.truncate(str,{
  1391. length: lim
  1392. });
  1393. },
  1394. timeAgo(ts) {
  1395. return App.util.format.timeAgo(ts);
  1396. },
  1397. emojiReaction() {
  1398. let em = event.target.innerText;
  1399. if(this.replyText.length == 0) {
  1400. this.reply_to_profile_id = this.status.account.id;
  1401. this.replyText = em + ' ';
  1402. $('textarea[name="comment"]').focus();
  1403. } else {
  1404. this.reply_to_profile_id = this.status.account.id;
  1405. this.replyText += em + ' ';
  1406. $('textarea[name="comment"]').focus();
  1407. }
  1408. },
  1409. toggleCommentVisibility() {
  1410. if(this.ownerOrAdmin() == false) {
  1411. return;
  1412. }
  1413. let state = this.status.comments_disabled;
  1414. let self = this;
  1415. if(state == true) {
  1416. // re-enable comments
  1417. axios.post('/i/visibility', {
  1418. item: self.status.id,
  1419. disableComments: false
  1420. }).then(function(res) {
  1421. self.status.comments_disabled = false;
  1422. self.$refs.ctxModal.hide();
  1423. window.location.reload();
  1424. }).catch(function(err) {
  1425. return;
  1426. });
  1427. } else {
  1428. // disable comments
  1429. axios.post('/i/visibility', {
  1430. item: self.status.id,
  1431. disableComments: true
  1432. }).then(function(res) {
  1433. self.status.comments_disabled = true;
  1434. self.showComments = false;
  1435. self.$refs.ctxModal.hide();
  1436. }).catch(function(err) {
  1437. return;
  1438. });
  1439. }
  1440. },
  1441. fetchRelationships() {
  1442. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1443. this.fetchData();
  1444. return;
  1445. } else {
  1446. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1447. params: {
  1448. 'id[]': this.statusProfileId
  1449. }
  1450. }).then(res => {
  1451. if(res.data[0] == null) {
  1452. this.fetchData();
  1453. return;
  1454. }
  1455. this.relationship = res.data[0];
  1456. if(res.data[0].blocking == true) {
  1457. this.loaded = true;
  1458. this.warning = true;
  1459. return;
  1460. } else {
  1461. this.fetchData();
  1462. return;
  1463. }
  1464. });
  1465. }
  1466. },
  1467. visibilityModal() {
  1468. switch(this.status.visibility) {
  1469. case 'public':
  1470. swal('Public Post', 'This post is visible to everyone.', 'info');
  1471. break;
  1472. case 'unlisted':
  1473. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1474. break;
  1475. case 'private':
  1476. swal('Private Post', 'This post is only visible to followers.', 'info');
  1477. break;
  1478. }
  1479. },
  1480. toggleReplies(reply) {
  1481. if(reply.thread) {
  1482. reply.thread = false;
  1483. } else {
  1484. if(reply.replies.length > 0) {
  1485. reply.thread = true;
  1486. return;
  1487. }
  1488. let url = '/api/v2/comments/'+reply.account.id+'/status/'+reply.id;
  1489. axios.get(url)
  1490. .then(response => {
  1491. reply.replies = _.reverse(response.data.data);
  1492. reply.thread = true;
  1493. });
  1494. }
  1495. },
  1496. redirect(url) {
  1497. window.location.href = url;
  1498. },
  1499. showEmbedPostModal() {
  1500. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  1501. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  1502. this.$refs.ctxModal.hide();
  1503. this.$refs.embedModal.show();
  1504. },
  1505. ctxCopyEmbed() {
  1506. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1507. this.$refs.embedModal.hide();
  1508. },
  1509. permalinkUrl(reply, showOrigin = false) {
  1510. let profile = reply.account;
  1511. if(profile.local == true) {
  1512. return reply.url;
  1513. } else {
  1514. return showOrigin ?
  1515. reply.url :
  1516. '/i/web/post/_/' + profile.id + '/' + reply.id;
  1517. }
  1518. },
  1519. fetchProfilePosts() {
  1520. if(!$('body').hasClass('loggedIn') && this.loaded) {
  1521. return;
  1522. }
  1523. let self = this;
  1524. let apiUrl = '/api/pixelfed/v1/accounts/' + this.statusProfileId + '/statuses';
  1525. axios.get(apiUrl, {
  1526. params: {
  1527. only_media: true,
  1528. min_id: 1,
  1529. limit: 9
  1530. }
  1531. })
  1532. .then(res => {
  1533. let data = res.data.filter(function(status) {
  1534. return status.media_attachments.length > 0 &&
  1535. status.id != self.statusId &&
  1536. status.sensitive == false
  1537. });
  1538. let ids = data.map(status => status.id);
  1539. if(data.length >= 3) {
  1540. self.showProfileMorePosts = true;
  1541. }
  1542. self.profileMorePosts = data.slice(0,6);
  1543. })
  1544. },
  1545. previewUrl(status) {
  1546. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  1547. },
  1548. previewBackground(status) {
  1549. let preview = this.previewUrl(status);
  1550. return 'background-image: url(' + preview + ');';
  1551. },
  1552. getStatusUrl(status) {
  1553. if(status.local == true) {
  1554. return status.url;
  1555. }
  1556. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1557. },
  1558. profileUrl(status) {
  1559. if(status.local == true) {
  1560. return status.account.url;
  1561. }
  1562. return '/i/web/profile/_/' + status.account.id;
  1563. },
  1564. showTaggedPeopleModal() {
  1565. if(!$('body').hasClass('loggedIn') && this.loaded) {
  1566. return;
  1567. }
  1568. this.$refs.taggedModal.show();
  1569. },
  1570. untagMe() {
  1571. this.$refs.taggedModal.hide();
  1572. let id = this.user.id;
  1573. axios.post('/api/local/compose/tag/untagme', {
  1574. status_id: this.statusId,
  1575. profile_id: id
  1576. }).then(res => {
  1577. this.status.taggedPeople = this.status.taggedPeople.filter(t => {
  1578. return t.id != id;
  1579. });
  1580. swal('Untagged', 'You have been untagged from this post.', 'success');
  1581. }).catch(err => {
  1582. swal('An Error Occurred', 'Please try again later.', 'error');
  1583. });
  1584. },
  1585. copyPostUrl() {
  1586. navigator.clipboard.writeText(this.statusUrl);
  1587. return;
  1588. },
  1589. moderatePost(action, $event) {
  1590. let status = this.status;
  1591. let username = status.account.username;
  1592. let msg = '';
  1593. let self = this;
  1594. switch(action) {
  1595. case 'addcw':
  1596. msg = 'Are you sure you want to add a content warning to this post?';
  1597. swal({
  1598. title: 'Confirm',
  1599. text: msg,
  1600. icon: 'warning',
  1601. buttons: true,
  1602. dangerMode: true
  1603. }).then(res => {
  1604. if(res) {
  1605. axios.post('/api/v2/moderator/action', {
  1606. action: action,
  1607. item_id: status.id,
  1608. item_type: 'status'
  1609. }).then(res => {
  1610. swal('Success', 'Successfully added content warning', 'success');
  1611. status.sensitive = true;
  1612. self.ctxModMenuClose();
  1613. }).catch(err => {
  1614. swal(
  1615. 'Error',
  1616. 'Something went wrong, please try again later.',
  1617. 'error'
  1618. );
  1619. self.ctxModMenuClose();
  1620. });
  1621. }
  1622. });
  1623. break;
  1624. case 'remcw':
  1625. msg = 'Are you sure you want to remove the content warning on this post?';
  1626. swal({
  1627. title: 'Confirm',
  1628. text: msg,
  1629. icon: 'warning',
  1630. buttons: true,
  1631. dangerMode: true
  1632. }).then(res => {
  1633. if(res) {
  1634. axios.post('/api/v2/moderator/action', {
  1635. action: action,
  1636. item_id: status.id,
  1637. item_type: 'status'
  1638. }).then(res => {
  1639. swal('Success', 'Successfully added content warning', 'success');
  1640. status.sensitive = false;
  1641. self.ctxModMenuClose();
  1642. }).catch(err => {
  1643. swal(
  1644. 'Error',
  1645. 'Something went wrong, please try again later.',
  1646. 'error'
  1647. );
  1648. self.ctxModMenuClose();
  1649. });
  1650. }
  1651. });
  1652. break;
  1653. case 'unlist':
  1654. msg = 'Are you sure you want to unlist this post?';
  1655. swal({
  1656. title: 'Confirm',
  1657. text: msg,
  1658. icon: 'warning',
  1659. buttons: true,
  1660. dangerMode: true
  1661. }).then(res => {
  1662. if(res) {
  1663. axios.post('/api/v2/moderator/action', {
  1664. action: action,
  1665. item_id: status.id,
  1666. item_type: 'status'
  1667. }).then(res => {
  1668. // this.feed = this.feed.filter(f => {
  1669. // return f.id != status.id;
  1670. // });
  1671. swal('Success', 'Successfully unlisted post', 'success');
  1672. self.ctxModMenuClose();
  1673. }).catch(err => {
  1674. self.ctxModMenuClose();
  1675. swal(
  1676. 'Error',
  1677. 'Something went wrong, please try again later.',
  1678. 'error'
  1679. );
  1680. });
  1681. }
  1682. });
  1683. break;
  1684. }
  1685. },
  1686. ctxMenu() {
  1687. this.$refs.ctxModal.show();
  1688. return;
  1689. },
  1690. closeCtxMenu(truncate) {
  1691. this.$refs.ctxModal.hide();
  1692. },
  1693. ctxModMenu() {
  1694. this.$refs.ctxModal.hide();
  1695. this.$refs.ctxModModal.show();
  1696. },
  1697. ctxModMenuClose() {
  1698. this.$refs.ctxModal.hide();
  1699. this.$refs.ctxModModal.hide();
  1700. },
  1701. ctxMenuCopyLink() {
  1702. let status = this.status;
  1703. navigator.clipboard.writeText(status.url);
  1704. this.closeCtxMenu();
  1705. return;
  1706. },
  1707. ctxMenuFollow() {
  1708. let id = this.status.account.id;
  1709. axios.post('/i/follow', {
  1710. item: id
  1711. }).then(res => {
  1712. let username = this.status.account.acct;
  1713. this.relationship.following = true;
  1714. this.$refs.ctxModal.hide();
  1715. setTimeout(function() {
  1716. swal('Follow successful!', 'You are now following ' + username, 'success');
  1717. }, 500);
  1718. });
  1719. },
  1720. ctxMenuUnfollow() {
  1721. let id = this.status.account.id;
  1722. axios.post('/i/follow', {
  1723. item: id
  1724. }).then(res => {
  1725. let username = this.status.account.acct;
  1726. this.relationship.following = false;
  1727. this.$refs.ctxModal.hide();
  1728. setTimeout(function() {
  1729. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1730. }, 500);
  1731. });
  1732. },
  1733. archivePost(status) {
  1734. if(window.confirm('Are you sure you want to archive this post?') == false) {
  1735. return;
  1736. }
  1737. axios.post('/api/pixelfed/v2/status/' + status.id + '/archive')
  1738. .then(res => {
  1739. this.$refs.ctxModal.hide();
  1740. window.location.href = '/';
  1741. });
  1742. },
  1743. unarchivePost(status) {
  1744. if(window.confirm('Are you sure you want to unarchive this post?') == false) {
  1745. return;
  1746. }
  1747. axios.post('/api/pixelfed/v2/status/' + status.id + '/unarchive')
  1748. .then(res => {
  1749. this.$refs.ctxModal.hide();
  1750. });
  1751. },
  1752. statusLike(s) {
  1753. this.reactions.liked = !!this.reactions.liked;
  1754. },
  1755. trimCaption(caption, len = 60) {
  1756. return _.truncate(caption, {
  1757. length: len
  1758. });
  1759. },
  1760. },
  1761. }
  1762. </script>