Profile.vue 36 KB

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