Profile.vue 35 KB

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