Timeline.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. <template>
  2. <div class="container" style="">
  3. <div class="row">
  4. <div :class="[modes.distractionFree ? 'col-md-8 col-lg-8 offset-md-2 pt-sm-2 px-0 my-sm-3 timeline order-2 order-md-1':'col-md-8 col-lg-8 pt-sm-2 px-0 my-sm-3 timeline order-2 order-md-1']">
  5. <div style="padding-top:10px;">
  6. <div v-if="loading" class="text-center">
  7. <div class="spinner-border" role="status">
  8. <span class="sr-only">Loading...</span>
  9. </div>
  10. </div>
  11. <div :data-status-id="status.id" v-for="(status, index) in feed" :key="`${index}-${status.id}`">
  12. <div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0">
  13. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  14. <h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
  15. <span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
  16. </div>
  17. <div class="card-body row mx-0">
  18. <div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
  19. <div class="card">
  20. <div class="card-body text-center pt-3">
  21. <p class="mb-0">
  22. <a :href="'/'+rec.username">
  23. <img :src="rec.avatar" class="img-fluid rounded-circle cursor-pointer" width="45px" height="45px">
  24. </a>
  25. </p>
  26. <div class="py-3">
  27. <p class="font-weight-bold text-dark cursor-pointer mb-0">
  28. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  29. {{rec.username}}
  30. </a>
  31. </p>
  32. <p class="small text-muted mb-0">{{rec.message}}</p>
  33. </div>
  34. <p class="mb-0">
  35. <a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  36. </p>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="card mb-sm-4 status-card card-md-rounded-0">
  43. <div v-if="!modes.distractionFree" class="card-header d-inline-flex align-items-center bg-white">
  44. <img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
  45. <a class="username font-weight-bold pl-2 text-dark" v-bind:href="status.account.url">
  46. {{status.account.username}}
  47. </a>
  48. <div class="text-right" style="flex-grow:1;">
  49. <button class="btn btn-link text-dark no-caret dropdown-toggle py-0" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  50. <span class="fas fa-ellipsis-v fa-lg text-muted"></span>
  51. </button>
  52. <div class="dropdown-menu dropdown-menu-right">
  53. <a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
  54. <!-- <a class="dropdown-item font-weight-bold" href="#">Share</a>
  55. <a class="dropdown-item font-weight-bold" href="#">Embed</a> -->
  56. <span v-if="statusOwner(status) == false">
  57. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  58. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
  59. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
  60. </span>
  61. <span v-if="statusOwner(status) == true">
  62. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  63. </span>
  64. <span v-if="profile.is_admin == true && modes.mod == true">
  65. <div class="dropdown-divider"></div>
  66. <a v-if="!statusOwner(status)" class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  67. <div class="dropdown-divider"></div>
  68. <h6 class="dropdown-header">Mod Tools</h6>
  69. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')">
  70. <p class="mb-0" data-toggle="tooltip" data-placement="bottom" title="Adds a CW to every post made by this account.">Enforce CW</p>
  71. </a>
  72. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')">
  73. <p class="mb-0" title="Do not transform mentions, hashtags or urls into HTML.">No Autolinking</p>
  74. </a>
  75. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')">
  76. <p class="mb-0" title="Removes account from public/network timelines.">Unlisted Posts</p>
  77. </a>
  78. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'disable')">
  79. <p class="mb-0" title="Temporarily disable account until next time user log in.">Disable Account</p>
  80. </a>
  81. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')">
  82. <p class="mb-0" title="This prevents any new interactions, without deleting existing data.">Suspend Account</p>
  83. </a>
  84. </span>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="postPresenterContainer" v-on:dblclick="likeStatus(status)">
  89. <div v-if="status.pf_type === 'photo'" class="w-100">
  90. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  91. </div>
  92. <div v-else-if="status.pf_type === 'video'" class="w-100">
  93. <video-presenter :status="status"></video-presenter>
  94. </div>
  95. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  96. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  97. </div>
  98. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  99. <video-album-presenter :status="status"></video-album-presenter>
  100. </div>
  101. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  102. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  103. </div>
  104. <div v-else class="w-100">
  105. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  106. </div>
  107. </div>
  108. <div class="card-body">
  109. <div v-if="!modes.distractionFree" class="reactions my-1">
  110. <h3 v-bind:class="[status.favourited ? 'fas fa-heart text-danger pr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus(status, $event)"></h3>
  111. <h3 v-if="!status.comments_disabled" class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
  112. <h3 v-if="status.visibility == 'public'" v-bind:class="[status.reblogged ? 'far fa-share-square pr-3 m-0 text-primary cursor-pointer' : 'far fa-share-square pr-3 m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus(status, $event)"></h3>
  113. </div>
  114. <div class="likes font-weight-bold" v-if="expLc(status) == true && !modes.distractionFree">
  115. <span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
  116. </div>
  117. <div class="caption">
  118. <p class="mb-2 read-more" style="overflow: hidden;">
  119. <span class="username font-weight-bold">
  120. <bdi><a class="text-dark" :href="status.account.url">{{status.account.username}}</a></bdi>
  121. </span>
  122. <span v-html="status.content"></span>
  123. </p>
  124. </div>
  125. <div class="comments" v-if="status.id == replyId && !status.comments_disabled">
  126. <p class="mb-0 d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;" v-for="(reply, index) in replies">
  127. <span>
  128. <a class="text-dark font-weight-bold mr-1" :href="reply.account.url">{{reply.account.username}}</a>
  129. <span v-html="reply.content"></span>
  130. </span>
  131. <span class="mb-0" style="min-width:38px">
  132. <span v-on:click="likeStatus(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  133. <post-menu :status="reply" :profile="profile" size="sm" :modal="'true'" :feed="feed" class="d-inline-flex pl-2"></post-menu>
  134. </span>
  135. </p>
  136. </div>
  137. <div class="timestamp mt-2">
  138. <p class="small text-uppercase mb-0">
  139. <a :href="status.url" class="text-muted">
  140. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  141. </a>
  142. <a v-if="modes.distractionFree" class="float-right" :href="status.url">
  143. <i class="fas fa-ellipsis-h fa-lg text-muted"></i>
  144. </a>
  145. </p>
  146. </div>
  147. </div>
  148. <div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white px-2 py-0">
  149. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  150. <li class="nav-item" v-on:click="emojiReaction(status)">😂</li>
  151. <li class="nav-item" v-on:click="emojiReaction(status)">💯</li>
  152. <li class="nav-item" v-on:click="emojiReaction(status)">❤️</li>
  153. <li class="nav-item" v-on:click="emojiReaction(status)">🙌</li>
  154. <li class="nav-item" v-on:click="emojiReaction(status)">👏</li>
  155. <li class="nav-item" v-on:click="emojiReaction(status)">👌</li>
  156. <li class="nav-item" v-on:click="emojiReaction(status)">😍</li>
  157. <li class="nav-item" v-on:click="emojiReaction(status)">😯</li>
  158. <li class="nav-item" v-on:click="emojiReaction(status)">😢</li>
  159. <li class="nav-item" v-on:click="emojiReaction(status)">😅</li>
  160. <li class="nav-item" v-on:click="emojiReaction(status)">😁</li>
  161. <li class="nav-item" v-on:click="emojiReaction(status)">🙂</li>
  162. <li class="nav-item" v-on:click="emojiReaction(status)">😎</li>
  163. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  164. </ul>
  165. </div>
  166. <div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white sticky-md-bottom p-0">
  167. <form class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="status.id" data-truncate="false">
  168. <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>
  169. <input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" v-on:click.prevent="commentSubmit(status, $event)"/>
  170. </form>
  171. </div>
  172. </div>
  173. </div>
  174. <div v-if="!loading && feed.length > 0">
  175. <div class="card">
  176. <div class="card-body">
  177. <infinite-loading @infinite="infiniteTimeline" :distance="800">
  178. <div slot="no-more" class="font-weight-bold">No more posts to load</div>
  179. <div slot="no-results" class="font-weight-bold">No posts found</div>
  180. </infinite-loading>
  181. </div>
  182. </div>
  183. </div>
  184. <div v-if="!loading && scope == 'home' && feed.length == 0">
  185. <div class="card">
  186. <div class="card-body text-center">
  187. <p class="h2 font-weight-lighter p-5">Hello, {{profile.acct}}</p>
  188. <p class="text-lighter"><i class="fas fa-camera-retro fa-5x"></i></p>
  189. <p class="h3 font-weight-lighter p-5">Start following people to build your timeline.</p>
  190. <p><a href="/discover" class="btn btn-primary font-weight-bold py-0">Discover new people and posts</a></p>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. <div v-if="!modes.distractionFree" class="col-md-4 col-lg-4 pt-2 my-3 order-1 order-md-2 d-none d-md-block">
  197. <div class="position-sticky" style="top:68px;">
  198. <div class="mb-4">
  199. <div class="">
  200. <div class="">
  201. <div class="media d-flex align-items-center">
  202. <a :href="profile.url">
  203. <img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
  204. </a>
  205. <div class="media-body d-flex justify-content-between word-break" >
  206. <div>
  207. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
  208. <p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
  209. </div>
  210. <div class="ml-2">
  211. <a class="text-muted" href="/settings/home"><i class="fas fa-cog fa-lg"></i></a>
  212. </div>
  213. </div>
  214. </div>
  215. </div>
  216. <!-- <div class="card-footer bg-white py-1 d-none">
  217. <div class="d-flex justify-content-between text-center">
  218. <span class="pl-3 cursor-pointer" v-on:click="redirect(profile.url)">
  219. <p class="mb-0 font-weight-bold">{{profile.statuses_count}}</p>
  220. <p class="mb-0 small text-muted">Posts</p>
  221. </span>
  222. <span class="cursor-pointer" v-on:click="followersModal()">
  223. <p class="mb-0 font-weight-bold">{{profile.followers_count}}</p>
  224. <p class="mb-0 small text-muted">Followers</p>
  225. </span>
  226. <span class="pr-3 cursor-pointer" v-on:click="followingModal()">
  227. <p class="mb-0 font-weight-bold">{{profile.following_count}}</p>
  228. <p class="mb-0 small text-muted">Following</p>
  229. </span>
  230. </div>
  231. </div> -->
  232. </div>
  233. </div>
  234. <div v-show="modes.notify == true" class="mb-4">
  235. <notification-card></notification-card>
  236. </div>
  237. <div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
  238. <div class="card">
  239. <div class="card-header bg-white d-flex align-items-center justify-content-between">
  240. <a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
  241. <div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
  242. <div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
  243. </div>
  244. <div class="card-body pt-0">
  245. <div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
  246. <a :href="'/'+rec.username">
  247. <img :src="rec.avatar" width="32px" height="32px" class="rounded-circle mr-3">
  248. </a>
  249. <div class="media-body">
  250. <p class="mb-0 font-weight-bold small">
  251. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  252. {{rec.username}}
  253. </a>
  254. </p>
  255. <p class="mb-0 small text-muted">{{rec.message}}</p>
  256. </div>
  257. <a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. <footer>
  263. <div class="container pb-5">
  264. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  265. <a href="/site/about" class="text-dark pr-2">About Us</a>
  266. <a href="/site/help" class="text-dark pr-2">Help</a>
  267. <a href="/site/open-source" class="text-dark pr-2">Open Source</a>
  268. <a href="/site/language" class="text-dark pr-2">Language</a>
  269. <a href="/site/terms" class="text-dark pr-2">Terms</a>
  270. <a href="/site/privacy" class="text-dark pr-2">Privacy</a>
  271. <a href="/site/platform" class="text-dark pr-2">API</a>
  272. </p>
  273. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  274. <a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by Pixelfed</a>
  275. </p>
  276. </div>
  277. </footer>
  278. </div>
  279. </div>
  280. </div>
  281. <!-- <b-modal ref="followingModal"
  282. id="following-modal"
  283. hide-footer
  284. centered
  285. title="Following"
  286. body-class="list-group-flush p-0">
  287. <div class="list-group">
  288. <div class="list-group-item border-0" v-for="(user, index) in following" :key="'following_'+index">
  289. <div class="media">
  290. <a :href="user.url">
  291. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  292. </a>
  293. <div class="media-body">
  294. <p class="mb-0" style="font-size: 14px">
  295. <a :href="user.url" class="font-weight-bold text-dark">
  296. {{user.username}}
  297. </a>
  298. </p>
  299. <p class="text-muted mb-0" style="font-size: 14px">
  300. {{user.display_name}}
  301. </p>
  302. </div>
  303. <a class="btn btn-outline-secondary btn-sm" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Unfollow</a>
  304. </div>
  305. </div>
  306. <div v-if="following.length == 0" class="list-group-item border-0">
  307. <div class="list-group-item border-0">
  308. <p class="p-3 text-center mb-0 lead">You are not following anyone.</p>
  309. </div>
  310. </div>
  311. <div v-if="following.length != 0 && followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  312. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  313. </div>
  314. </div>
  315. </b-modal>
  316. <b-modal ref="followerModal"
  317. id="follower-modal"
  318. hide-footer
  319. centered
  320. title="Followers"
  321. body-class="list-group-flush p-0">
  322. <div class="list-group">
  323. <div class="list-group-item border-0" v-for="(user, index) in followers" :key="'follower_'+index">
  324. <div class="media">
  325. <a :href="user.url">
  326. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  327. </a>
  328. <div class="media-body">
  329. <p class="mb-0" style="font-size: 14px">
  330. <a :href="user.url" class="font-weight-bold text-dark">
  331. {{user.username}}
  332. </a>
  333. </p>
  334. <p class="text-muted mb-0" style="font-size: 14px">
  335. {{user.display_name}}
  336. </p>
  337. </div>
  338. </div>
  339. </div>
  340. <div v-if="followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  341. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  342. </div>
  343. </div>
  344. </b-modal> -->
  345. <b-modal
  346. id="lightbox"
  347. ref="lightboxModal"
  348. hide-header
  349. hide-footer
  350. centered
  351. size="lg"
  352. body-class="p-0"
  353. >
  354. <div v-if="lightboxMedia" :class="lightboxMedia.filter_class">
  355. <img :src="lightboxMedia.url" class="img-fluid" style="min-height: 100%; min-width: 100%">
  356. </div>
  357. </b-modal>
  358. </div>
  359. </template>
  360. <style type="text/css" scoped>
  361. .postPresenterContainer {
  362. display: flex;
  363. align-items: center;
  364. background: #fff;
  365. }
  366. .word-break {
  367. word-break: break-all;
  368. }
  369. .small .custom-control-label {
  370. padding-top: 3px;
  371. }
  372. .reply-btn {
  373. position: absolute;
  374. bottom: 12px;
  375. right: 20px;
  376. width: 60px;
  377. text-align: center;
  378. border-radius: 0 3px 3px 0;
  379. }
  380. .emoji-reactions .nav-item {
  381. font-size: 1.2rem;
  382. padding: 9px;
  383. cursor: pointer;
  384. }
  385. .emoji-reactions::-webkit-scrollbar {
  386. width: 0px;
  387. height: 0px;
  388. background: transparent;
  389. }
  390. </style>
  391. <script type="text/javascript">
  392. export default {
  393. props: ['scope'],
  394. data() {
  395. return {
  396. ids: [],
  397. config: {},
  398. page: 2,
  399. feed: [],
  400. profile: {},
  401. min_id: 0,
  402. max_id: 0,
  403. stories: {},
  404. suggestions: {},
  405. loading: true,
  406. replies: [],
  407. replyId: null,
  408. modes: {
  409. 'mod': false,
  410. 'dark': false,
  411. 'notify': true,
  412. 'distractionFree': false
  413. },
  414. followers: [],
  415. followerCursor: 1,
  416. followerMore: true,
  417. following: [],
  418. followingCursor: 1,
  419. followingMore: true,
  420. lightboxMedia: false,
  421. showSuggestions: false,
  422. showReadMore: true,
  423. replyStatus: {},
  424. replyText: '',
  425. emoji: ['😀','🤣','😃','😄','😆','😉','😊','😋','😘','😗','😙','😚','🤗','🤩','🤔','🤨','😐','😑','😶','🙄','😏','😣','😥','😮','🤐','😪','😫','😴','😌','😛','😜','😝','🤤','😒','😓','😔','😕','🙃','🤑','😲','🙁','😖','😞','😟','😤','😭','😦','😧','😨','😩','🤯','😬','😰','😱','😳','🤪','😵','😡','😠','🤬','😷','🤒','🤕','🤢','🤮','🤧','😇','🤠','🤡','🤥','🤫','🤭','🧐','🤓','😈','👿','👹','👺','💀','👻','👽','🤖','💩','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🤲','👐','🤝','👍','👎','👊','✊','🤛','🤜','🤞','✌️','🤟','🤘','👈','👉','👆','👇','☝️','✋','🤚','🖐','🖖','👋','🤙','💪','🖕','✍️','🙏','💍','💄','💋','👄','👅','👂','👃','👣','👁','👀','🧠','🗣','👤','👥'],
  426. showHashtagPosts: true,
  427. hashtagPosts: []
  428. }
  429. },
  430. beforeMount() {
  431. axios.get('/api/v2/config')
  432. .then(res => {
  433. this.config = res.data;
  434. this.fetchProfile();
  435. this.fetchTimelineApi();
  436. // if(this.config.announcement.enabled == true) {
  437. // let msg = $('<div>')
  438. // .addClass('alert alert-warning mb-0 rounded-0 text-center font-weight-bold')
  439. // .html(this.config.announcement.message);
  440. // $('body').prepend(msg);
  441. // }
  442. });
  443. },
  444. mounted() {
  445. if($('link[data-stylesheet="dark"]').length != 0) {
  446. this.modes.dark = true;
  447. }
  448. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  449. this.showSuggestions = false;
  450. } else {
  451. this.showSuggestions = true;
  452. }
  453. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  454. this.showReadMore = false;
  455. } else {
  456. this.showReadMore = true;
  457. }
  458. if(localStorage.getItem('pf_metro_ui.exp.df') == 'true') {
  459. this.modes.distractionFree = true;
  460. } else {
  461. this.modes.distractionFree = false;
  462. }
  463. this.$nextTick(function () {
  464. $('[data-toggle="tooltip"]').tooltip()
  465. });
  466. },
  467. updated() {
  468. if(this.showReadMore == true) {
  469. pixelfed.readmore();
  470. }
  471. },
  472. methods: {
  473. fetchProfile() {
  474. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  475. this.profile = res.data;
  476. if(this.profile.is_admin == true) {
  477. this.modes.mod = true;
  478. }
  479. $('.profile-card .loader').addClass('d-none');
  480. $('.profile-card .contents').removeClass('d-none');
  481. $('.profile-card .card-footer').removeClass('d-none');
  482. this.expRec();
  483. }).catch(err => {
  484. swal(
  485. 'Oops, something went wrong',
  486. 'Please reload the page.',
  487. 'error'
  488. );
  489. });
  490. },
  491. fetchTimelineApi() {
  492. let apiUrl = false;
  493. switch(this.scope) {
  494. case 'home':
  495. apiUrl = '/api/v1/timelines/home';
  496. break;
  497. case 'local':
  498. apiUrl = '/api/v1/timelines/public';
  499. break;
  500. case 'network':
  501. apiUrl = '/api/v1/timelines/network';
  502. break;
  503. }
  504. axios.get(apiUrl, {
  505. params: {
  506. max_id: this.max_id,
  507. limit: 6
  508. }
  509. }).then(res => {
  510. let data = res.data;
  511. this.feed.push(...data);
  512. let ids = data.map(status => status.id);
  513. this.ids = ids;
  514. this.min_id = Math.max(...ids);
  515. this.max_id = Math.min(...ids);
  516. $('.timeline .pagination').removeClass('d-none');
  517. this.loading = false;
  518. }).catch(err => {
  519. });
  520. },
  521. infiniteTimeline($state) {
  522. if(this.loading) {
  523. return;
  524. }
  525. let apiUrl = false;
  526. switch(this.scope) {
  527. case 'home':
  528. apiUrl = '/api/v1/timelines/home';
  529. break;
  530. case 'local':
  531. apiUrl = '/api/v1/timelines/public';
  532. break;
  533. case 'network':
  534. apiUrl = '/api/v1/timelines/network';
  535. break;
  536. }
  537. axios.get(apiUrl, {
  538. params: {
  539. max_id: this.max_id,
  540. limit: 6
  541. },
  542. }).then(res => {
  543. if (res.data.length && this.loading == false) {
  544. let data = res.data;
  545. let self = this;
  546. data.forEach(d => {
  547. if(self.ids.indexOf(d.id) == -1) {
  548. self.feed.push(d);
  549. self.ids.push(d.id);
  550. }
  551. });
  552. this.min_id = Math.max(...this.ids);
  553. this.max_id = Math.min(...this.ids);
  554. this.page += 1;
  555. $state.loaded();
  556. this.loading = false;
  557. } else {
  558. $state.complete();
  559. }
  560. });
  561. },
  562. loadMore(event) {
  563. let homeTimeline = '/api/v1/timelines/home';
  564. let localTimeline = '/api/v1/timelines/public';
  565. let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline;
  566. event.target.innerText = 'Loading...';
  567. axios.get(apiUrl, {
  568. params: {
  569. page: this.page,
  570. },
  571. }).then(res => {
  572. if (res.data.length && this.loading == false) {
  573. let data = res.data;
  574. let ids = data.map(status => status.id);
  575. this.min_id = Math.min(...ids);
  576. if(this.page == 1) {
  577. this.max_id = Math.max(...ids);
  578. }
  579. this.feed.push(...data);
  580. this.page += 1;
  581. this.loading = false;
  582. event.target.innerText = 'Load more posts';
  583. } else {
  584. }
  585. });
  586. },
  587. reportUrl(status) {
  588. let type = status.in_reply_to ? 'comment' : 'post';
  589. let id = status.id;
  590. return '/i/report?type=' + type + '&id=' + id;
  591. },
  592. commentFocus(status, $event) {
  593. if(this.replyId == status.id || status.comments_disabled) {
  594. return;
  595. }
  596. this.replies = {};
  597. this.replyStatus = {};
  598. this.replyText = '';
  599. this.replyId = status.id;
  600. this.replyStatus = status;
  601. this.fetchStatusComments(status, '');
  602. },
  603. likeStatus(status) {
  604. if($('body').hasClass('loggedIn') == false) {
  605. return;
  606. }
  607. axios.post('/i/like', {
  608. item: status.id
  609. }).then(res => {
  610. status.favourites_count = res.data.count;
  611. status.favourited = !status.favourited;
  612. }).catch(err => {
  613. swal('Error', 'Something went wrong, please try again later.', 'error');
  614. });
  615. },
  616. shareStatus(status, $event) {
  617. if($('body').hasClass('loggedIn') == false) {
  618. return;
  619. }
  620. axios.post('/i/share', {
  621. item: status.id
  622. }).then(res => {
  623. status.reblogs_count = res.data.count;
  624. status.reblogged = !status.reblogged;
  625. }).catch(err => {
  626. swal('Error', 'Something went wrong, please try again later.', 'error');
  627. });
  628. },
  629. timestampFormat(timestamp) {
  630. let ts = new Date(timestamp);
  631. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  632. },
  633. editUrl(status) {
  634. return status.url + '/edit';
  635. },
  636. redirect(url) {
  637. window.location.href = url;
  638. return;
  639. },
  640. replyUrl(status) {
  641. let username = this.profile.username;
  642. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  643. return '/p/' + username + '/' + id;
  644. },
  645. mentionUrl(status) {
  646. let username = status.account.username;
  647. let id = status.id;
  648. return '/p/' + username + '/' + id;
  649. },
  650. statusOwner(status) {
  651. let sid = status.account.id;
  652. let uid = this.profile.id;
  653. if(sid == uid) {
  654. return true;
  655. } else {
  656. return false;
  657. }
  658. },
  659. fetchStatusComments(status, card) {
  660. axios.get('/api/v2/status/'+status.id+'/replies')
  661. .then(res => {
  662. let data = res.data.filter(res => {
  663. return res.sensitive == false;
  664. });
  665. this.replies = _.reverse(data);
  666. }).catch(err => {
  667. })
  668. },
  669. muteProfile(status) {
  670. if($('body').hasClass('loggedIn') == false) {
  671. return;
  672. }
  673. axios.post('/i/mute', {
  674. type: 'user',
  675. item: status.account.id
  676. }).then(res => {
  677. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  678. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  679. }).catch(err => {
  680. swal('Error', 'Something went wrong. Please try again later.', 'error');
  681. });
  682. },
  683. blockProfile(status) {
  684. if($('body').hasClass('loggedIn') == false) {
  685. return;
  686. }
  687. axios.post('/i/block', {
  688. type: 'user',
  689. item: status.account.id
  690. }).then(res => {
  691. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  692. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  693. }).catch(err => {
  694. swal('Error', 'Something went wrong. Please try again later.', 'error');
  695. });
  696. },
  697. deletePost(status, index) {
  698. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  699. return;
  700. }
  701. if(window.confirm('Are you sure you want to delete this post?') == false) {
  702. return;
  703. }
  704. axios.post('/i/delete', {
  705. type: 'status',
  706. item: status.id
  707. }).then(res => {
  708. this.feed = this.feed.filter(s => {
  709. return s.id != status.id;
  710. })
  711. swal('Success', 'You have successfully deleted this post', 'success');
  712. }).catch(err => {
  713. swal('Error', 'Something went wrong. Please try again later.', 'error');
  714. });
  715. },
  716. commentSubmit(status, $event) {
  717. let id = status.id;
  718. let comment = this.replyText;
  719. axios.post('/i/comment', {
  720. item: id,
  721. comment: comment
  722. }).then(res => {
  723. this.replyText = '';
  724. this.replies.push(res.data.entity);
  725. });
  726. },
  727. moderatePost(status, action, $event) {
  728. let username = status.account.username;
  729. console.log('action: ' + action + ' status id' + status.id);
  730. switch(action) {
  731. case 'autocw':
  732. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  733. swal({
  734. title: 'Confirm',
  735. text: msg,
  736. icon: 'warning',
  737. buttons: true,
  738. dangerMode: true
  739. }).then(res => {
  740. if(res) {
  741. axios.post('/api/v2/moderator/action', {
  742. action: action,
  743. item_id: status.id,
  744. item_type: 'status'
  745. }).then(res => {
  746. swal('Success', 'Successfully enforced CW for ' + username, 'success');
  747. }).catch(err => {
  748. swal(
  749. 'Error',
  750. 'Something went wrong, please try again later.',
  751. 'error'
  752. );
  753. });
  754. }
  755. });
  756. break;
  757. case 'noautolink':
  758. msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
  759. swal({
  760. title: 'Confirm',
  761. text: msg,
  762. icon: 'warning',
  763. buttons: true,
  764. dangerMode: true
  765. }).then(res => {
  766. if(res) {
  767. axios.post('/api/v2/moderator/action', {
  768. action: action,
  769. item_id: status.id,
  770. item_type: 'status'
  771. }).then(res => {
  772. swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
  773. }).catch(err => {
  774. swal(
  775. 'Error',
  776. 'Something went wrong, please try again later.',
  777. 'error'
  778. );
  779. });
  780. }
  781. });
  782. break;
  783. case 'unlisted':
  784. msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
  785. swal({
  786. title: 'Confirm',
  787. text: msg,
  788. icon: 'warning',
  789. buttons: true,
  790. dangerMode: true
  791. }).then(res => {
  792. if(res) {
  793. axios.post('/api/v2/moderator/action', {
  794. action: action,
  795. item_id: status.id,
  796. item_type: 'status'
  797. }).then(res => {
  798. swal('Success', 'Successfully unlisted for ' + username, 'success');
  799. }).catch(err => {
  800. swal(
  801. 'Error',
  802. 'Something went wrong, please try again later.',
  803. 'error'
  804. );
  805. });
  806. }
  807. });
  808. break;
  809. case 'disable':
  810. msg = 'Are you sure you want to disable ' + username + '’s account ?';
  811. swal({
  812. title: 'Confirm',
  813. text: msg,
  814. icon: 'warning',
  815. buttons: true,
  816. dangerMode: true
  817. }).then(res => {
  818. if(res) {
  819. axios.post('/api/v2/moderator/action', {
  820. action: action,
  821. item_id: status.id,
  822. item_type: 'status'
  823. }).then(res => {
  824. swal('Success', 'Successfully disabled ' + username + '’s account', 'success');
  825. }).catch(err => {
  826. swal(
  827. 'Error',
  828. 'Something went wrong, please try again later.',
  829. 'error'
  830. );
  831. });
  832. }
  833. });
  834. break;
  835. case 'suspend':
  836. msg = 'Are you sure you want to suspend ' + username + '’s account ?';
  837. swal({
  838. title: 'Confirm',
  839. text: msg,
  840. icon: 'warning',
  841. buttons: true,
  842. dangerMode: true
  843. }).then(res => {
  844. if(res) {
  845. axios.post('/api/v2/moderator/action', {
  846. action: action,
  847. item_id: status.id,
  848. item_type: 'status'
  849. }).then(res => {
  850. swal('Success', 'Successfully suspend ' + username + '’s account', 'success');
  851. }).catch(err => {
  852. swal(
  853. 'Error',
  854. 'Something went wrong, please try again later.',
  855. 'error'
  856. );
  857. });
  858. }
  859. });
  860. break;
  861. }
  862. },
  863. followingModal() {
  864. if(this.following.length > 0) {
  865. this.$refs.followingModal.show();
  866. return;
  867. }
  868. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  869. params: {
  870. page: this.followingCursor
  871. }
  872. })
  873. .then(res => {
  874. this.following = res.data;
  875. this.followingCursor++;
  876. });
  877. if(res.data.length < 10) {
  878. this.followingMore = false;
  879. }
  880. this.$refs.followingModal.show();
  881. },
  882. followersModal() {
  883. if(this.followers.length > 0) {
  884. this.$refs.followerModal.show();
  885. return;
  886. }
  887. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  888. params: {
  889. page: this.followerCursor
  890. }
  891. })
  892. .then(res => {
  893. this.followers = res.data;
  894. this.followerCursor++;
  895. })
  896. if(res.data.length < 10) {
  897. this.followerMore = false;
  898. }
  899. this.$refs.followerModal.show();
  900. },
  901. followingLoadMore() {
  902. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  903. params: {
  904. page: this.followingCursor
  905. }
  906. })
  907. .then(res => {
  908. if(res.data.length > 0) {
  909. this.following.push(...res.data);
  910. this.followingCursor++;
  911. }
  912. if(res.data.length < 10) {
  913. this.followingMore = false;
  914. }
  915. });
  916. },
  917. followersLoadMore() {
  918. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  919. params: {
  920. page: this.followerCursor
  921. }
  922. })
  923. .then(res => {
  924. if(res.data.length > 0) {
  925. this.followers.push(...res.data);
  926. this.followerCursor++;
  927. }
  928. if(res.data.length < 10) {
  929. this.followerMore = false;
  930. }
  931. });
  932. },
  933. lightbox(src) {
  934. this.lightboxMedia = src;
  935. this.$refs.lightboxModal.show();
  936. },
  937. expLc(status) {
  938. if(this.config.ab.lc == false) {
  939. return true;
  940. }
  941. if(this.statusOwner(status) == true) {
  942. return true;
  943. }
  944. return false;
  945. },
  946. expRec() {
  947. if(this.config.ab.rec == false) {
  948. return;
  949. }
  950. axios.get('/api/local/exp/rec')
  951. .then(res => {
  952. this.suggestions = res.data;
  953. })
  954. },
  955. expRecFollow(id, index) {
  956. if(this.config.ab.rec == false) {
  957. return;
  958. }
  959. axios.post('/i/follow', {
  960. item: id
  961. }).then(res => {
  962. this.suggestions.splice(index, 1);
  963. }).catch(err => {
  964. if(err.response.data.message) {
  965. swal('Error', err.response.data.message, 'error');
  966. }
  967. });
  968. },
  969. followModalAction(id, index, type = 'following') {
  970. axios.post('/i/follow', {
  971. item: id
  972. }).then(res => {
  973. if(type == 'following') {
  974. this.following.splice(index, 1);
  975. }
  976. }).catch(err => {
  977. if(err.response.data.message) {
  978. swal('Error', err.response.data.message, 'error');
  979. }
  980. });
  981. },
  982. owner(status) {
  983. return this.profile.id === status.account.id;
  984. },
  985. admin() {
  986. return this.profile.is_admin == true;
  987. },
  988. ownerOrAdmin(status) {
  989. return this.owner(status) || this.admin();
  990. },
  991. hideSuggestions() {
  992. localStorage.setItem('pf_metro_ui.exp.rec', false);
  993. this.showSuggestions = false;
  994. },
  995. emojiReaction(status) {
  996. let em = event.target.innerText;
  997. if(this.replyText.length == 0) {
  998. this.replyText = em + ' ';
  999. $('textarea[name="comment"]').focus();
  1000. } else {
  1001. this.replyText += em + ' ';
  1002. $('textarea[name="comment"]').focus();
  1003. }
  1004. },
  1005. refreshSuggestions() {
  1006. let el = event.target.parentNode;
  1007. if(el.classList.contains('disabled') == true) {
  1008. return;
  1009. }
  1010. axios.get('/api/local/exp/rec', {
  1011. params: {
  1012. refresh: true
  1013. }
  1014. })
  1015. .then(res => {
  1016. this.suggestions = res.data;
  1017. if (el.classList) {
  1018. el.classList.add('disabled');
  1019. el.classList.add('text-light');
  1020. }
  1021. else {
  1022. el.className += ' ' + 'disabled text-light';
  1023. }
  1024. setTimeout(function() {
  1025. el.setAttribute('href', '#');
  1026. if (el.classList) {
  1027. el.classList.remove('disabled');
  1028. el.classList.remove('text-light');
  1029. }
  1030. else {
  1031. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1032. }
  1033. }, 10000);
  1034. });
  1035. }
  1036. }
  1037. }
  1038. </script>