1
0

Profile.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  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">
  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="profile.locked == false" class="list-group-item cursor-pointer text-center rounded text-dark" @click="showEmbedProfileModal">
  420. Embed
  421. </div>
  422. <div v-if="user && !owner && !relationship.following" class="list-group-item cursor-pointer text-center rounded text-dark" @click="followProfile">
  423. Follow
  424. </div>
  425. <div v-if="user && !owner && relationship.following" class="list-group-item cursor-pointer text-center rounded" @click="followProfile">
  426. Unfollow
  427. </div>
  428. <div v-if="user && !owner && !relationship.muting" class="list-group-item cursor-pointer text-center rounded" @click="muteProfile">
  429. Mute
  430. </div>
  431. <div v-if="user && !owner && relationship.muting" class="list-group-item cursor-pointer text-center rounded" @click="unmuteProfile">
  432. Unmute
  433. </div>
  434. <div v-if="user && !owner" class="list-group-item cursor-pointer text-center rounded text-dark" @click="reportProfile">
  435. Report User
  436. </div>
  437. <div v-if="user && !owner && !relationship.blocking" class="list-group-item cursor-pointer text-center rounded text-dark" @click="blockProfile">
  438. Block
  439. </div>
  440. <div v-if="user && !owner && relationship.blocking" class="list-group-item cursor-pointer text-center rounded text-dark" @click="unblockProfile">
  441. Unblock
  442. </div>
  443. <div v-if="user && owner" class="list-group-item cursor-pointer text-center rounded text-dark" @click="redirect('/settings/home')">
  444. Settings
  445. </div>
  446. <div class="list-group-item cursor-pointer text-center rounded text-muted" @click="$refs.visitorContextMenu.hide()">
  447. Close
  448. </div>
  449. </div>
  450. </b-modal>
  451. <b-modal ref="sponsorModal"
  452. id="sponsor-modal"
  453. hide-footer
  454. :title="'Sponsor ' + profileUsername"
  455. centered
  456. size="md"
  457. body-class="px-5">
  458. <div>
  459. <p class="font-weight-bold">External Links</p>
  460. <p v-if="sponsorList.patreon" class="pt-2">
  461. <a :href="'https://' + sponsorList.patreon" rel="nofollow" class="font-weight-bold">{{sponsorList.patreon}}</a>
  462. </p>
  463. <p v-if="sponsorList.liberapay" class="pt-2">
  464. <a :href="'https://' + sponsorList.liberapay" rel="nofollow" class="font-weight-bold">{{sponsorList.liberapay}}</a>
  465. </p>
  466. <p v-if="sponsorList.opencollective" class="pt-2">
  467. <a :href="'https://' + sponsorList.opencollective" rel="nofollow" class="font-weight-bold">{{sponsorList.opencollective}}</a>
  468. </p>
  469. </div>
  470. </b-modal>
  471. <b-modal ref="embedModal"
  472. id="ctx-embed-modal"
  473. hide-header
  474. hide-footer
  475. centered
  476. rounded
  477. size="md"
  478. body-class="p-2 rounded">
  479. <div>
  480. <textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 12px; height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
  481. <hr>
  482. <button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
  483. <p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
  484. </div>
  485. </b-modal>
  486. </div>
  487. </template>
  488. <style type="text/css" scoped>
  489. .o-square {
  490. max-width: 320px;
  491. }
  492. .o-portrait {
  493. max-width: 320px;
  494. }
  495. .o-landscape {
  496. max-width: 320px;
  497. }
  498. .post-icon {
  499. color: #fff;
  500. position:relative;
  501. margin-top: 10px;
  502. z-index: 9;
  503. opacity: 0.6;
  504. text-shadow: 3px 3px 16px #272634;
  505. }
  506. .font-size-16px {
  507. font-size: 16px;
  508. }
  509. .profile-website {
  510. color: #003569;
  511. text-decoration: none;
  512. font-weight: 600;
  513. }
  514. .nav-topbar .nav-link {
  515. color: #999;
  516. }
  517. .nav-topbar .nav-link .small {
  518. font-weight: 600;
  519. }
  520. </style>
  521. <script type="text/javascript">
  522. import VueMasonry from 'vue-masonry-css'
  523. export default {
  524. props: [
  525. 'profile-id',
  526. 'profile-layout',
  527. 'profile-settings',
  528. 'profile-username'
  529. ],
  530. data() {
  531. return {
  532. ids: [],
  533. profile: {},
  534. user: false,
  535. timeline: [],
  536. timelinePage: 2,
  537. min_id: 0,
  538. max_id: 0,
  539. loading: true,
  540. owner: false,
  541. layout: this.profileLayout,
  542. mode: 'grid',
  543. modes: ['grid', 'collections', 'bookmarks'],
  544. modalStatus: false,
  545. relationship: {},
  546. followers: [],
  547. followerCursor: 1,
  548. followerMore: true,
  549. following: [],
  550. followingCursor: 1,
  551. followingMore: true,
  552. warning: false,
  553. sponsorList: [],
  554. bookmarks: [],
  555. bookmarksPage: 2,
  556. collections: [],
  557. collectionsPage: 2,
  558. isMobile: false,
  559. ctxEmbedPayload: null,
  560. copiedEmbed: false
  561. }
  562. },
  563. beforeMount() {
  564. this.fetchRelationships();
  565. this.fetchProfile();
  566. let u = new URLSearchParams(window.location.search);
  567. let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
  568. if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
  569. this.layout = 'metro';
  570. }
  571. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  572. Vue.use(VueMasonry);
  573. this.layout = 'moment';
  574. }
  575. if(this.layout == 'metro' && u.has('t')) {
  576. if(this.modes.indexOf(u.get('t')) != -1) {
  577. if(u.get('t') == 'bookmarks') {
  578. return;
  579. }
  580. this.mode = u.get('t');
  581. }
  582. }
  583. },
  584. mounted() {
  585. let u = new URLSearchParams(window.location.search);
  586. if(u.has('md') && u.get('md') == 'followers') {
  587. this.followersModal();
  588. }
  589. if(u.has('md') && u.get('md') == 'following') {
  590. this.followingModal();
  591. }
  592. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  593. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  594. this.user = res.data;
  595. });
  596. }
  597. if(window.outerWidth < 576) {
  598. $('nav.navbar').hide();
  599. this.isMobile = true;
  600. }
  601. },
  602. updated() {
  603. $('[data-toggle="tooltip"]').tooltip();
  604. },
  605. methods: {
  606. fetchProfile() {
  607. axios.get('/api/pixelfed/v1/accounts/' + this.profileId).then(res => {
  608. this.profile = res.data;
  609. }).then(res => {
  610. this.fetchPosts();
  611. });
  612. },
  613. fetchPosts() {
  614. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  615. axios.get(apiUrl, {
  616. params: {
  617. only_media: true,
  618. min_id: 1,
  619. }
  620. })
  621. .then(res => {
  622. let data = res.data.filter(status => status.media_attachments.length > 0);
  623. let ids = data.map(status => status.id);
  624. this.ids = ids;
  625. this.min_id = Math.max(...ids);
  626. this.max_id = Math.min(...ids);
  627. this.modalStatus = _.first(res.data);
  628. this.timeline = data;
  629. this.ownerCheck();
  630. this.loading = false;
  631. //this.loadSponsor();
  632. }).catch(err => {
  633. swal('Oops, something went wrong',
  634. 'Please release the page.',
  635. 'error');
  636. });
  637. },
  638. ownerCheck() {
  639. if($('body').hasClass('loggedIn') == false) {
  640. this.owner = false;
  641. return;
  642. }
  643. this.owner = this.profile.id === this.user.id;
  644. },
  645. infiniteTimeline($state) {
  646. if(this.loading || this.timeline.length < 9) {
  647. $state.complete();
  648. return;
  649. }
  650. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  651. axios.get(apiUrl, {
  652. params: {
  653. only_media: true,
  654. max_id: this.max_id
  655. },
  656. }).then(res => {
  657. if (res.data.length && this.loading == false) {
  658. let data = res.data;
  659. let self = this;
  660. data.forEach(d => {
  661. if(self.ids.indexOf(d.id) == -1) {
  662. self.timeline.push(d);
  663. self.ids.push(d.id);
  664. }
  665. });
  666. this.min_id = Math.max(...this.ids);
  667. this.max_id = Math.min(...this.ids);
  668. $state.loaded();
  669. this.loading = false;
  670. } else {
  671. $state.complete();
  672. }
  673. });
  674. },
  675. previewUrl(status) {
  676. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  677. },
  678. previewBackground(status) {
  679. let preview = this.previewUrl(status);
  680. return 'background-image: url(' + preview + ');';
  681. },
  682. switchMode(mode) {
  683. this.mode = _.indexOf(this.modes, mode) ? mode : 'grid';
  684. if(this.mode == 'bookmarks' && this.bookmarks.length == 0) {
  685. axios.get('/api/local/bookmarks')
  686. .then(res => {
  687. this.bookmarks = res.data
  688. });
  689. }
  690. if(this.mode == 'collections' && this.collections.length == 0) {
  691. axios.get('/api/local/profile/collections/' + this.profileId)
  692. .then(res => {
  693. this.collections = res.data
  694. });
  695. }
  696. },
  697. reportProfile() {
  698. let id = this.profile.id;
  699. window.location.href = '/i/report?type=user&id=' + id;
  700. },
  701. reportUrl(status) {
  702. let type = status.in_reply_to ? 'comment' : 'post';
  703. let id = status.id;
  704. return '/i/report?type=' + type + '&id=' + id;
  705. },
  706. commentFocus(status, $event) {
  707. let el = event.target;
  708. let card = el.parentElement.parentElement.parentElement;
  709. let comments = card.getElementsByClassName('comments')[0];
  710. if(comments.children.length == 0) {
  711. comments.classList.add('mb-2');
  712. this.fetchStatusComments(status, card);
  713. }
  714. let footer = card.querySelectorAll('.card-footer')[0];
  715. let input = card.querySelectorAll('.status-reply-input')[0];
  716. if(footer.classList.contains('d-none') == true) {
  717. footer.classList.remove('d-none');
  718. input.focus();
  719. } else {
  720. footer.classList.add('d-none');
  721. input.blur();
  722. }
  723. },
  724. likeStatus(status, $event) {
  725. if($('body').hasClass('loggedIn') == false) {
  726. return;
  727. }
  728. axios.post('/i/like', {
  729. item: status.id
  730. }).then(res => {
  731. status.favourites_count = res.data.count;
  732. if(status.favourited == true) {
  733. status.favourited = false;
  734. } else {
  735. status.favourited = true;
  736. }
  737. }).catch(err => {
  738. swal('Error', 'Something went wrong, please try again later.', 'error');
  739. });
  740. },
  741. shareStatus(status, $event) {
  742. if($('body').hasClass('loggedIn') == false) {
  743. return;
  744. }
  745. axios.post('/i/share', {
  746. item: status.id
  747. }).then(res => {
  748. status.reblogs_count = res.data.count;
  749. if(status.reblogged == true) {
  750. status.reblogged = false;
  751. } else {
  752. status.reblogged = true;
  753. }
  754. }).catch(err => {
  755. swal('Error', 'Something went wrong, please try again later.', 'error');
  756. });
  757. },
  758. timestampFormat(timestamp) {
  759. let ts = new Date(timestamp);
  760. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  761. },
  762. editUrl(status) {
  763. return status.url + '/edit';
  764. },
  765. redirect(url) {
  766. window.location.href = url;
  767. return;
  768. },
  769. replyUrl(status) {
  770. let username = this.profile.username;
  771. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  772. return '/p/' + username + '/' + id;
  773. },
  774. mentionUrl(status) {
  775. let username = status.account.username;
  776. let id = status.id;
  777. return '/p/' + username + '/' + id;
  778. },
  779. statusOwner(status) {
  780. let sid = status.account.id;
  781. let uid = this.profile.id;
  782. if(sid == uid) {
  783. return true;
  784. } else {
  785. return false;
  786. }
  787. },
  788. fetchRelationships() {
  789. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  790. return;
  791. }
  792. axios.get('/api/pixelfed/v1/accounts/relationships', {
  793. params: {
  794. 'id[]': this.profileId
  795. }
  796. }).then(res => {
  797. if(res.data.length) {
  798. this.relationship = res.data[0];
  799. if(res.data[0].blocking == true) {
  800. this.warning = true;
  801. }
  802. }
  803. });
  804. },
  805. muteProfile(status = null) {
  806. if($('body').hasClass('loggedIn') == false) {
  807. return;
  808. }
  809. let id = this.profileId;
  810. axios.post('/i/mute', {
  811. type: 'user',
  812. item: id
  813. }).then(res => {
  814. this.fetchRelationships();
  815. this.$refs.visitorContextMenu.hide();
  816. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  817. }).catch(err => {
  818. swal('Error', 'Something went wrong. Please try again later.', 'error');
  819. });
  820. },
  821. unmuteProfile(status = null) {
  822. if($('body').hasClass('loggedIn') == false) {
  823. return;
  824. }
  825. let id = this.profileId;
  826. axios.post('/i/unmute', {
  827. type: 'user',
  828. item: id
  829. }).then(res => {
  830. this.fetchRelationships();
  831. this.$refs.visitorContextMenu.hide();
  832. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  833. }).catch(err => {
  834. swal('Error', 'Something went wrong. Please try again later.', 'error');
  835. });
  836. },
  837. blockProfile(status = null) {
  838. if($('body').hasClass('loggedIn') == false) {
  839. return;
  840. }
  841. let id = this.profileId;
  842. axios.post('/i/block', {
  843. type: 'user',
  844. item: id
  845. }).then(res => {
  846. this.warning = true;
  847. this.fetchRelationships();
  848. this.$refs.visitorContextMenu.hide();
  849. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  850. }).catch(err => {
  851. swal('Error', 'Something went wrong. Please try again later.', 'error');
  852. });
  853. },
  854. unblockProfile(status = null) {
  855. if($('body').hasClass('loggedIn') == false) {
  856. return;
  857. }
  858. let id = this.profileId;
  859. axios.post('/i/unblock', {
  860. type: 'user',
  861. item: id
  862. }).then(res => {
  863. this.fetchRelationships();
  864. this.$refs.visitorContextMenu.hide();
  865. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  866. }).catch(err => {
  867. swal('Error', 'Something went wrong. Please try again later.', 'error');
  868. });
  869. },
  870. deletePost(status, index) {
  871. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  872. return;
  873. }
  874. axios.post('/i/delete', {
  875. type: 'status',
  876. item: status.id
  877. }).then(res => {
  878. this.timeline.splice(index,1);
  879. swal('Success', 'You have successfully deleted this post', 'success');
  880. }).catch(err => {
  881. swal('Error', 'Something went wrong. Please try again later.', 'error');
  882. });
  883. },
  884. followProfile() {
  885. if($('body').hasClass('loggedIn') == false) {
  886. return;
  887. }
  888. axios.post('/i/follow', {
  889. item: this.profileId
  890. }).then(res => {
  891. this.$refs.visitorContextMenu.hide();
  892. if(this.relationship.following) {
  893. this.profile.followers_count--;
  894. if(this.profile.locked == true) {
  895. window.location.href = '/';
  896. }
  897. } else {
  898. this.profile.followers_count++;
  899. }
  900. this.relationship.following = !this.relationship.following;
  901. }).catch(err => {
  902. if(err.response.data.message) {
  903. swal('Error', err.response.data.message, 'error');
  904. }
  905. });
  906. },
  907. followingModal() {
  908. if($('body').hasClass('loggedIn') == false) {
  909. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  910. return;
  911. }
  912. if(this.profileSettings.following.list == false) {
  913. return;
  914. }
  915. if(this.followingCursor > 1) {
  916. this.$refs.followingModal.show();
  917. return;
  918. } else {
  919. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/following', {
  920. params: {
  921. page: this.followingCursor
  922. }
  923. })
  924. .then(res => {
  925. this.following = res.data;
  926. this.followingCursor++;
  927. if(res.data.length < 10) {
  928. this.followingMore = false;
  929. }
  930. });
  931. this.$refs.followingModal.show();
  932. return;
  933. }
  934. },
  935. followersModal() {
  936. if($('body').hasClass('loggedIn') == false) {
  937. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  938. return;
  939. }
  940. if(this.profileSettings.followers.list == false) {
  941. return;
  942. }
  943. if(this.followerCursor > 1) {
  944. this.$refs.followerModal.show();
  945. return;
  946. } else {
  947. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/followers', {
  948. params: {
  949. page: this.followerCursor
  950. }
  951. })
  952. .then(res => {
  953. this.followers.push(...res.data);
  954. this.followerCursor++;
  955. if(res.data.length < 10) {
  956. this.followerMore = false;
  957. }
  958. })
  959. this.$refs.followerModal.show();
  960. return;
  961. }
  962. },
  963. followingLoadMore() {
  964. if($('body').hasClass('loggedIn') == false) {
  965. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  966. return;
  967. }
  968. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  969. params: {
  970. page: this.followingCursor
  971. }
  972. })
  973. .then(res => {
  974. if(res.data.length > 0) {
  975. this.following.push(...res.data);
  976. this.followingCursor++;
  977. }
  978. if(res.data.length < 10) {
  979. this.followingMore = false;
  980. }
  981. });
  982. },
  983. followersLoadMore() {
  984. if($('body').hasClass('loggedIn') == false) {
  985. return;
  986. }
  987. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  988. params: {
  989. page: this.followerCursor
  990. }
  991. })
  992. .then(res => {
  993. if(res.data.length > 0) {
  994. this.followers.push(...res.data);
  995. this.followerCursor++;
  996. }
  997. if(res.data.length < 10) {
  998. this.followerMore = false;
  999. }
  1000. });
  1001. },
  1002. visitorMenu() {
  1003. this.$refs.visitorContextMenu.show();
  1004. },
  1005. followModalAction(id, index, type = 'following') {
  1006. axios.post('/i/follow', {
  1007. item: id
  1008. }).then(res => {
  1009. if(type == 'following') {
  1010. this.following.splice(index, 1);
  1011. this.profile.following_count--;
  1012. }
  1013. }).catch(err => {
  1014. if(err.response.data.message) {
  1015. swal('Error', err.response.data.message, 'error');
  1016. }
  1017. });
  1018. },
  1019. momentBackground() {
  1020. let c = 'w-100 h-100 mt-n3 ';
  1021. if(this.profile.header_bg) {
  1022. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1023. } else {
  1024. c += 'bg-pixelfed';
  1025. }
  1026. return c;
  1027. },
  1028. loadSponsor() {
  1029. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1030. .then(res => {
  1031. this.sponsorList = res.data;
  1032. });
  1033. },
  1034. showSponsorModal() {
  1035. this.$refs.sponsorModal.show();
  1036. },
  1037. goBack() {
  1038. if(window.history.length > 2) {
  1039. window.history.back();
  1040. return;
  1041. } else {
  1042. window.location.href = '/';
  1043. return;
  1044. }
  1045. },
  1046. copyProfileLink() {
  1047. navigator.clipboard.writeText(window.location.href);
  1048. this.$refs.visitorContextMenu.hide();
  1049. },
  1050. formatCount(count) {
  1051. return App.util.format.count(count);
  1052. },
  1053. statusUrl(status) {
  1054. return status.url;
  1055. if(status.local == true) {
  1056. return status.url;
  1057. }
  1058. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1059. },
  1060. profileUrl(status) {
  1061. return status.url;
  1062. if(status.local == true) {
  1063. return status.account.url;
  1064. }
  1065. return '/i/web/profile/_/' + status.account.id;
  1066. },
  1067. showEmbedProfileModal() {
  1068. this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url)
  1069. this.$refs.embedModal.show();
  1070. },
  1071. ctxCopyEmbed() {
  1072. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1073. this.$refs.embedModal.hide();
  1074. this.$refs.visitorContextMenu.hide();
  1075. },
  1076. }
  1077. }
  1078. </script>