Profile.vue 39 KB

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