Profile.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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">{{formatCount(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">{{formatCount(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">{{formatCount(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">{{formatCount(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">{{formatCount(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">{{formatCount(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="statusUrl(s)">
  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">{{formatCount(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">{{formatCount(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">{{formatCount(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="statusUrl(s)">
  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. export default {
  506. props: [
  507. 'profile-id',
  508. 'profile-layout',
  509. 'profile-settings',
  510. 'profile-username'
  511. ],
  512. data() {
  513. return {
  514. ids: [],
  515. profile: {},
  516. user: false,
  517. timeline: [],
  518. timelinePage: 2,
  519. min_id: 0,
  520. max_id: 0,
  521. loading: true,
  522. owner: false,
  523. layout: this.profileLayout,
  524. mode: 'grid',
  525. modes: ['grid', 'collections', 'bookmarks'],
  526. modalStatus: false,
  527. relationship: {},
  528. followers: [],
  529. followerCursor: 1,
  530. followerMore: true,
  531. following: [],
  532. followingCursor: 1,
  533. followingMore: true,
  534. warning: false,
  535. sponsorList: [],
  536. bookmarks: [],
  537. bookmarksPage: 2,
  538. collections: [],
  539. collectionsPage: 2,
  540. isMobile: false
  541. }
  542. },
  543. beforeMount() {
  544. if(window.outerWidth < 576) {
  545. $('nav.navbar').hide();
  546. this.isMobile = true;
  547. }
  548. this.fetchRelationships();
  549. this.fetchProfile();
  550. let u = new URLSearchParams(window.location.search);
  551. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  552. Vue.use(VueMasonry);
  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. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  576. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  577. this.user = res.data;
  578. });
  579. }
  580. },
  581. updated() {
  582. $('[data-toggle="tooltip"]').tooltip();
  583. },
  584. methods: {
  585. fetchProfile() {
  586. axios.get('/api/pixelfed/v1/accounts/' + this.profileId).then(res => {
  587. this.profile = res.data;
  588. }).then(res => {
  589. this.fetchPosts();
  590. });
  591. },
  592. fetchPosts() {
  593. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  594. axios.get(apiUrl, {
  595. params: {
  596. only_media: true,
  597. min_id: 1,
  598. }
  599. })
  600. .then(res => {
  601. let data = res.data.filter(status => status.media_attachments.length > 0);
  602. let ids = data.map(status => status.id);
  603. this.ids = ids;
  604. this.min_id = Math.max(...ids);
  605. this.max_id = Math.min(...ids);
  606. this.modalStatus = _.first(res.data);
  607. this.timeline = data;
  608. this.ownerCheck();
  609. this.loading = false;
  610. //this.loadSponsor();
  611. }).catch(err => {
  612. swal('Oops, something went wrong',
  613. 'Please release the page.',
  614. 'error');
  615. });
  616. },
  617. ownerCheck() {
  618. if($('body').hasClass('loggedIn') == false) {
  619. this.owner = false;
  620. return;
  621. }
  622. this.owner = this.profile.id === this.user.id;
  623. },
  624. infiniteTimeline($state) {
  625. if(this.loading || this.timeline.length < 9) {
  626. $state.complete();
  627. return;
  628. }
  629. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  630. axios.get(apiUrl, {
  631. params: {
  632. only_media: true,
  633. max_id: this.max_id
  634. },
  635. }).then(res => {
  636. if (res.data.length && this.loading == false) {
  637. let data = res.data;
  638. let self = this;
  639. data.forEach(d => {
  640. if(self.ids.indexOf(d.id) == -1) {
  641. self.timeline.push(d);
  642. self.ids.push(d.id);
  643. }
  644. });
  645. this.min_id = Math.max(...this.ids);
  646. this.max_id = Math.min(...this.ids);
  647. $state.loaded();
  648. this.loading = false;
  649. } else {
  650. $state.complete();
  651. }
  652. });
  653. },
  654. previewUrl(status) {
  655. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  656. },
  657. previewBackground(status) {
  658. let preview = this.previewUrl(status);
  659. return 'background-image: url(' + preview + ');';
  660. },
  661. switchMode(mode) {
  662. this.mode = _.indexOf(this.modes, mode) ? mode : 'grid';
  663. if(this.mode == 'bookmarks' && this.bookmarks.length == 0) {
  664. axios.get('/api/local/bookmarks')
  665. .then(res => {
  666. this.bookmarks = res.data
  667. });
  668. }
  669. if(this.mode == 'collections' && this.collections.length == 0) {
  670. axios.get('/api/local/profile/collections/' + this.profileId)
  671. .then(res => {
  672. this.collections = res.data
  673. });
  674. }
  675. },
  676. reportProfile() {
  677. let id = this.profile.id;
  678. window.location.href = '/i/report?type=user&id=' + id;
  679. },
  680. reportUrl(status) {
  681. let type = status.in_reply_to ? 'comment' : 'post';
  682. let id = status.id;
  683. return '/i/report?type=' + type + '&id=' + id;
  684. },
  685. commentFocus(status, $event) {
  686. let el = event.target;
  687. let card = el.parentElement.parentElement.parentElement;
  688. let comments = card.getElementsByClassName('comments')[0];
  689. if(comments.children.length == 0) {
  690. comments.classList.add('mb-2');
  691. this.fetchStatusComments(status, card);
  692. }
  693. let footer = card.querySelectorAll('.card-footer')[0];
  694. let input = card.querySelectorAll('.status-reply-input')[0];
  695. if(footer.classList.contains('d-none') == true) {
  696. footer.classList.remove('d-none');
  697. input.focus();
  698. } else {
  699. footer.classList.add('d-none');
  700. input.blur();
  701. }
  702. },
  703. likeStatus(status, $event) {
  704. if($('body').hasClass('loggedIn') == false) {
  705. return;
  706. }
  707. axios.post('/i/like', {
  708. item: status.id
  709. }).then(res => {
  710. status.favourites_count = res.data.count;
  711. if(status.favourited == true) {
  712. status.favourited = false;
  713. } else {
  714. status.favourited = true;
  715. }
  716. }).catch(err => {
  717. swal('Error', 'Something went wrong, please try again later.', 'error');
  718. });
  719. },
  720. shareStatus(status, $event) {
  721. if($('body').hasClass('loggedIn') == false) {
  722. return;
  723. }
  724. axios.post('/i/share', {
  725. item: status.id
  726. }).then(res => {
  727. status.reblogs_count = res.data.count;
  728. if(status.reblogged == true) {
  729. status.reblogged = false;
  730. } else {
  731. status.reblogged = true;
  732. }
  733. }).catch(err => {
  734. swal('Error', 'Something went wrong, please try again later.', 'error');
  735. });
  736. },
  737. timestampFormat(timestamp) {
  738. let ts = new Date(timestamp);
  739. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  740. },
  741. editUrl(status) {
  742. return status.url + '/edit';
  743. },
  744. redirect(url) {
  745. window.location.href = url;
  746. return;
  747. },
  748. replyUrl(status) {
  749. let username = this.profile.username;
  750. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  751. return '/p/' + username + '/' + id;
  752. },
  753. mentionUrl(status) {
  754. let username = status.account.username;
  755. let id = status.id;
  756. return '/p/' + username + '/' + id;
  757. },
  758. statusOwner(status) {
  759. let sid = status.account.id;
  760. let uid = this.profile.id;
  761. if(sid == uid) {
  762. return true;
  763. } else {
  764. return false;
  765. }
  766. },
  767. fetchRelationships() {
  768. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  769. return;
  770. }
  771. axios.get('/api/pixelfed/v1/accounts/relationships', {
  772. params: {
  773. 'id[]': this.profileId
  774. }
  775. }).then(res => {
  776. if(res.data.length) {
  777. this.relationship = res.data[0];
  778. if(res.data[0].blocking == true) {
  779. this.warning = true;
  780. }
  781. }
  782. });
  783. },
  784. muteProfile(status = null) {
  785. if($('body').hasClass('loggedIn') == false) {
  786. return;
  787. }
  788. let id = this.profileId;
  789. axios.post('/i/mute', {
  790. type: 'user',
  791. item: id
  792. }).then(res => {
  793. this.fetchRelationships();
  794. this.$refs.visitorContextMenu.hide();
  795. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  796. }).catch(err => {
  797. swal('Error', 'Something went wrong. Please try again later.', 'error');
  798. });
  799. },
  800. unmuteProfile(status = null) {
  801. if($('body').hasClass('loggedIn') == false) {
  802. return;
  803. }
  804. let id = this.profileId;
  805. axios.post('/i/unmute', {
  806. type: 'user',
  807. item: id
  808. }).then(res => {
  809. this.fetchRelationships();
  810. this.$refs.visitorContextMenu.hide();
  811. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  812. }).catch(err => {
  813. swal('Error', 'Something went wrong. Please try again later.', 'error');
  814. });
  815. },
  816. blockProfile(status = null) {
  817. if($('body').hasClass('loggedIn') == false) {
  818. return;
  819. }
  820. let id = this.profileId;
  821. axios.post('/i/block', {
  822. type: 'user',
  823. item: id
  824. }).then(res => {
  825. this.warning = true;
  826. this.fetchRelationships();
  827. this.$refs.visitorContextMenu.hide();
  828. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  829. }).catch(err => {
  830. swal('Error', 'Something went wrong. Please try again later.', 'error');
  831. });
  832. },
  833. unblockProfile(status = null) {
  834. if($('body').hasClass('loggedIn') == false) {
  835. return;
  836. }
  837. let id = this.profileId;
  838. axios.post('/i/unblock', {
  839. type: 'user',
  840. item: id
  841. }).then(res => {
  842. this.fetchRelationships();
  843. this.$refs.visitorContextMenu.hide();
  844. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  845. }).catch(err => {
  846. swal('Error', 'Something went wrong. Please try again later.', 'error');
  847. });
  848. },
  849. deletePost(status, index) {
  850. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  851. return;
  852. }
  853. axios.post('/i/delete', {
  854. type: 'status',
  855. item: status.id
  856. }).then(res => {
  857. this.timeline.splice(index,1);
  858. swal('Success', 'You have successfully deleted this post', 'success');
  859. }).catch(err => {
  860. swal('Error', 'Something went wrong. Please try again later.', 'error');
  861. });
  862. },
  863. followProfile() {
  864. if($('body').hasClass('loggedIn') == false) {
  865. return;
  866. }
  867. axios.post('/i/follow', {
  868. item: this.profileId
  869. }).then(res => {
  870. this.$refs.visitorContextMenu.hide();
  871. if(this.relationship.following) {
  872. this.profile.followers_count--;
  873. if(this.profile.locked == true) {
  874. window.location.href = '/';
  875. }
  876. } else {
  877. this.profile.followers_count++;
  878. }
  879. this.relationship.following = !this.relationship.following;
  880. }).catch(err => {
  881. if(err.response.data.message) {
  882. swal('Error', err.response.data.message, 'error');
  883. }
  884. });
  885. },
  886. followingModal() {
  887. if($('body').hasClass('loggedIn') == false) {
  888. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  889. return;
  890. }
  891. if(this.profileSettings.following.list == false) {
  892. return;
  893. }
  894. if(this.followingCursor > 1) {
  895. this.$refs.followingModal.show();
  896. return;
  897. } else {
  898. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/following', {
  899. params: {
  900. page: this.followingCursor
  901. }
  902. })
  903. .then(res => {
  904. this.following = res.data;
  905. this.followingCursor++;
  906. if(res.data.length < 10) {
  907. this.followingMore = false;
  908. }
  909. });
  910. this.$refs.followingModal.show();
  911. return;
  912. }
  913. },
  914. followersModal() {
  915. if($('body').hasClass('loggedIn') == false) {
  916. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  917. return;
  918. }
  919. if(this.profileSettings.followers.list == false) {
  920. return;
  921. }
  922. if(this.followerCursor > 1) {
  923. this.$refs.followerModal.show();
  924. return;
  925. } else {
  926. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/followers', {
  927. params: {
  928. page: this.followerCursor
  929. }
  930. })
  931. .then(res => {
  932. this.followers.push(...res.data);
  933. this.followerCursor++;
  934. if(res.data.length < 10) {
  935. this.followerMore = false;
  936. }
  937. })
  938. this.$refs.followerModal.show();
  939. return;
  940. }
  941. },
  942. followingLoadMore() {
  943. if($('body').hasClass('loggedIn') == false) {
  944. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  945. return;
  946. }
  947. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  948. params: {
  949. page: this.followingCursor
  950. }
  951. })
  952. .then(res => {
  953. if(res.data.length > 0) {
  954. this.following.push(...res.data);
  955. this.followingCursor++;
  956. }
  957. if(res.data.length < 10) {
  958. this.followingMore = false;
  959. }
  960. });
  961. },
  962. followersLoadMore() {
  963. if($('body').hasClass('loggedIn') == false) {
  964. return;
  965. }
  966. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  967. params: {
  968. page: this.followerCursor
  969. }
  970. })
  971. .then(res => {
  972. if(res.data.length > 0) {
  973. this.followers.push(...res.data);
  974. this.followerCursor++;
  975. }
  976. if(res.data.length < 10) {
  977. this.followerMore = false;
  978. }
  979. });
  980. },
  981. visitorMenu() {
  982. this.$refs.visitorContextMenu.show();
  983. },
  984. followModalAction(id, index, type = 'following') {
  985. axios.post('/i/follow', {
  986. item: id
  987. }).then(res => {
  988. if(type == 'following') {
  989. this.following.splice(index, 1);
  990. this.profile.following_count--;
  991. }
  992. }).catch(err => {
  993. if(err.response.data.message) {
  994. swal('Error', err.response.data.message, 'error');
  995. }
  996. });
  997. },
  998. momentBackground() {
  999. let c = 'w-100 h-100 mt-n3 ';
  1000. if(this.profile.header_bg) {
  1001. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1002. } else {
  1003. c += 'bg-pixelfed';
  1004. }
  1005. return c;
  1006. },
  1007. loadSponsor() {
  1008. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1009. .then(res => {
  1010. this.sponsorList = res.data;
  1011. });
  1012. },
  1013. showSponsorModal() {
  1014. this.$refs.sponsorModal.show();
  1015. },
  1016. goBack() {
  1017. if(window.history.length > 2) {
  1018. window.history.back();
  1019. return;
  1020. } else {
  1021. window.location.href = '/';
  1022. return;
  1023. }
  1024. },
  1025. copyProfileLink() {
  1026. navigator.clipboard.writeText(window.location.href);
  1027. this.$refs.visitorContextMenu.hide();
  1028. },
  1029. formatCount(count) {
  1030. return App.util.format.count(count);
  1031. },
  1032. statusUrl(status) {
  1033. if(status.local == true) {
  1034. return status.url;
  1035. }
  1036. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1037. },
  1038. profileUrl(status) {
  1039. if(status.local == true) {
  1040. return status.account.url;
  1041. }
  1042. return '/i/web/profile/_/' + status.account.id;
  1043. }
  1044. }
  1045. }
  1046. </script>