Profile.vue 38 KB

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