Profile.vue 37 KB

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