Profile.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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. },
  533. mounted() {
  534. },
  535. updated() {
  536. },
  537. methods: {
  538. fetchProfile() {
  539. axios.get('/api/v1/accounts/' + this.profileId).then(res => {
  540. this.profile = res.data;
  541. });
  542. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  543. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  544. this.user = res.data;
  545. });
  546. }
  547. let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses';
  548. axios.get(apiUrl, {
  549. params: {
  550. only_media: true,
  551. min_id: 1,
  552. }
  553. })
  554. .then(res => {
  555. let data = res.data;
  556. let ids = data.map(status => status.id);
  557. this.ids = ids;
  558. this.min_id = Math.max(...ids);
  559. this.max_id = Math.min(...ids);
  560. this.modalStatus = _.first(res.data);
  561. this.timeline = data;
  562. this.ownerCheck();
  563. this.loading = false;
  564. }).catch(err => {
  565. swal(
  566. 'Oops, something went wrong',
  567. 'Please release the page.',
  568. 'error'
  569. );
  570. });
  571. },
  572. ownerCheck() {
  573. this.owner = this.profile.id === this.user.id;
  574. },
  575. infiniteTimeline($state) {
  576. if(this.loading || this.timeline.length < 9) {
  577. $state.complete();
  578. return;
  579. }
  580. let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses';
  581. axios.get(apiUrl, {
  582. params: {
  583. only_media: true,
  584. max_id: this.max_id
  585. },
  586. }).then(res => {
  587. if (res.data.length && this.loading == false) {
  588. let data = res.data;
  589. let self = this;
  590. data.forEach(d => {
  591. if(self.ids.indexOf(d.id) == -1) {
  592. self.timeline.push(d);
  593. self.ids.push(d.id);
  594. }
  595. });
  596. this.min_id = Math.max(...this.ids);
  597. this.max_id = Math.min(...this.ids);
  598. $state.loaded();
  599. this.loading = false;
  600. } else {
  601. $state.complete();
  602. }
  603. });
  604. },
  605. previewUrl(status) {
  606. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  607. },
  608. previewBackground(status) {
  609. let preview = this.previewUrl(status);
  610. return 'background-image: url(' + preview + ');';
  611. },
  612. switchMode(mode) {
  613. this.mode = _.indexOf(this.modes, mode) ? mode : 'grid';
  614. if(this.mode == 'masonry') {
  615. $('.masonry').masonry({
  616. columnWidth: 200,
  617. itemSelector: '.masonry-item'
  618. });
  619. }
  620. },
  621. reportProfile() {
  622. let id = this.profile.id;
  623. window.location.href = '/i/report?type=user&id=' + id;
  624. },
  625. reportUrl(status) {
  626. let type = status.in_reply_to ? 'comment' : 'post';
  627. let id = status.id;
  628. return '/i/report?type=' + type + '&id=' + id;
  629. },
  630. commentFocus(status, $event) {
  631. let el = event.target;
  632. let card = el.parentElement.parentElement.parentElement;
  633. let comments = card.getElementsByClassName('comments')[0];
  634. if(comments.children.length == 0) {
  635. comments.classList.add('mb-2');
  636. this.fetchStatusComments(status, card);
  637. }
  638. let footer = card.querySelectorAll('.card-footer')[0];
  639. let input = card.querySelectorAll('.status-reply-input')[0];
  640. if(footer.classList.contains('d-none') == true) {
  641. footer.classList.remove('d-none');
  642. input.focus();
  643. } else {
  644. footer.classList.add('d-none');
  645. input.blur();
  646. }
  647. },
  648. likeStatus(status, $event) {
  649. if($('body').hasClass('loggedIn') == false) {
  650. return;
  651. }
  652. axios.post('/i/like', {
  653. item: status.id
  654. }).then(res => {
  655. status.favourites_count = res.data.count;
  656. if(status.favourited == true) {
  657. status.favourited = false;
  658. } else {
  659. status.favourited = true;
  660. }
  661. }).catch(err => {
  662. swal('Error', 'Something went wrong, please try again later.', 'error');
  663. });
  664. },
  665. shareStatus(status, $event) {
  666. if($('body').hasClass('loggedIn') == false) {
  667. return;
  668. }
  669. axios.post('/i/share', {
  670. item: status.id
  671. }).then(res => {
  672. status.reblogs_count = res.data.count;
  673. if(status.reblogged == true) {
  674. status.reblogged = false;
  675. } else {
  676. status.reblogged = true;
  677. }
  678. }).catch(err => {
  679. swal('Error', 'Something went wrong, please try again later.', 'error');
  680. });
  681. },
  682. timestampFormat(timestamp) {
  683. let ts = new Date(timestamp);
  684. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  685. },
  686. editUrl(status) {
  687. return status.url + '/edit';
  688. },
  689. redirect(url) {
  690. window.location.href = url;
  691. return;
  692. },
  693. replyUrl(status) {
  694. let username = this.profile.username;
  695. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  696. return '/p/' + username + '/' + id;
  697. },
  698. mentionUrl(status) {
  699. let username = status.account.username;
  700. let id = status.id;
  701. return '/p/' + username + '/' + id;
  702. },
  703. statusOwner(status) {
  704. let sid = status.account.id;
  705. let uid = this.profile.id;
  706. if(sid == uid) {
  707. return true;
  708. } else {
  709. return false;
  710. }
  711. },
  712. fetchStatusComments(status, card) {
  713. axios.get('/api/v2/status/'+status.id+'/replies')
  714. .then(res => {
  715. let comments = card.querySelectorAll('.comments')[0];
  716. let data = res.data;
  717. data.forEach(function(i, k) {
  718. let username = document.createElement('a');
  719. username.classList.add('font-weight-bold');
  720. username.classList.add('text-dark');
  721. username.classList.add('mr-2');
  722. username.setAttribute('href', i.account.url);
  723. username.textContent = i.account.username;
  724. let text = document.createElement('span');
  725. text.innerHTML = i.content;
  726. let comment = document.createElement('p');
  727. comment.classList.add('read-more');
  728. comment.classList.add('mb-0');
  729. comment.appendChild(username);
  730. comment.appendChild(text);
  731. comments.appendChild(comment);
  732. });
  733. }).catch(err => {
  734. })
  735. },
  736. fetchRelationships() {
  737. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  738. return;
  739. }
  740. axios.get('/api/v1/accounts/relationships', {
  741. params: {
  742. 'id[]': this.profileId
  743. }
  744. }).then(res => {
  745. this.relationship = res.data[0];
  746. if(res.data[0].blocking == true) {
  747. this.warning = true;
  748. }
  749. });
  750. },
  751. muteProfile(status = null) {
  752. if($('body').hasClass('loggedIn') == false) {
  753. return;
  754. }
  755. let id = this.profileId;
  756. axios.post('/i/mute', {
  757. type: 'user',
  758. item: id
  759. }).then(res => {
  760. this.fetchRelationships();
  761. this.$refs.visitorContextMenu.hide();
  762. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  763. }).catch(err => {
  764. swal('Error', 'Something went wrong. Please try again later.', 'error');
  765. });
  766. },
  767. unmuteProfile(status = null) {
  768. if($('body').hasClass('loggedIn') == false) {
  769. return;
  770. }
  771. let id = this.profileId;
  772. axios.post('/i/unmute', {
  773. type: 'user',
  774. item: id
  775. }).then(res => {
  776. this.fetchRelationships();
  777. this.$refs.visitorContextMenu.hide();
  778. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  779. }).catch(err => {
  780. swal('Error', 'Something went wrong. Please try again later.', 'error');
  781. });
  782. },
  783. blockProfile(status = null) {
  784. if($('body').hasClass('loggedIn') == false) {
  785. return;
  786. }
  787. let id = this.profileId;
  788. axios.post('/i/block', {
  789. type: 'user',
  790. item: id
  791. }).then(res => {
  792. this.warning = true;
  793. this.fetchRelationships();
  794. this.$refs.visitorContextMenu.hide();
  795. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  796. }).catch(err => {
  797. swal('Error', 'Something went wrong. Please try again later.', 'error');
  798. });
  799. },
  800. unblockProfile(status = null) {
  801. if($('body').hasClass('loggedIn') == false) {
  802. return;
  803. }
  804. let id = this.profileId;
  805. axios.post('/i/unblock', {
  806. type: 'user',
  807. item: id
  808. }).then(res => {
  809. this.fetchRelationships();
  810. this.$refs.visitorContextMenu.hide();
  811. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  812. }).catch(err => {
  813. swal('Error', 'Something went wrong. Please try again later.', 'error');
  814. });
  815. },
  816. deletePost(status, index) {
  817. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  818. return;
  819. }
  820. axios.post('/i/delete', {
  821. type: 'status',
  822. item: status.id
  823. }).then(res => {
  824. this.timeline.splice(index,1);
  825. swal('Success', 'You have successfully deleted this post', 'success');
  826. }).catch(err => {
  827. swal('Error', 'Something went wrong. Please try again later.', 'error');
  828. });
  829. },
  830. commentSubmit(status, $event) {
  831. if($('body').hasClass('loggedIn') == false) {
  832. return;
  833. }
  834. let id = status.id;
  835. let form = $event.target;
  836. let input = $(form).find('input[name="comment"]');
  837. let comment = input.val();
  838. let comments = form.parentElement.parentElement.getElementsByClassName('comments')[0];
  839. axios.post('/i/comment', {
  840. item: id,
  841. comment: comment
  842. }).then(res => {
  843. input.val('');
  844. input.blur();
  845. let username = document.createElement('a');
  846. username.classList.add('font-weight-bold');
  847. username.classList.add('text-dark');
  848. username.classList.add('mr-2');
  849. username.setAttribute('href', this.user.url);
  850. username.textContent = this.user.username;
  851. let text = document.createElement('span');
  852. text.innerHTML = comment;
  853. let wrapper = document.createElement('p');
  854. wrapper.classList.add('read-more');
  855. wrapper.classList.add('mb-0');
  856. wrapper.appendChild(username);
  857. wrapper.appendChild(text);
  858. comments.insertBefore(wrapper, comments.firstChild);
  859. });
  860. },
  861. statusModal(status) {
  862. this.modalStatus = status;
  863. this.$refs.statusModalRef.show();
  864. },
  865. masonryOrientation(status) {
  866. let o = status.media_attachments[0].orientation;
  867. if(!o) {
  868. o = 'square';
  869. }
  870. return o;
  871. },
  872. followProfile() {
  873. if($('body').hasClass('loggedIn') == false) {
  874. return;
  875. }
  876. axios.post('/i/follow', {
  877. item: this.profileId
  878. }).then(res => {
  879. this.$refs.visitorContextMenu.hide();
  880. if(this.relationship.following) {
  881. this.profile.followers_count--;
  882. if(this.profile.locked == true) {
  883. window.location.href = '/';
  884. }
  885. } else {
  886. this.profile.followers_count++;
  887. }
  888. this.relationship.following = !this.relationship.following;
  889. });
  890. },
  891. followingModal() {
  892. if($('body').hasClass('loggedIn') == false) {
  893. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  894. return;
  895. }
  896. if(this.profileSettings.following.list == false) {
  897. return;
  898. }
  899. if(this.following.length > 0) {
  900. this.$refs.followingModal.show();
  901. return;
  902. }
  903. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  904. params: {
  905. page: this.followingCursor
  906. }
  907. })
  908. .then(res => {
  909. this.following = res.data;
  910. this.followingCursor++;
  911. if(res.data.length < 10) {
  912. this.followingMore = false;
  913. }
  914. });
  915. this.$refs.followingModal.show();
  916. },
  917. followersModal() {
  918. if($('body').hasClass('loggedIn') == false) {
  919. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  920. return;
  921. }
  922. if(this.profileSettings.followers.list == false) {
  923. return;
  924. }
  925. if(this.followers.length > 0) {
  926. this.$refs.followerModal.show();
  927. return;
  928. }
  929. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  930. params: {
  931. page: this.followerCursor
  932. }
  933. })
  934. .then(res => {
  935. this.followers = res.data;
  936. this.followerCursor++;
  937. if(res.data.length < 10) {
  938. this.followerMore = false;
  939. }
  940. })
  941. this.$refs.followerModal.show();
  942. },
  943. followingLoadMore() {
  944. if($('body').hasClass('loggedIn') == false) {
  945. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  946. return;
  947. }
  948. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  949. params: {
  950. page: this.followingCursor
  951. }
  952. })
  953. .then(res => {
  954. if(res.data.length > 0) {
  955. this.following.push(...res.data);
  956. this.followingCursor++;
  957. }
  958. if(res.data.length < 10) {
  959. this.followingMore = false;
  960. }
  961. });
  962. },
  963. followersLoadMore() {
  964. if($('body').hasClass('loggedIn') == false) {
  965. return;
  966. }
  967. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  968. params: {
  969. page: this.followerCursor
  970. }
  971. })
  972. .then(res => {
  973. if(res.data.length > 0) {
  974. this.followers.push(...res.data);
  975. this.followerCursor++;
  976. }
  977. if(res.data.length < 10) {
  978. this.followerMore = false;
  979. }
  980. });
  981. },
  982. visitorMenu() {
  983. if($('body').hasClass('loggedIn') == false) {
  984. return;
  985. }
  986. this.$refs.visitorContextMenu.show();
  987. },
  988. followModalAction(id, index, type = 'following') {
  989. axios.post('/i/follow', {
  990. item: id
  991. }).then(res => {
  992. if(type == 'following') {
  993. this.following.splice(index, 1);
  994. this.profile.following_count--;
  995. }
  996. })
  997. },
  998. momentBackground() {
  999. let c = 'w-100 h-100 mt-n3 ';
  1000. if(this.profile.header_bg) {
  1001. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1002. } else {
  1003. c += 'bg-pixelfed';
  1004. }
  1005. return c;
  1006. }
  1007. }
  1008. }
  1009. </script>