Profile.vue 36 KB

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