Timeline.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  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-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="modes.infinite == true && !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="modes.infinite == false && !loading && feed.length > 0" class="pagination">
  185. <p class="btn btn-outline-secondary font-weight-bold btn-block" v-on:click="loadMore">Load more posts</p>
  186. </div>
  187. <div v-if="!loading && scope == 'home' && feed.length == 0">
  188. <div class="card">
  189. <div class="card-body text-center">
  190. <p class="h2 font-weight-lighter p-5">Hello, {{profile.acct}}</p>
  191. <p class="text-lighter"><i class="fas fa-camera-retro fa-5x"></i></p>
  192. <p class="h3 font-weight-lighter p-5">Start following people to build your timeline.</p>
  193. <p><a href="/discover" class="btn btn-primary font-weight-bold py-0">Discover new people and posts</a></p>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. <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">
  200. <div class="position-sticky" style="top:68px;">
  201. <div class="mb-4">
  202. <div class="">
  203. <div class="">
  204. <div class="media d-flex align-items-center">
  205. <a :href="profile.url">
  206. <img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
  207. </a>
  208. <div class="media-body d-flex justify-content-between word-break" >
  209. <div>
  210. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
  211. <p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
  212. </div>
  213. <div class="ml-2">
  214. <a :class="[optionMenuState == true ? 'text-primary' :'text-muted']" v-on:click="toggleOptionsMenu()"><i class="fas fa-cog fa-lg"></i></a>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. <!-- <div class="card-footer bg-white py-1 d-none">
  220. <div class="d-flex justify-content-between text-center">
  221. <span class="pl-3 cursor-pointer" v-on:click="redirect(profile.url)">
  222. <p class="mb-0 font-weight-bold">{{profile.statuses_count}}</p>
  223. <p class="mb-0 small text-muted">Posts</p>
  224. </span>
  225. <span class="cursor-pointer" v-on:click="followersModal()">
  226. <p class="mb-0 font-weight-bold">{{profile.followers_count}}</p>
  227. <p class="mb-0 small text-muted">Followers</p>
  228. </span>
  229. <span class="pr-3 cursor-pointer" v-on:click="followingModal()">
  230. <p class="mb-0 font-weight-bold">{{profile.following_count}}</p>
  231. <p class="mb-0 small text-muted">Following</p>
  232. </span>
  233. </div>
  234. </div> -->
  235. </div>
  236. </div>
  237. <div v-if="optionMenuState == true" class="mb-4">
  238. <div class="card options-card">
  239. <div class="card-body small">
  240. <div v-if="profile.is_admin" class="custom-control custom-switch mb-3">
  241. <input type="checkbox" class="custom-control-input" id="mode-mod" v-on:click="modeModToggle()" v-model="modes.mod">
  242. <label class="custom-control-label font-weight-bold" for="mode-mod">Moderator Mode</label>
  243. </div>
  244. <!-- <div class="custom-control custom-switch mb-3">
  245. <input type="checkbox" class="custom-control-input" id="mode-notify" v-on:click="modeNotifyToggle()" v-model="!modes.notify">
  246. <label class="custom-control-label font-weight-bold" for="mode-notify">Disable Notifications</label>
  247. </div> -->
  248. <div class="custom-control custom-switch">
  249. <input type="checkbox" class="custom-control-input" id="mode-infinite" v-on:click="modeInfiniteToggle()" v-model="modes.infinite">
  250. <label class="custom-control-label font-weight-bold" for="mode-infinite">Enable Infinite Scroll</label>
  251. </div>
  252. <hr>
  253. <p class="font-weight-bold">BETA FEATURES</p>
  254. <div class="alert alert-primary font-weight-bold text-center">Experimental features have been moved to the <a href="/settings/labs">Labs</a> settings page.</div>
  255. </div>
  256. </div>
  257. </div>
  258. <div v-show="modes.notify == true" class="mb-4">
  259. <notification-card></notification-card>
  260. </div>
  261. <div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
  262. <div class="card">
  263. <div class="card-header bg-white d-flex align-items-center justify-content-between">
  264. <a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
  265. <div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
  266. <div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
  267. </div>
  268. <div class="card-body pt-0">
  269. <div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
  270. <a :href="'/'+rec.username">
  271. <img :src="rec.avatar" width="32px" height="32px" class="rounded-circle mr-3">
  272. </a>
  273. <div class="media-body">
  274. <p class="mb-0 font-weight-bold small">
  275. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  276. {{rec.username}}
  277. </a>
  278. </p>
  279. <p class="mb-0 small text-muted">{{rec.message}}</p>
  280. </div>
  281. <a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <footer>
  287. <div class="container pb-5">
  288. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  289. <a href="/site/about" class="text-dark pr-2">About Us</a>
  290. <a href="/site/help" class="text-dark pr-2">Help</a>
  291. <a href="/site/open-source" class="text-dark pr-2">Open Source</a>
  292. <a href="/site/language" class="text-dark pr-2">Language</a>
  293. <a href="/site/terms" class="text-dark pr-2">Terms</a>
  294. <a href="/site/privacy" class="text-dark pr-2">Privacy</a>
  295. <a href="/site/platform" class="text-dark pr-2">API</a>
  296. </p>
  297. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  298. <a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by PixelFed</a>
  299. </p>
  300. </div>
  301. </footer>
  302. </div>
  303. </div>
  304. </div>
  305. <!-- <b-modal ref="followingModal"
  306. id="following-modal"
  307. hide-footer
  308. centered
  309. title="Following"
  310. body-class="list-group-flush p-0">
  311. <div class="list-group">
  312. <div class="list-group-item border-0" v-for="(user, index) in following" :key="'following_'+index">
  313. <div class="media">
  314. <a :href="user.url">
  315. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  316. </a>
  317. <div class="media-body">
  318. <p class="mb-0" style="font-size: 14px">
  319. <a :href="user.url" class="font-weight-bold text-dark">
  320. {{user.username}}
  321. </a>
  322. </p>
  323. <p class="text-muted mb-0" style="font-size: 14px">
  324. {{user.display_name}}
  325. </p>
  326. </div>
  327. <a class="btn btn-outline-secondary btn-sm" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Unfollow</a>
  328. </div>
  329. </div>
  330. <div v-if="following.length == 0" class="list-group-item border-0">
  331. <div class="list-group-item border-0">
  332. <p class="p-3 text-center mb-0 lead">You are not following anyone.</p>
  333. </div>
  334. </div>
  335. <div v-if="following.length != 0 && followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  336. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  337. </div>
  338. </div>
  339. </b-modal>
  340. <b-modal ref="followerModal"
  341. id="follower-modal"
  342. hide-footer
  343. centered
  344. title="Followers"
  345. body-class="list-group-flush p-0">
  346. <div class="list-group">
  347. <div class="list-group-item border-0" v-for="(user, index) in followers" :key="'follower_'+index">
  348. <div class="media">
  349. <a :href="user.url">
  350. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  351. </a>
  352. <div class="media-body">
  353. <p class="mb-0" style="font-size: 14px">
  354. <a :href="user.url" class="font-weight-bold text-dark">
  355. {{user.username}}
  356. </a>
  357. </p>
  358. <p class="text-muted mb-0" style="font-size: 14px">
  359. {{user.display_name}}
  360. </p>
  361. </div>
  362. </div>
  363. </div>
  364. <div v-if="followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  365. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  366. </div>
  367. </div>
  368. </b-modal> -->
  369. <b-modal
  370. id="lightbox"
  371. ref="lightboxModal"
  372. hide-header
  373. hide-footer
  374. centered
  375. size="lg"
  376. body-class="p-0"
  377. >
  378. <div v-if="lightboxMedia" :class="lightboxMedia.filter_class">
  379. <img :src="lightboxMedia.url" class="img-fluid" style="min-height: 100%; min-width: 100%">
  380. </div>
  381. </b-modal>
  382. </div>
  383. </template>
  384. <style type="text/css" scoped>
  385. .postPresenterContainer {
  386. display: flex;
  387. align-items: center;
  388. background: #fff;
  389. }
  390. .word-break {
  391. word-break: break-all;
  392. }
  393. .small .custom-control-label {
  394. padding-top: 3px;
  395. }
  396. .reply-btn {
  397. position: absolute;
  398. bottom: 12px;
  399. right: 20px;
  400. width: 60px;
  401. text-align: center;
  402. border-radius: 0 3px 3px 0;
  403. }
  404. .emoji-reactions .nav-item {
  405. font-size: 1.2rem;
  406. padding: 9px;
  407. cursor: pointer;
  408. }
  409. .emoji-reactions::-webkit-scrollbar {
  410. width: 0px;
  411. height: 0px;
  412. background: transparent;
  413. }
  414. </style>
  415. <script type="text/javascript">
  416. export default {
  417. props: ['scope'],
  418. data() {
  419. return {
  420. ids: [],
  421. config: {},
  422. page: 2,
  423. feed: [],
  424. profile: {},
  425. min_id: 0,
  426. max_id: 0,
  427. stories: {},
  428. suggestions: {},
  429. loading: true,
  430. replies: [],
  431. replyId: null,
  432. optionMenuState: false,
  433. modes: {
  434. 'mod': false,
  435. 'dark': false,
  436. 'notify': true,
  437. 'infinite': true,
  438. 'distractionFree': false
  439. },
  440. followers: [],
  441. followerCursor: 1,
  442. followerMore: true,
  443. following: [],
  444. followingCursor: 1,
  445. followingMore: true,
  446. lightboxMedia: false,
  447. showSuggestions: false,
  448. showReadMore: true,
  449. replyStatus: {},
  450. replyText: '',
  451. emoji: ['😀','🤣','😃','😄','😆','😉','😊','😋','😘','😗','😙','😚','🤗','🤩','🤔','🤨','😐','😑','😶','🙄','😏','😣','😥','😮','🤐','😪','😫','😴','😌','😛','😜','😝','🤤','😒','😓','😔','😕','🙃','🤑','😲','🙁','😖','😞','😟','😤','😭','😦','😧','😨','😩','🤯','😬','😰','😱','😳','🤪','😵','😡','😠','🤬','😷','🤒','🤕','🤢','🤮','🤧','😇','🤠','🤡','🤥','🤫','🤭','🧐','🤓','😈','👿','👹','👺','💀','👻','👽','🤖','💩','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🤲','👐','🤝','👍','👎','👊','✊','🤛','🤜','🤞','✌️','🤟','🤘','👈','👉','👆','👇','☝️','✋','🤚','🖐','🖖','👋','🤙','💪','🖕','✍️','🙏','💍','💄','💋','👄','👅','👂','👃','👣','👁','👀','🧠','🗣','👤','👥']
  452. }
  453. },
  454. beforeMount() {
  455. axios.get('/api/v2/config')
  456. .then(res => {
  457. this.config = res.data;
  458. this.fetchProfile();
  459. this.fetchTimelineApi();
  460. });
  461. },
  462. mounted() {
  463. if($('link[data-stylesheet="dark"]').length != 0) {
  464. this.modes.dark = true;
  465. }
  466. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  467. this.showSuggestions = false;
  468. } else {
  469. this.showSuggestions = true;
  470. }
  471. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  472. this.showReadMore = false;
  473. } else {
  474. this.showReadMore = true;
  475. }
  476. if(localStorage.getItem('pf_metro_ui.exp.df') == 'true') {
  477. this.modes.distractionFree = true;
  478. } else {
  479. this.modes.distractionFree = false;
  480. }
  481. this.$nextTick(function () {
  482. $('[data-toggle="tooltip"]').tooltip()
  483. });
  484. },
  485. updated() {
  486. if(this.showReadMore == true) {
  487. pixelfed.readmore();
  488. }
  489. },
  490. methods: {
  491. fetchProfile() {
  492. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  493. this.profile = res.data;
  494. if(this.profile.is_admin == true) {
  495. this.modes.mod = true;
  496. }
  497. $('.profile-card .loader').addClass('d-none');
  498. $('.profile-card .contents').removeClass('d-none');
  499. $('.profile-card .card-footer').removeClass('d-none');
  500. this.expRec();
  501. }).catch(err => {
  502. swal(
  503. 'Oops, something went wrong',
  504. 'Please reload the page.',
  505. 'error'
  506. );
  507. });
  508. },
  509. fetchTimelineApi() {
  510. let apiUrl = false;
  511. switch(this.scope) {
  512. case 'home':
  513. apiUrl = '/api/v1/timelines/home';
  514. break;
  515. case 'local':
  516. apiUrl = '/api/v1/timelines/public';
  517. break;
  518. case 'network':
  519. apiUrl = '/api/v1/timelines/network';
  520. break;
  521. }
  522. axios.get(apiUrl, {
  523. params: {
  524. max_id: this.max_id,
  525. limit: 6
  526. }
  527. }).then(res => {
  528. let data = res.data;
  529. this.feed.push(...data);
  530. let ids = data.map(status => status.id);
  531. this.ids = ids;
  532. this.min_id = Math.max(...ids);
  533. this.max_id = Math.min(...ids);
  534. $('.timeline .pagination').removeClass('d-none');
  535. this.loading = false;
  536. }).catch(err => {
  537. });
  538. },
  539. infiniteTimeline($state) {
  540. if(this.loading) {
  541. return;
  542. }
  543. let apiUrl = false;
  544. switch(this.scope) {
  545. case 'home':
  546. apiUrl = '/api/v1/timelines/home';
  547. break;
  548. case 'local':
  549. apiUrl = '/api/v1/timelines/public';
  550. break;
  551. case 'network':
  552. apiUrl = '/api/v1/timelines/network';
  553. break;
  554. }
  555. axios.get(apiUrl, {
  556. params: {
  557. max_id: this.max_id,
  558. limit: 6
  559. },
  560. }).then(res => {
  561. if (res.data.length && this.loading == false) {
  562. let data = res.data;
  563. let self = this;
  564. data.forEach(d => {
  565. if(self.ids.indexOf(d.id) == -1) {
  566. self.feed.push(d);
  567. self.ids.push(d.id);
  568. }
  569. });
  570. this.min_id = Math.max(...this.ids);
  571. this.max_id = Math.min(...this.ids);
  572. this.page += 1;
  573. $state.loaded();
  574. this.loading = false;
  575. } else {
  576. $state.complete();
  577. }
  578. });
  579. },
  580. loadMore(event) {
  581. let homeTimeline = '/api/v1/timelines/home';
  582. let localTimeline = '/api/v1/timelines/public';
  583. let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline;
  584. event.target.innerText = 'Loading...';
  585. axios.get(apiUrl, {
  586. params: {
  587. page: this.page,
  588. },
  589. }).then(res => {
  590. if (res.data.length && this.loading == false) {
  591. let data = res.data;
  592. let ids = data.map(status => status.id);
  593. this.min_id = Math.min(...ids);
  594. if(this.page == 1) {
  595. this.max_id = Math.max(...ids);
  596. }
  597. this.feed.push(...data);
  598. this.page += 1;
  599. this.loading = false;
  600. event.target.innerText = 'Load more posts';
  601. } else {
  602. }
  603. });
  604. },
  605. reportUrl(status) {
  606. let type = status.in_reply_to ? 'comment' : 'post';
  607. let id = status.id;
  608. return '/i/report?type=' + type + '&id=' + id;
  609. },
  610. commentFocus(status, $event) {
  611. if(this.replyId == status.id || status.comments_disabled) {
  612. return;
  613. }
  614. this.replies = {};
  615. this.replyStatus = {};
  616. this.replyText = '';
  617. this.replyId = status.id;
  618. this.replyStatus = status;
  619. this.fetchStatusComments(status, '');
  620. },
  621. likeStatus(status) {
  622. if($('body').hasClass('loggedIn') == false) {
  623. return;
  624. }
  625. axios.post('/i/like', {
  626. item: status.id
  627. }).then(res => {
  628. status.favourites_count = res.data.count;
  629. status.favourited = !status.favourited;
  630. }).catch(err => {
  631. swal('Error', 'Something went wrong, please try again later.', 'error');
  632. });
  633. },
  634. shareStatus(status, $event) {
  635. if($('body').hasClass('loggedIn') == false) {
  636. return;
  637. }
  638. axios.post('/i/share', {
  639. item: status.id
  640. }).then(res => {
  641. status.reblogs_count = res.data.count;
  642. status.reblogged = !status.reblogged;
  643. }).catch(err => {
  644. swal('Error', 'Something went wrong, please try again later.', 'error');
  645. });
  646. },
  647. timestampFormat(timestamp) {
  648. let ts = new Date(timestamp);
  649. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  650. },
  651. editUrl(status) {
  652. return status.url + '/edit';
  653. },
  654. redirect(url) {
  655. window.location.href = url;
  656. return;
  657. },
  658. replyUrl(status) {
  659. let username = this.profile.username;
  660. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  661. return '/p/' + username + '/' + id;
  662. },
  663. mentionUrl(status) {
  664. let username = status.account.username;
  665. let id = status.id;
  666. return '/p/' + username + '/' + id;
  667. },
  668. statusOwner(status) {
  669. let sid = status.account.id;
  670. let uid = this.profile.id;
  671. if(sid == uid) {
  672. return true;
  673. } else {
  674. return false;
  675. }
  676. },
  677. fetchStatusComments(status, card) {
  678. axios.get('/api/v2/status/'+status.id+'/replies')
  679. .then(res => {
  680. let data = res.data;
  681. this.replies = _.reverse(data);
  682. }).catch(err => {
  683. })
  684. },
  685. muteProfile(status) {
  686. if($('body').hasClass('loggedIn') == false) {
  687. return;
  688. }
  689. axios.post('/i/mute', {
  690. type: 'user',
  691. item: status.account.id
  692. }).then(res => {
  693. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  694. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  695. }).catch(err => {
  696. swal('Error', 'Something went wrong. Please try again later.', 'error');
  697. });
  698. },
  699. blockProfile(status) {
  700. if($('body').hasClass('loggedIn') == false) {
  701. return;
  702. }
  703. axios.post('/i/block', {
  704. type: 'user',
  705. item: status.account.id
  706. }).then(res => {
  707. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  708. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  709. }).catch(err => {
  710. swal('Error', 'Something went wrong. Please try again later.', 'error');
  711. });
  712. },
  713. deletePost(status, index) {
  714. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  715. return;
  716. }
  717. if(window.confirm('Are you sure you want to delete this post?') == false) {
  718. return;
  719. }
  720. axios.post('/i/delete', {
  721. type: 'status',
  722. item: status.id
  723. }).then(res => {
  724. this.feed.splice(index,1);
  725. swal('Success', 'You have successfully deleted this post', 'success');
  726. }).catch(err => {
  727. swal('Error', 'Something went wrong. Please try again later.', 'error');
  728. });
  729. },
  730. commentSubmit(status, $event) {
  731. let id = status.id;
  732. let comment = this.replyText;
  733. axios.post('/i/comment', {
  734. item: id,
  735. comment: comment
  736. }).then(res => {
  737. this.replyText = '';
  738. this.replies.push(res.data.entity);
  739. });
  740. },
  741. moderatePost(status, action, $event) {
  742. let username = status.account.username;
  743. console.log('action: ' + action + ' status id' + status.id);
  744. switch(action) {
  745. case 'autocw':
  746. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  747. swal({
  748. title: 'Confirm',
  749. text: msg,
  750. icon: 'warning',
  751. buttons: true,
  752. dangerMode: true
  753. }).then(res => {
  754. if(res) {
  755. axios.post('/api/v2/moderator/action', {
  756. action: action,
  757. item_id: status.id,
  758. item_type: 'status'
  759. }).then(res => {
  760. swal('Success', 'Successfully enforced CW for ' + username, 'success');
  761. }).catch(err => {
  762. swal(
  763. 'Error',
  764. 'Something went wrong, please try again later.',
  765. 'error'
  766. );
  767. });
  768. }
  769. });
  770. break;
  771. case 'noautolink':
  772. msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
  773. swal({
  774. title: 'Confirm',
  775. text: msg,
  776. icon: 'warning',
  777. buttons: true,
  778. dangerMode: true
  779. }).then(res => {
  780. if(res) {
  781. axios.post('/api/v2/moderator/action', {
  782. action: action,
  783. item_id: status.id,
  784. item_type: 'status'
  785. }).then(res => {
  786. swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
  787. }).catch(err => {
  788. swal(
  789. 'Error',
  790. 'Something went wrong, please try again later.',
  791. 'error'
  792. );
  793. });
  794. }
  795. });
  796. break;
  797. case 'unlisted':
  798. msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
  799. swal({
  800. title: 'Confirm',
  801. text: msg,
  802. icon: 'warning',
  803. buttons: true,
  804. dangerMode: true
  805. }).then(res => {
  806. if(res) {
  807. axios.post('/api/v2/moderator/action', {
  808. action: action,
  809. item_id: status.id,
  810. item_type: 'status'
  811. }).then(res => {
  812. swal('Success', 'Successfully unlisted for ' + username, 'success');
  813. }).catch(err => {
  814. swal(
  815. 'Error',
  816. 'Something went wrong, please try again later.',
  817. 'error'
  818. );
  819. });
  820. }
  821. });
  822. break;
  823. case 'disable':
  824. msg = 'Are you sure you want to disable ' + username + '’s account ?';
  825. swal({
  826. title: 'Confirm',
  827. text: msg,
  828. icon: 'warning',
  829. buttons: true,
  830. dangerMode: true
  831. }).then(res => {
  832. if(res) {
  833. axios.post('/api/v2/moderator/action', {
  834. action: action,
  835. item_id: status.id,
  836. item_type: 'status'
  837. }).then(res => {
  838. swal('Success', 'Successfully disabled ' + username + '’s account', 'success');
  839. }).catch(err => {
  840. swal(
  841. 'Error',
  842. 'Something went wrong, please try again later.',
  843. 'error'
  844. );
  845. });
  846. }
  847. });
  848. break;
  849. case 'suspend':
  850. msg = 'Are you sure you want to suspend ' + username + '’s account ?';
  851. swal({
  852. title: 'Confirm',
  853. text: msg,
  854. icon: 'warning',
  855. buttons: true,
  856. dangerMode: true
  857. }).then(res => {
  858. if(res) {
  859. axios.post('/api/v2/moderator/action', {
  860. action: action,
  861. item_id: status.id,
  862. item_type: 'status'
  863. }).then(res => {
  864. swal('Success', 'Successfully suspend ' + username + '’s account', 'success');
  865. }).catch(err => {
  866. swal(
  867. 'Error',
  868. 'Something went wrong, please try again later.',
  869. 'error'
  870. );
  871. });
  872. }
  873. });
  874. break;
  875. }
  876. },
  877. toggleOptionsMenu() {
  878. this.optionMenuState = !this.optionMenuState;
  879. },
  880. modeModToggle() {
  881. this.modes.mod = !this.modes.mod;
  882. //window.ls.set('pixelfed-classicui-settings', this.modes);
  883. },
  884. modeNotifyToggle() {
  885. this.modes.notify = !this.modes.notify;
  886. //window.ls.set('pixelfed-classicui-settings', this.modes);
  887. },
  888. modeDarkToggle() {
  889. // todo: more graceful stylesheet change
  890. if(this.modes.dark == true) {
  891. axios.post('/i/metro/dark-mode', {
  892. mode: 'light'
  893. }).then(res => {
  894. $('link[data-stylesheet=dark]')
  895. .attr('data-stylesheet', 'light')
  896. .attr('href', '/css/app.css?v=' + Date.now());
  897. this.modes.dark = false;
  898. });
  899. } else {
  900. axios.post('/i/metro/dark-mode', {
  901. mode: 'dark'
  902. }).then(res => {
  903. $('link[data-stylesheet=light]')
  904. .attr('data-stylesheet', 'dark')
  905. .attr('href', '/css/appdark.css?v=' + Date.now());
  906. this.modes.dark = true;
  907. });
  908. }
  909. //window.ls.set('pixelfed-classicui-settings', this.modes);
  910. },
  911. modeInfiniteToggle() {
  912. this.modes.infinite = !this.modes.infinite
  913. //window.ls.set('pixelfed-classicui-settings', this.modes);
  914. },
  915. followingModal() {
  916. if(this.following.length > 0) {
  917. this.$refs.followingModal.show();
  918. return;
  919. }
  920. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  921. params: {
  922. page: this.followingCursor
  923. }
  924. })
  925. .then(res => {
  926. this.following = res.data;
  927. this.followingCursor++;
  928. });
  929. if(res.data.length < 10) {
  930. this.followingMore = false;
  931. }
  932. this.$refs.followingModal.show();
  933. },
  934. followersModal() {
  935. if(this.followers.length > 0) {
  936. this.$refs.followerModal.show();
  937. return;
  938. }
  939. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  940. params: {
  941. page: this.followerCursor
  942. }
  943. })
  944. .then(res => {
  945. this.followers = res.data;
  946. this.followerCursor++;
  947. })
  948. if(res.data.length < 10) {
  949. this.followerMore = false;
  950. }
  951. this.$refs.followerModal.show();
  952. },
  953. followingLoadMore() {
  954. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  955. params: {
  956. page: this.followingCursor
  957. }
  958. })
  959. .then(res => {
  960. if(res.data.length > 0) {
  961. this.following.push(...res.data);
  962. this.followingCursor++;
  963. }
  964. if(res.data.length < 10) {
  965. this.followingMore = false;
  966. }
  967. });
  968. },
  969. followersLoadMore() {
  970. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  971. params: {
  972. page: this.followerCursor
  973. }
  974. })
  975. .then(res => {
  976. if(res.data.length > 0) {
  977. this.followers.push(...res.data);
  978. this.followerCursor++;
  979. }
  980. if(res.data.length < 10) {
  981. this.followerMore = false;
  982. }
  983. });
  984. },
  985. lightbox(src) {
  986. this.lightboxMedia = src;
  987. this.$refs.lightboxModal.show();
  988. },
  989. expLc(status) {
  990. if(this.config.ab.lc == false) {
  991. return true;
  992. }
  993. if(this.statusOwner(status) == true) {
  994. return true;
  995. }
  996. return false;
  997. },
  998. expRec() {
  999. if(this.config.ab.rec == false) {
  1000. return;
  1001. }
  1002. axios.get('/api/local/exp/rec')
  1003. .then(res => {
  1004. this.suggestions = res.data;
  1005. })
  1006. },
  1007. expRecFollow(id, index) {
  1008. if(this.config.ab.rec == false) {
  1009. return;
  1010. }
  1011. axios.post('/i/follow', {
  1012. item: id
  1013. }).then(res => {
  1014. this.suggestions.splice(index, 1);
  1015. })
  1016. },
  1017. followModalAction(id, index, type = 'following') {
  1018. axios.post('/i/follow', {
  1019. item: id
  1020. }).then(res => {
  1021. if(type == 'following') {
  1022. this.following.splice(index, 1);
  1023. }
  1024. })
  1025. },
  1026. owner(status) {
  1027. return this.profile.id === status.account.id;
  1028. },
  1029. admin() {
  1030. return this.profile.is_admin == true;
  1031. },
  1032. ownerOrAdmin(status) {
  1033. return this.owner(status) || this.admin();
  1034. },
  1035. hideSuggestions() {
  1036. localStorage.setItem('pf_metro_ui.exp.rec', false);
  1037. this.showSuggestions = false;
  1038. },
  1039. emojiReaction(status) {
  1040. let em = event.target.innerText;
  1041. if(this.replyText.length == 0) {
  1042. this.replyText = em + ' ';
  1043. $('textarea[name="comment"]').focus();
  1044. } else {
  1045. this.replyText += em + ' ';
  1046. $('textarea[name="comment"]').focus();
  1047. }
  1048. },
  1049. refreshSuggestions() {
  1050. let el = event.target.parentNode;
  1051. if(el.classList.contains('disabled') == true) {
  1052. return;
  1053. }
  1054. axios.get('/api/local/exp/rec', {
  1055. params: {
  1056. refresh: true
  1057. }
  1058. })
  1059. .then(res => {
  1060. this.suggestions = res.data;
  1061. if (el.classList) {
  1062. el.classList.add('disabled');
  1063. el.classList.add('text-light');
  1064. }
  1065. else {
  1066. el.className += ' ' + 'disabled text-light';
  1067. }
  1068. setTimeout(function() {
  1069. el.setAttribute('href', '#');
  1070. if (el.classList) {
  1071. el.classList.remove('disabled');
  1072. el.classList.remove('text-light');
  1073. }
  1074. else {
  1075. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1076. }
  1077. }, 10000);
  1078. });
  1079. }
  1080. }
  1081. }
  1082. </script>