Profile.vue 39 KB

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