Profile.vue 39 KB

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