Profile.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  1. <template>
  2. <div class="w-100 h-100">
  3. <div v-if="relationship && relationship.blocking && warning" class="bg-white pt-3 border-bottom">
  4. <div class="container">
  5. <p class="text-center font-weight-bold">You are blocking this account</p>
  6. <p class="text-center font-weight-bold">Click <a href="#" class="cursor-pointer" @click.prevent="warning = false;">here</a> to view profile</p>
  7. </div>
  8. </div>
  9. <div v-if="loading" style="height: 80vh;" class="d-flex justify-content-center align-items-center">
  10. <img src="/img/pixelfed-icon-grey.svg" class="">
  11. </div>
  12. <div v-if="!loading && !warning">
  13. <div v-if="profileLayout == 'metro'">
  14. <div class="bg-white py-5 border-bottom">
  15. <div class="container">
  16. <div class="row">
  17. <div class="col-12 col-md-4 d-flex">
  18. <div class="profile-avatar mx-md-auto">
  19. <div class="d-block d-md-none">
  20. <div class="row">
  21. <div class="col-5">
  22. <img class="rounded-circle box-shadow mr-2" :src="profile.avatar" width="77px" height="77px">
  23. <p v-if="sponsorList.patreon || sponsorList.liberapay || sponsorList.opencollective" class="text-center mt-1 mr-2">
  24. <button type="button" @click="showSponsorModal" class="btn btn-sm btn-outline-secondary font-weight-bold py-0">
  25. Donate
  26. </button>
  27. </p>
  28. </div>
  29. <div class="col-7 pl-2">
  30. <p class="align-middle">
  31. <span class="font-weight-ultralight h3 mb-0">{{profile.username}}</span>
  32. <span class="float-right mb-0" v-if="!loading && profile.id != user.id && user.hasOwnProperty('id')">
  33. <a class="fas fa-cog fa-lg text-muted text-decoration-none" href="#" @click.prevent="visitorMenu"></a>
  34. </span>
  35. </p>
  36. <p v-if="!loading && profile.id == user.id && user.hasOwnProperty('id')">
  37. <a class="btn btn-outline-dark py-0 px-4 mt-3" href="/settings/home">Edit Profile</a>
  38. </p>
  39. <div v-if="profile.id != user.id && user.hasOwnProperty('id')">
  40. <p class="mt-3 mb-0" v-if="relationship.following == true">
  41. <button type="button" class="btn btn-outline-dark font-weight-bold px-4 py-0" v-on:click="followProfile()" data-toggle="tooltip" title="Unfollow">Unfollow</button>
  42. </p>
  43. <p class="mt-3 mb-0" v-if="!relationship.following">
  44. <button type="button" class="btn btn-outline-dark font-weight-bold px-4 py-0" v-on:click="followProfile()" data-toggle="tooltip" title="Follow">Follow</button>
  45. </p>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="d-none d-md-block">
  51. <img class="rounded-circle box-shadow" :src="profile.avatar" width="172px" height="172px">
  52. <p v-if="sponsorList.patreon || sponsorList.liberapay || sponsorList.opencollective" class="text-center mt-3">
  53. <button type="button" @click="showSponsorModal" class="btn btn-outline-secondary font-weight-bold py-0">
  54. <i class="fas fa-heart text-danger"></i>
  55. Donate
  56. </button>
  57. </p>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="col-12 col-md-8 d-flex align-items-center">
  62. <div class="profile-details">
  63. <div class="d-none d-md-flex username-bar pb-2 align-items-center">
  64. <span class="font-weight-ultralight h3">{{profile.username}}</span>
  65. <span class="pl-4" v-if="profile.is_admin">
  66. <span class="btn btn-outline-secondary font-weight-bold py-0">ADMIN</span>
  67. </span>
  68. <span class="pl-4">
  69. <a :href="'/users/'+profile.username+'.atom'" class="fas fa-rss fa-lg text-muted text-decoration-none"></a>
  70. </span>
  71. <span class="pl-4" v-if="owner && user.hasOwnProperty('id')">
  72. <a class="fas fa-cog fa-lg text-muted text-decoration-none" href="/settings/home"></a>
  73. </span>
  74. <span class="pl-4" v-if="!owner && user.hasOwnProperty('id')">
  75. <a class="fas fa-cog fa-lg text-muted text-decoration-none" href="#" @click.prevent="visitorMenu"></a>
  76. </span>
  77. <span v-if="profile.id != user.id && user.hasOwnProperty('id')">
  78. <span class="pl-4" v-if="relationship.following == true">
  79. <button type="button" class="btn btn-outline-secondary font-weight-bold btn-sm" v-on:click="followProfile()" data-toggle="tooltip" title="Unfollow"><i class="fas fa-user-minus"></i></button>
  80. </span>
  81. <span class="pl-4" v-if="!relationship.following">
  82. <button type="button" class="btn btn-primary font-weight-bold btn-sm" v-on:click="followProfile()" data-toggle="tooltip" title="Follow"><i class="fas fa-user-plus"></i></button>
  83. </span>
  84. </span>
  85. </div>
  86. <div class="d-none d-md-inline-flex profile-stats pb-3 lead">
  87. <div class="font-weight-light pr-5">
  88. <a class="text-dark" :href="profile.url">
  89. <span class="font-weight-bold">{{profile.statuses_count}}</span>
  90. Posts
  91. </a>
  92. </div>
  93. <div v-if="profileSettings.followers.count" class="font-weight-light pr-5">
  94. <a class="text-dark cursor-pointer" v-on:click="followersModal()">
  95. <span class="font-weight-bold">{{profile.followers_count}}</span>
  96. Followers
  97. </a>
  98. </div>
  99. <div v-if="profileSettings.following.count" class="font-weight-light">
  100. <a class="text-dark cursor-pointer" v-on:click="followingModal()">
  101. <span class="font-weight-bold">{{profile.following_count}}</span>
  102. Following
  103. </a>
  104. </div>
  105. </div>
  106. <p class="lead mb-0 d-flex align-items-center pt-3">
  107. <span class="font-weight-bold pr-3">{{profile.display_name}}</span>
  108. </p>
  109. <div v-if="profile.note" class="mb-0 lead" v-html="profile.note"></div>
  110. <p v-if="profile.website" class=""><a :href="profile.website" class="font-weight-bold" rel="me external nofollow noopener" target="_blank">{{profile.website}}</a></p>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="d-block d-md-none bg-white my-0 py-2 border-bottom">
  117. <ul class="nav d-flex justify-content-center">
  118. <li class="nav-item">
  119. <div class="font-weight-light">
  120. <span class="text-dark text-center">
  121. <p class="font-weight-bold mb-0">{{profile.statuses_count}}</p>
  122. <p class="text-muted mb-0">Posts</p>
  123. </span>
  124. </div>
  125. </li>
  126. <li class="nav-item px-5">
  127. <div v-if="profileSettings.followers.count" class="font-weight-light">
  128. <a class="text-dark cursor-pointer text-center" v-on:click="followersModal()">
  129. <p class="font-weight-bold mb-0">{{profile.followers_count}}</p>
  130. <p class="text-muted mb-0">Followers</p>
  131. </a>
  132. </div>
  133. </li>
  134. <li class="nav-item">
  135. <div v-if="profileSettings.following.count" class="font-weight-light">
  136. <a class="text-dark cursor-pointer text-center" v-on:click="followingModal()">
  137. <p class="font-weight-bold mb-0">{{profile.following_count}}</p>
  138. <p class="text-muted mb-0">Following</p>
  139. </a>
  140. </div>
  141. </li>
  142. </ul>
  143. </div>
  144. <div class="bg-white">
  145. <ul class="nav nav-topbar d-flex justify-content-center border-0">
  146. <li class="nav-item">
  147. <a :class="this.mode == 'grid' ? 'nav-link font-weight-bold text-uppercase text-primary' : 'nav-link font-weight-bold text-uppercase'" href="#" v-on:click.prevent="switchMode('grid')"><i class="fas fa-th fa-lg"></i></a>
  148. </li>
  149. <li class="nav-item px-3">
  150. <a :class="this.mode == 'list' ? 'nav-link font-weight-bold text-uppercase text-primary' : 'nav-link font-weight-bold text-uppercase'" href="#" v-on:click.prevent="switchMode('list')"><i class="fas fa-th-list fa-lg"></i></a>
  151. </li>
  152. <li class="nav-item pr-3">
  153. <a :class="this.mode == 'collections' ? 'nav-link font-weight-bold text-uppercase text-primary' : 'nav-link font-weight-bold text-uppercase'" href="#" v-on:click.prevent="switchMode('collections')"><i class="fas fa-images fa-lg"></i></a>
  154. </li>
  155. <li class="nav-item" v-if="owner">
  156. <a :class="this.mode == 'bookmarks' ? 'nav-link font-weight-bold text-uppercase text-primary' : 'nav-link font-weight-bold text-uppercase'" href="#" v-on:click.prevent="switchMode('bookmarks')"><i class="fas fa-bookmark fa-lg"></i></a>
  157. </li>
  158. </ul>
  159. </div>
  160. <div class="container">
  161. <div class="profile-timeline mt-md-4">
  162. <div class="row" v-if="mode == 'grid'">
  163. <div class="col-4 p-0 p-sm-2 p-md-3 p-xs-1" v-for="(s, index) in timeline">
  164. <a class="card info-overlay card-md-border-0" :href="s.url">
  165. <div class="square">
  166. <span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
  167. <span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
  168. <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
  169. <div class="square-content" v-bind:style="previewBackground(s)">
  170. </div>
  171. <div class="info-overlay-text">
  172. <h5 class="text-white m-auto font-weight-bold">
  173. <span>
  174. <span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
  175. <span class="d-flex-inline">{{s.favourites_count}}</span>
  176. </span>
  177. <span>
  178. <span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span>
  179. <span class="d-flex-inline">{{s.reblogs_count}}</span>
  180. </span>
  181. </h5>
  182. </div>
  183. </div>
  184. </a>
  185. </div>
  186. </div>
  187. <div class="row" v-if="mode == 'list'">
  188. <div class="col-md-8 col-lg-8 offset-md-2 px-0 timeline">
  189. <div class="card status-card card-md-rounded-0 my-sm-2 my-md-3 my-lg-4" :data-status-id="status.id" v-for="(status, index) in timeline" :key="status.id">
  190. <div class="card-header d-inline-flex align-items-center bg-white">
  191. <img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
  192. <a class="username font-weight-bold pl-2 text-dark" v-bind:href="status.account.url">
  193. {{status.account.username}}
  194. </a>
  195. <div v-if="user.hasOwnProperty('id')" class="text-right" style="flex-grow:1;">
  196. <div class="dropdown">
  197. <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">
  198. <span class="fas fa-ellipsis-v fa-lg text-muted"></span>
  199. </button>
  200. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  201. <a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
  202. <span v-if="status.account.id != user.id">
  203. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  204. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
  205. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
  206. </span>
  207. <span v-if="status.account.id == user.id || user.is_admin == true">
  208. <a class="dropdown-item font-weight-bold" :href="editUrl(status)">Edit</a>
  209. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  210. </span>
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. <div class="postPresenterContainer">
  216. <div v-if="status.pf_type === 'photo'" class="w-100">
  217. <photo-presenter :status="status"></photo-presenter>
  218. </div>
  219. <div v-else-if="status.pf_type === 'video'" class="w-100">
  220. <video-presenter :status="status"></video-presenter>
  221. </div>
  222. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  223. <photo-album-presenter :status="status"></photo-album-presenter>
  224. </div>
  225. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  226. <video-album-presenter :status="status"></video-album-presenter>
  227. </div>
  228. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  229. <mixed-album-presenter :status="status"></mixed-album-presenter>
  230. </div>
  231. <div v-else class="w-100">
  232. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  233. </div>
  234. </div>
  235. <div class="card-body">
  236. <div class="reactions my-1" v-if="user.hasOwnProperty('id')">
  237. <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>
  238. <h3 class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
  239. <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>
  240. </div>
  241. <div class="likes font-weight-bold">
  242. <span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
  243. </div>
  244. <div class="caption">
  245. <p class="mb-2 read-more" style="overflow: hidden;">
  246. <span class="username font-weight-bold">
  247. <bdi><a class="text-dark" :href="status.account.url">{{status.account.username}}</a></bdi>
  248. </span>
  249. <span v-html="status.content"></span>
  250. </p>
  251. </div>
  252. <div class="comments">
  253. </div>
  254. <div class="timestamp pt-1">
  255. <p class="small text-uppercase mb-0">
  256. <a :href="status.url" class="text-muted">
  257. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  258. </a>
  259. </p>
  260. </div>
  261. </div>
  262. <div class="card-footer bg-white d-none">
  263. <form class="" v-on:submit.prevent="commentSubmit(status, $event)">
  264. <input type="hidden" name="item" value="">
  265. <input class="form-control status-reply-input" name="comment" placeholder="Add a comment…" autocomplete="off">
  266. </form>
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. <div v-if="['grid','list'].indexOf(mode) != -1 && timeline.length == 0">
  272. <div class="py-5 text-center text-muted">
  273. <p><i class="fas fa-camera-retro fa-2x"></i></p>
  274. <p class="h2 font-weight-light pt-3">No posts yet</p>
  275. </div>
  276. </div>
  277. <div v-if="timeline.length && ['grid','list'].indexOf(mode) != -1">
  278. <infinite-loading @infinite="infiniteTimeline">
  279. <div slot="no-more"></div>
  280. <div slot="no-results"></div>
  281. </infinite-loading>
  282. </div>
  283. <div class="row" v-if="mode == 'bookmarks'">
  284. <div v-if="bookmarks.length">
  285. <div class="col-4 p-0 p-sm-2 p-md-3 p-xs-1" v-for="(s, index) in bookmarks">
  286. <a class="card info-overlay card-md-border-0" :href="s.url">
  287. <div class="square">
  288. <span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
  289. <span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
  290. <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
  291. <div class="square-content" v-bind:style="previewBackground(s)">
  292. </div>
  293. <div class="info-overlay-text">
  294. <h5 class="text-white m-auto font-weight-bold">
  295. <span>
  296. <span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
  297. <span class="d-flex-inline">{{s.favourites_count}}</span>
  298. </span>
  299. <span>
  300. <span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span>
  301. <span class="d-flex-inline">{{s.reblogs_count}}</span>
  302. </span>
  303. </h5>
  304. </div>
  305. </div>
  306. </a>
  307. </div>
  308. </div>
  309. <div v-else class="col-12">
  310. <div class="py-5 text-center text-muted">
  311. <p><i class="fas fa-bookmark fa-2x"></i></p>
  312. <p class="h2 font-weight-light pt-3">You have no saved bookmarks</p>
  313. </div>
  314. </div>
  315. </div>
  316. <div class="col-12" v-if="mode == 'collections'">
  317. <div class="py-5 text-center text-muted">
  318. <p><i class="fas fa-images fa-2x"></i></p>
  319. <p class="h2 font-weight-light pt-3">You have no collections</p>
  320. </div>
  321. </div>
  322. </div>
  323. </div>
  324. </div>
  325. <div v-if="profileLayout == 'moment'">
  326. <div :class="momentBackground()" style="width:100%;min-height:274px;">
  327. </div>
  328. <div class="bg-white border-bottom">
  329. <div class="container">
  330. <div class="row">
  331. <div class="col-12 row mx-0">
  332. <div class="col-4"></div>
  333. <div class="col-4 text-center">
  334. <div class="d-block d-md-none">
  335. <img class="rounded-circle box-shadow" :src="profile.avatar" width="110px" height="110px" style="margin-top:-60px; border: 5px solid #fff">
  336. </div>
  337. <div class="d-none d-md-block">
  338. <img class="rounded-circle box-shadow" :src="profile.avatar" width="172px" height="172px" style="margin-top:-90px; border: 5px solid #fff">
  339. </div>
  340. </div>
  341. <div class="col-4 text-right mt-2">
  342. <span class="d-none d-md-inline-block pl-4">
  343. <a :href="'/users/'+profile.username+'.atom'" class="fas fa-rss fa-lg text-muted text-decoration-none"></a>
  344. </span>
  345. <span class="pl-md-4 pl-sm-2" v-if="owner">
  346. <a class="fas fa-cog fa-lg text-muted text-decoration-none" href="/settings/home"></a>
  347. </span>
  348. <span class="pl-md-4 pl-sm-2" v-if="profile.id != user.id && user.hasOwnProperty('id')">
  349. <a class="fas fa-cog fa-lg text-muted text-decoration-none" href="#" @click.prevent="visitorMenu"></a>
  350. </span>
  351. <span v-if="profile.id != user.id && user.hasOwnProperty('id')">
  352. <span class="pl-md-4 pl-sm-2" v-if="relationship.following == true">
  353. <button type="button" class="btn btn-outline-secondary font-weight-bold btn-sm" @click.prevent="followProfile()" data-toggle="tooltip" title="Unfollow">Unfollow</button>
  354. </span>
  355. <span class="pl-md-4 pl-sm-2" v-else>
  356. <button type="button" class="btn btn-primary font-weight-bold btn-sm" @click.prevent="followProfile()" data-toggle="tooltip" title="Follow">Follow</button>
  357. </span>
  358. </span>
  359. </div>
  360. </div>
  361. <div class="col-12 text-center">
  362. <div class="profile-details my-3">
  363. <p class="font-weight-ultralight h2 text-center">{{profile.username}}</p>
  364. <div v-if="profile.note" class="text-center text-muted p-3" v-html="profile.note"></div>
  365. <div class="pb-3 text-muted text-center">
  366. <a class="text-lighter" :href="profile.url">
  367. <span class="font-weight-bold">{{profile.statuses_count}}</span>
  368. Posts
  369. </a>
  370. <a v-if="profileSettings.followers.count" class="text-lighter cursor-pointer px-3" v-on:click="followersModal()">
  371. <span class="font-weight-bold">{{profile.followers_count}}</span>
  372. Followers
  373. </a>
  374. <a v-if="profileSettings.following.count" class="text-lighter cursor-pointer" v-on:click="followingModal()">
  375. <span class="font-weight-bold">{{profile.following_count}}</span>
  376. Following
  377. </a>
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. <div class="container-fluid">
  385. <div class="profile-timeline mt-md-4">
  386. <div class="card-columns" v-if="mode == 'grid'">
  387. <div class="p-sm-2 p-md-3" v-for="(s, index) in timeline">
  388. <a class="card info-overlay card-md-border-0" :href="s.url">
  389. <img :src="previewUrl(s)" class="img-fluid w-100">
  390. </a>
  391. </div>
  392. </div>
  393. <div v-if="timeline.length">
  394. <infinite-loading @infinite="infiniteTimeline">
  395. <div slot="no-more"></div>
  396. <div slot="no-results"></div>
  397. </infinite-loading>
  398. </div>
  399. </div>
  400. </div>
  401. </div>
  402. </div>
  403. <b-modal ref="followingModal"
  404. id="following-modal"
  405. hide-footer
  406. centered
  407. title="Following"
  408. body-class="list-group-flush p-0">
  409. <div class="list-group">
  410. <div class="list-group-item border-0" v-for="(user, index) in following" :key="'following_'+index">
  411. <div class="media">
  412. <a :href="user.url">
  413. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" loading="lazy">
  414. </a>
  415. <div class="media-body">
  416. <p class="mb-0" style="font-size: 14px">
  417. <a :href="user.url" class="font-weight-bold text-dark">
  418. {{user.username}}
  419. </a>
  420. </p>
  421. <p class="text-muted mb-0" style="font-size: 14px">
  422. {{user.display_name}}
  423. </p>
  424. </div>
  425. <div v-if="owner">
  426. <a class="btn btn-outline-secondary btn-sm" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Unfollow</a>
  427. </div>
  428. </div>
  429. </div>
  430. <div v-if="following.length == 0" class="list-group-item border-0">
  431. <div class="list-group-item border-0">
  432. <p class="p-3 text-center mb-0 lead">You are not following anyone.</p>
  433. </div>
  434. </div>
  435. <div v-if="followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  436. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  437. </div>
  438. </div>
  439. </b-modal>
  440. <b-modal ref="followerModal"
  441. id="follower-modal"
  442. hide-footer
  443. centered
  444. title="Followers"
  445. body-class="list-group-flush p-0">
  446. <div class="list-group">
  447. <div class="list-group-item border-0" v-for="(user, index) in followers" :key="'follower_'+index">
  448. <div class="media">
  449. <a :href="user.url">
  450. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" loading="lazy">
  451. </a>
  452. <div class="media-body">
  453. <p class="mb-0" style="font-size: 14px">
  454. <a :href="user.url" class="font-weight-bold text-dark">
  455. {{user.username}}
  456. </a>
  457. </p>
  458. <p class="text-muted mb-0" style="font-size: 14px">
  459. {{user.display_name}}
  460. </p>
  461. </div>
  462. </div>
  463. </div>
  464. <div v-if="followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  465. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  466. </div>
  467. </div>
  468. </b-modal>
  469. <b-modal ref="visitorContextMenu"
  470. id="visitor-context-menu"
  471. hide-footer
  472. hide-header
  473. centered
  474. size="sm"
  475. body-class="list-group-flush p-0">
  476. <div class="list-group" v-if="relationship">
  477. <div v-if="!owner && !relationship.following" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-primary" @click="followProfile">
  478. Follow
  479. </div>
  480. <div v-if="!owner && relationship.following" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded" @click="followProfile">
  481. Unfollow
  482. </div>
  483. <div v-if="!owner && !relationship.muting" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded" @click="muteProfile">
  484. Mute
  485. </div>
  486. <div v-if="!owner && relationship.muting" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded" @click="unmuteProfile">
  487. Unmute
  488. </div>
  489. <div v-if="!owner" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-danger" @click="reportProfile">
  490. Report User
  491. </div>
  492. <div v-if="!owner && !relationship.blocking" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-danger" @click="blockProfile">
  493. Block
  494. </div>
  495. <div v-if="!owner && relationship.blocking" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-danger" @click="unblockProfile">
  496. Unblock
  497. </div>
  498. <div class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-muted" @click="$refs.visitorContextMenu.hide()">
  499. Close
  500. </div>
  501. </div>
  502. </b-modal>
  503. <b-modal ref="sponsorModal"
  504. id="sponsor-modal"
  505. hide-footer
  506. :title="'Sponsor ' + profileUsername"
  507. centered
  508. size="md"
  509. body-class="px-5">
  510. <div>
  511. <p class="font-weight-bold">External Links</p>
  512. <p v-if="sponsorList.patreon" class="pt-2">
  513. <a :href="'https://' + sponsorList.patreon" rel="nofollow" class="font-weight-bold">{{sponsorList.patreon}}</a>
  514. </p>
  515. <p v-if="sponsorList.liberapay" class="pt-2">
  516. <a :href="'https://' + sponsorList.liberapay" rel="nofollow" class="font-weight-bold">{{sponsorList.liberapay}}</a>
  517. </p>
  518. <p v-if="sponsorList.opencollective" class="pt-2">
  519. <a :href="'https://' + sponsorList.opencollective" rel="nofollow" class="font-weight-bold">{{sponsorList.opencollective}}</a>
  520. </p>
  521. </div>
  522. </b-modal>
  523. </div>
  524. </template>
  525. <style type="text/css" scoped>
  526. .o-square {
  527. max-width: 320px;
  528. }
  529. .o-portrait {
  530. max-width: 320px;
  531. }
  532. .o-landscape {
  533. max-width: 320px;
  534. }
  535. .post-icon {
  536. color: #fff;
  537. position:relative;
  538. margin-top: 10px;
  539. z-index: 9;
  540. opacity: 0.6;
  541. text-shadow: 3px 3px 16px #272634;
  542. }
  543. </style>
  544. <script type="text/javascript">
  545. export default {
  546. props: [
  547. 'profile-id',
  548. 'profile-layout',
  549. 'profile-settings',
  550. 'profile-username'
  551. ],
  552. data() {
  553. return {
  554. ids: [],
  555. profile: {},
  556. user: {},
  557. timeline: [],
  558. timelinePage: 2,
  559. min_id: 0,
  560. max_id: 0,
  561. loading: true,
  562. owner: false,
  563. mode: 'grid',
  564. modes: ['grid', 'list', 'masonry', 'bookmarks'],
  565. modalStatus: false,
  566. relationship: {},
  567. followers: [],
  568. followerCursor: 1,
  569. followerMore: true,
  570. following: [],
  571. followingCursor: 1,
  572. followingMore: true,
  573. warning: false,
  574. sponsorList: [],
  575. bookmarks: [],
  576. bookmarksPage: 2,
  577. collections: [],
  578. collectionsPage: 2
  579. }
  580. },
  581. beforeMount() {
  582. this.fetchRelationships();
  583. this.fetchProfile();
  584. if(window.outerWidth < 576 && window.history.length > 2) {
  585. $('nav.navbar').hide();
  586. $('body').prepend('<div class="bg-white p-3 border-bottom"><div class="d-flex justify-content-between align-items-center"><div onclick="window.history.back();"><i class="fas fa-chevron-left fa-lg"></i></div><div class="font-weight-bold">' + this.profileUsername + '</div><div><i class="fas fa-chevron-right text-white fa-lg"></i></div></div></div>');
  587. }
  588. let u = new URLSearchParams(window.location.search);
  589. if(u.has('ui') && u.get('ui') == 'moment' && this.profileLayout != 'moment') {
  590. this.profileLayout = 'moment';
  591. }
  592. if(u.has('ui') && u.get('ui') == 'metro' && this.profileLayout != 'metro') {
  593. this.profileLayout = 'metro';
  594. }
  595. },
  596. mounted() {
  597. },
  598. updated() {
  599. },
  600. methods: {
  601. fetchProfile() {
  602. axios.get('/api/v1/accounts/' + this.profileId).then(res => {
  603. this.profile = res.data;
  604. });
  605. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  606. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  607. this.user = res.data;
  608. });
  609. }
  610. let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses';
  611. axios.get(apiUrl, {
  612. params: {
  613. only_media: true,
  614. min_id: 1,
  615. }
  616. })
  617. .then(res => {
  618. let data = res.data.filter(status => status.media_attachments.length > 0);
  619. let ids = data.map(status => status.id);
  620. this.ids = ids;
  621. this.min_id = Math.max(...ids);
  622. this.max_id = Math.min(...ids);
  623. this.modalStatus = _.first(res.data);
  624. this.timeline = data;
  625. this.ownerCheck();
  626. this.loading = false;
  627. this.loadSponsor();
  628. }).catch(err => {
  629. swal(
  630. 'Oops, something went wrong',
  631. 'Please release the page.',
  632. 'error'
  633. );
  634. });
  635. },
  636. ownerCheck() {
  637. this.owner = this.profile.id === this.user.id;
  638. },
  639. infiniteTimeline($state) {
  640. if(this.loading || this.timeline.length < 9) {
  641. $state.complete();
  642. return;
  643. }
  644. let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses';
  645. axios.get(apiUrl, {
  646. params: {
  647. only_media: true,
  648. max_id: this.max_id
  649. },
  650. }).then(res => {
  651. if (res.data.length && this.loading == false) {
  652. let data = res.data;
  653. let self = this;
  654. data.forEach(d => {
  655. if(self.ids.indexOf(d.id) == -1) {
  656. self.timeline.push(d);
  657. self.ids.push(d.id);
  658. }
  659. });
  660. this.min_id = Math.max(...this.ids);
  661. this.max_id = Math.min(...this.ids);
  662. $state.loaded();
  663. this.loading = false;
  664. } else {
  665. $state.complete();
  666. }
  667. });
  668. },
  669. previewUrl(status) {
  670. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  671. },
  672. previewBackground(status) {
  673. let preview = this.previewUrl(status);
  674. return 'background-image: url(' + preview + ');';
  675. },
  676. switchMode(mode) {
  677. this.mode = _.indexOf(this.modes, mode) ? mode : 'grid';
  678. if(this.mode == 'bookmarks' && this.bookmarks.length == 0) {
  679. axios.get('/api/local/bookmarks')
  680. .then(res => {
  681. this.bookmarks = res.data
  682. });
  683. }
  684. },
  685. reportProfile() {
  686. let id = this.profile.id;
  687. window.location.href = '/i/report?type=user&id=' + id;
  688. },
  689. reportUrl(status) {
  690. let type = status.in_reply_to ? 'comment' : 'post';
  691. let id = status.id;
  692. return '/i/report?type=' + type + '&id=' + id;
  693. },
  694. commentFocus(status, $event) {
  695. let el = event.target;
  696. let card = el.parentElement.parentElement.parentElement;
  697. let comments = card.getElementsByClassName('comments')[0];
  698. if(comments.children.length == 0) {
  699. comments.classList.add('mb-2');
  700. this.fetchStatusComments(status, card);
  701. }
  702. let footer = card.querySelectorAll('.card-footer')[0];
  703. let input = card.querySelectorAll('.status-reply-input')[0];
  704. if(footer.classList.contains('d-none') == true) {
  705. footer.classList.remove('d-none');
  706. input.focus();
  707. } else {
  708. footer.classList.add('d-none');
  709. input.blur();
  710. }
  711. },
  712. likeStatus(status, $event) {
  713. if($('body').hasClass('loggedIn') == false) {
  714. return;
  715. }
  716. axios.post('/i/like', {
  717. item: status.id
  718. }).then(res => {
  719. status.favourites_count = res.data.count;
  720. if(status.favourited == true) {
  721. status.favourited = false;
  722. } else {
  723. status.favourited = true;
  724. }
  725. }).catch(err => {
  726. swal('Error', 'Something went wrong, please try again later.', 'error');
  727. });
  728. },
  729. shareStatus(status, $event) {
  730. if($('body').hasClass('loggedIn') == false) {
  731. return;
  732. }
  733. axios.post('/i/share', {
  734. item: status.id
  735. }).then(res => {
  736. status.reblogs_count = res.data.count;
  737. if(status.reblogged == true) {
  738. status.reblogged = false;
  739. } else {
  740. status.reblogged = true;
  741. }
  742. }).catch(err => {
  743. swal('Error', 'Something went wrong, please try again later.', 'error');
  744. });
  745. },
  746. timestampFormat(timestamp) {
  747. let ts = new Date(timestamp);
  748. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  749. },
  750. editUrl(status) {
  751. return status.url + '/edit';
  752. },
  753. redirect(url) {
  754. window.location.href = url;
  755. return;
  756. },
  757. replyUrl(status) {
  758. let username = this.profile.username;
  759. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  760. return '/p/' + username + '/' + id;
  761. },
  762. mentionUrl(status) {
  763. let username = status.account.username;
  764. let id = status.id;
  765. return '/p/' + username + '/' + id;
  766. },
  767. statusOwner(status) {
  768. let sid = status.account.id;
  769. let uid = this.profile.id;
  770. if(sid == uid) {
  771. return true;
  772. } else {
  773. return false;
  774. }
  775. },
  776. fetchStatusComments(status, card) {
  777. axios.get('/api/v2/status/'+status.id+'/replies')
  778. .then(res => {
  779. let comments = card.querySelectorAll('.comments')[0];
  780. let data = res.data;
  781. data.forEach(function(i, k) {
  782. let username = document.createElement('a');
  783. username.classList.add('font-weight-bold');
  784. username.classList.add('text-dark');
  785. username.classList.add('mr-2');
  786. username.setAttribute('href', i.account.url);
  787. username.textContent = i.account.username;
  788. let text = document.createElement('span');
  789. text.innerHTML = i.content;
  790. let comment = document.createElement('p');
  791. comment.classList.add('read-more');
  792. comment.classList.add('mb-0');
  793. comment.appendChild(username);
  794. comment.appendChild(text);
  795. comments.appendChild(comment);
  796. });
  797. }).catch(err => {
  798. })
  799. },
  800. fetchRelationships() {
  801. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  802. return;
  803. }
  804. axios.get('/api/v1/accounts/relationships', {
  805. params: {
  806. 'id[]': this.profileId
  807. }
  808. }).then(res => {
  809. if(res.data.length) {
  810. this.relationship = res.data[0];
  811. if(res.data[0].blocking == true) {
  812. this.warning = true;
  813. }
  814. }
  815. });
  816. },
  817. muteProfile(status = null) {
  818. if($('body').hasClass('loggedIn') == false) {
  819. return;
  820. }
  821. let id = this.profileId;
  822. axios.post('/i/mute', {
  823. type: 'user',
  824. item: id
  825. }).then(res => {
  826. this.fetchRelationships();
  827. this.$refs.visitorContextMenu.hide();
  828. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  829. }).catch(err => {
  830. swal('Error', 'Something went wrong. Please try again later.', 'error');
  831. });
  832. },
  833. unmuteProfile(status = null) {
  834. if($('body').hasClass('loggedIn') == false) {
  835. return;
  836. }
  837. let id = this.profileId;
  838. axios.post('/i/unmute', {
  839. type: 'user',
  840. item: id
  841. }).then(res => {
  842. this.fetchRelationships();
  843. this.$refs.visitorContextMenu.hide();
  844. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  845. }).catch(err => {
  846. swal('Error', 'Something went wrong. Please try again later.', 'error');
  847. });
  848. },
  849. blockProfile(status = null) {
  850. if($('body').hasClass('loggedIn') == false) {
  851. return;
  852. }
  853. let id = this.profileId;
  854. axios.post('/i/block', {
  855. type: 'user',
  856. item: id
  857. }).then(res => {
  858. this.warning = true;
  859. this.fetchRelationships();
  860. this.$refs.visitorContextMenu.hide();
  861. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  862. }).catch(err => {
  863. swal('Error', 'Something went wrong. Please try again later.', 'error');
  864. });
  865. },
  866. unblockProfile(status = null) {
  867. if($('body').hasClass('loggedIn') == false) {
  868. return;
  869. }
  870. let id = this.profileId;
  871. axios.post('/i/unblock', {
  872. type: 'user',
  873. item: id
  874. }).then(res => {
  875. this.fetchRelationships();
  876. this.$refs.visitorContextMenu.hide();
  877. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  878. }).catch(err => {
  879. swal('Error', 'Something went wrong. Please try again later.', 'error');
  880. });
  881. },
  882. deletePost(status, index) {
  883. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  884. return;
  885. }
  886. axios.post('/i/delete', {
  887. type: 'status',
  888. item: status.id
  889. }).then(res => {
  890. this.timeline.splice(index,1);
  891. swal('Success', 'You have successfully deleted this post', 'success');
  892. }).catch(err => {
  893. swal('Error', 'Something went wrong. Please try again later.', 'error');
  894. });
  895. },
  896. commentSubmit(status, $event) {
  897. if($('body').hasClass('loggedIn') == false) {
  898. return;
  899. }
  900. let id = status.id;
  901. let form = $event.target;
  902. let input = $(form).find('input[name="comment"]');
  903. let comment = input.val();
  904. let comments = form.parentElement.parentElement.getElementsByClassName('comments')[0];
  905. axios.post('/i/comment', {
  906. item: id,
  907. comment: comment
  908. }).then(res => {
  909. input.val('');
  910. input.blur();
  911. let username = document.createElement('a');
  912. username.classList.add('font-weight-bold');
  913. username.classList.add('text-dark');
  914. username.classList.add('mr-2');
  915. username.setAttribute('href', this.user.url);
  916. username.textContent = this.user.username;
  917. let text = document.createElement('span');
  918. text.innerHTML = comment;
  919. let wrapper = document.createElement('p');
  920. wrapper.classList.add('read-more');
  921. wrapper.classList.add('mb-0');
  922. wrapper.appendChild(username);
  923. wrapper.appendChild(text);
  924. comments.insertBefore(wrapper, comments.firstChild);
  925. });
  926. },
  927. statusModal(status) {
  928. this.modalStatus = status;
  929. this.$refs.statusModalRef.show();
  930. },
  931. masonryOrientation(status) {
  932. let o = status.media_attachments[0].orientation;
  933. if(!o) {
  934. o = 'square';
  935. }
  936. return o;
  937. },
  938. followProfile() {
  939. if($('body').hasClass('loggedIn') == false) {
  940. return;
  941. }
  942. axios.post('/i/follow', {
  943. item: this.profileId
  944. }).then(res => {
  945. this.$refs.visitorContextMenu.hide();
  946. if(this.relationship.following) {
  947. this.profile.followers_count--;
  948. if(this.profile.locked == true) {
  949. window.location.href = '/';
  950. }
  951. } else {
  952. this.profile.followers_count++;
  953. }
  954. this.relationship.following = !this.relationship.following;
  955. }).catch(err => {
  956. if(err.response.data.message) {
  957. swal('Error', err.response.data.message, 'error');
  958. }
  959. });
  960. },
  961. followingModal() {
  962. if($('body').hasClass('loggedIn') == false) {
  963. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  964. return;
  965. }
  966. if(this.profileSettings.following.list == false) {
  967. return;
  968. }
  969. if(this.following.length > 0) {
  970. this.$refs.followingModal.show();
  971. return;
  972. }
  973. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  974. params: {
  975. page: this.followingCursor
  976. }
  977. })
  978. .then(res => {
  979. this.following = res.data;
  980. this.followingCursor++;
  981. if(res.data.length < 10) {
  982. this.followingMore = false;
  983. }
  984. });
  985. this.$refs.followingModal.show();
  986. },
  987. followersModal() {
  988. if($('body').hasClass('loggedIn') == false) {
  989. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  990. return;
  991. }
  992. if(this.profileSettings.followers.list == false) {
  993. return;
  994. }
  995. if(this.followers.length > 0) {
  996. this.$refs.followerModal.show();
  997. return;
  998. }
  999. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  1000. params: {
  1001. page: this.followerCursor
  1002. }
  1003. })
  1004. .then(res => {
  1005. this.followers = res.data;
  1006. this.followerCursor++;
  1007. if(res.data.length < 10) {
  1008. this.followerMore = false;
  1009. }
  1010. })
  1011. this.$refs.followerModal.show();
  1012. },
  1013. followingLoadMore() {
  1014. if($('body').hasClass('loggedIn') == false) {
  1015. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  1016. return;
  1017. }
  1018. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  1019. params: {
  1020. page: this.followingCursor
  1021. }
  1022. })
  1023. .then(res => {
  1024. if(res.data.length > 0) {
  1025. this.following.push(...res.data);
  1026. this.followingCursor++;
  1027. }
  1028. if(res.data.length < 10) {
  1029. this.followingMore = false;
  1030. }
  1031. });
  1032. },
  1033. followersLoadMore() {
  1034. if($('body').hasClass('loggedIn') == false) {
  1035. return;
  1036. }
  1037. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  1038. params: {
  1039. page: this.followerCursor
  1040. }
  1041. })
  1042. .then(res => {
  1043. if(res.data.length > 0) {
  1044. this.followers.push(...res.data);
  1045. this.followerCursor++;
  1046. }
  1047. if(res.data.length < 10) {
  1048. this.followerMore = false;
  1049. }
  1050. });
  1051. },
  1052. visitorMenu() {
  1053. if($('body').hasClass('loggedIn') == false) {
  1054. return;
  1055. }
  1056. this.$refs.visitorContextMenu.show();
  1057. },
  1058. followModalAction(id, index, type = 'following') {
  1059. axios.post('/i/follow', {
  1060. item: id
  1061. }).then(res => {
  1062. if(type == 'following') {
  1063. this.following.splice(index, 1);
  1064. this.profile.following_count--;
  1065. }
  1066. }).catch(err => {
  1067. if(err.response.data.message) {
  1068. swal('Error', err.response.data.message, 'error');
  1069. }
  1070. });
  1071. },
  1072. momentBackground() {
  1073. let c = 'w-100 h-100 mt-n3 ';
  1074. if(this.profile.header_bg) {
  1075. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1076. } else {
  1077. c += 'bg-pixelfed';
  1078. }
  1079. return c;
  1080. },
  1081. loadSponsor() {
  1082. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1083. .then(res => {
  1084. this.sponsorList = res.data;
  1085. });
  1086. },
  1087. showSponsorModal() {
  1088. this.$refs.sponsorModal.show();
  1089. }
  1090. }
  1091. }
  1092. </script>