Profile.vue 38 KB

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