Profile.vue 35 KB

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