Profile.vue 37 KB

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