PostComponent.vue 64 KB

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