Profile.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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="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="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">
  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="profile.id != user.id && 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" 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="w-100 h-100 mt-n3 bg-pixelfed" 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="s.media_attachments[0].url" class="img-fluid">
  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>
  384. </div>
  385. <div v-if="followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  386. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  387. </div>
  388. </div>
  389. </b-modal>
  390. <b-modal ref="followerModal"
  391. id="follower-modal"
  392. hide-footer
  393. centered
  394. title="Followers"
  395. body-class="list-group-flush p-0">
  396. <div class="list-group">
  397. <div class="list-group-item border-0" v-for="(user, index) in followers" :key="'follower_'+index">
  398. <div class="media">
  399. <a :href="user.url">
  400. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" loading="lazy">
  401. </a>
  402. <div class="media-body">
  403. <p class="mb-0" style="font-size: 14px">
  404. <a :href="user.url" class="font-weight-bold text-dark">
  405. {{user.username}}
  406. </a>
  407. </p>
  408. <p class="text-muted mb-0" style="font-size: 14px">
  409. {{user.display_name}}
  410. </p>
  411. </div>
  412. </div>
  413. </div>
  414. <div v-if="followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  415. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  416. </div>
  417. </div>
  418. </b-modal>
  419. <b-modal ref="visitorContextMenu"
  420. id="visitor-context-menu"
  421. hide-footer
  422. hide-header
  423. centered
  424. size="sm"
  425. body-class="list-group-flush p-0">
  426. <div class="list-group" v-if="relationship">
  427. <div v-if="!owner && !relationship.following" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-primary" @click="followProfile">
  428. Follow
  429. </div>
  430. <div v-if="!owner && relationship.following" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded" @click="followProfile">
  431. Unfollow
  432. </div>
  433. <div v-if="!owner && !relationship.muting" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded" @click="muteProfile">
  434. Mute
  435. </div>
  436. <div v-if="!owner && relationship.muting" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded" @click="unmuteProfile">
  437. Unmute
  438. </div>
  439. <div v-if="!owner" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-danger" @click="reportProfile">
  440. Report User
  441. </div>
  442. <div v-if="!owner && !relationship.blocking" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-danger" @click="blockProfile">
  443. Block
  444. </div>
  445. <div v-if="!owner && relationship.blocking" class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-danger" @click="unblockProfile">
  446. Unblock
  447. </div>
  448. <div class="list-group-item cursor-pointer text-center font-weight-bold lead rounded text-muted" @click="$refs.visitorContextMenu.hide()">
  449. Close
  450. </div>
  451. </div>
  452. </b-modal>
  453. </div>
  454. </template>
  455. <!-- <style type="text/css" scoped="">
  456. .modal-body {
  457. padding: 0;
  458. margin: 0;
  459. }
  460. @media (min-width: 992px) {
  461. .modal-lg, .modal-xl {
  462. max-width: 900px;
  463. }
  464. }
  465. </style> -->
  466. <style type="text/css" scoped>
  467. .o-square {
  468. max-width: 320px;
  469. }
  470. .o-portrait {
  471. max-width: 320px;
  472. }
  473. .o-landscape {
  474. max-width: 320px;
  475. }
  476. .post-icon {
  477. color: #fff;
  478. position:relative;
  479. margin-top: 10px;
  480. z-index: 9;
  481. opacity: 0.6;
  482. text-shadow: 3px 3px 16px #272634;
  483. }
  484. </style>
  485. <script type="text/javascript">
  486. export default {
  487. props: [
  488. 'profile-id',
  489. 'profile-settings',
  490. 'profile-layout'
  491. ],
  492. data() {
  493. return {
  494. profile: {},
  495. user: {},
  496. timeline: [],
  497. timelinePage: 2,
  498. min_id: 0,
  499. max_id: 0,
  500. loading: true,
  501. owner: false,
  502. mode: 'grid',
  503. modes: ['grid', 'list', 'masonry'],
  504. modalStatus: false,
  505. relationship: {},
  506. followers: [],
  507. followerCursor: 1,
  508. followerMore: true,
  509. following: [],
  510. followingCursor: 1,
  511. followingMore: true,
  512. warning: false
  513. }
  514. },
  515. beforeMount() {
  516. this.fetchRelationships();
  517. this.fetchProfile();
  518. },
  519. mounted() {
  520. },
  521. updated() {
  522. },
  523. methods: {
  524. fetchProfile() {
  525. axios.get('/api/v1/accounts/' + this.profileId).then(res => {
  526. this.profile = res.data;
  527. });
  528. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  529. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  530. this.user = res.data;
  531. });
  532. }
  533. let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses';
  534. axios.get(apiUrl, {
  535. params: {
  536. only_media: true,
  537. min_id: 1,
  538. }
  539. })
  540. .then(res => {
  541. let data = res.data;
  542. this.timeline = data;
  543. let ids = data.map(status => status.id);
  544. this.min_id = Math.max(...ids);
  545. this.max_id = Math.min(...ids);
  546. this.modalStatus = _.first(res.data);
  547. this.ownerCheck();
  548. this.loading = false;
  549. }).catch(err => {
  550. swal(
  551. 'Oops, something went wrong',
  552. 'Please release the page.',
  553. 'error'
  554. );
  555. });
  556. },
  557. ownerCheck() {
  558. this.owner = this.profile.id === this.user.id;
  559. },
  560. infiniteTimeline($state) {
  561. if(this.loading || this.timeline < 9) {
  562. return;
  563. }
  564. let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses';
  565. axios.get(apiUrl, {
  566. params: {
  567. only_media: true,
  568. max_id: this.max_id
  569. },
  570. }).then(res => {
  571. if (res.data.length && this.loading == false) {
  572. let data = res.data;
  573. this.timeline.push(...data);
  574. let ids = data.map(status => status.id);
  575. this.max_id = Math.min(...ids);
  576. this.loading = false;
  577. $state.loaded();
  578. } else {
  579. $state.complete();
  580. }
  581. });
  582. },
  583. previewUrl(status) {
  584. return status.media_attachments[0].preview_url;
  585. },
  586. previewBackground(status) {
  587. let preview = this.previewUrl(status);
  588. return 'background-image: url(' + preview + ');';
  589. },
  590. switchMode(mode) {
  591. this.mode = _.indexOf(this.modes, mode) ? mode : 'grid';
  592. if(this.mode == 'masonry') {
  593. $('.masonry').masonry({
  594. columnWidth: 200,
  595. itemSelector: '.masonry-item'
  596. });
  597. }
  598. },
  599. reportProfile() {
  600. let id = this.profile.id;
  601. window.location.href = '/i/report?type=user&id=' + id;
  602. },
  603. reportUrl(status) {
  604. let type = status.in_reply_to ? 'comment' : 'post';
  605. let id = status.id;
  606. return '/i/report?type=' + type + '&id=' + id;
  607. },
  608. commentFocus(status, $event) {
  609. let el = event.target;
  610. let card = el.parentElement.parentElement.parentElement;
  611. let comments = card.getElementsByClassName('comments')[0];
  612. if(comments.children.length == 0) {
  613. comments.classList.add('mb-2');
  614. this.fetchStatusComments(status, card);
  615. }
  616. let footer = card.querySelectorAll('.card-footer')[0];
  617. let input = card.querySelectorAll('.status-reply-input')[0];
  618. if(footer.classList.contains('d-none') == true) {
  619. footer.classList.remove('d-none');
  620. input.focus();
  621. } else {
  622. footer.classList.add('d-none');
  623. input.blur();
  624. }
  625. },
  626. likeStatus(status, $event) {
  627. if($('body').hasClass('loggedIn') == false) {
  628. return;
  629. }
  630. axios.post('/i/like', {
  631. item: status.id
  632. }).then(res => {
  633. status.favourites_count = res.data.count;
  634. if(status.favourited == true) {
  635. status.favourited = false;
  636. } else {
  637. status.favourited = true;
  638. }
  639. }).catch(err => {
  640. swal('Error', 'Something went wrong, please try again later.', 'error');
  641. });
  642. },
  643. shareStatus(status, $event) {
  644. if($('body').hasClass('loggedIn') == false) {
  645. return;
  646. }
  647. axios.post('/i/share', {
  648. item: status.id
  649. }).then(res => {
  650. status.reblogs_count = res.data.count;
  651. if(status.reblogged == true) {
  652. status.reblogged = false;
  653. } else {
  654. status.reblogged = true;
  655. }
  656. }).catch(err => {
  657. swal('Error', 'Something went wrong, please try again later.', 'error');
  658. });
  659. },
  660. timestampFormat(timestamp) {
  661. let ts = new Date(timestamp);
  662. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  663. },
  664. editUrl(status) {
  665. return status.url + '/edit';
  666. },
  667. redirect(url) {
  668. window.location.href = url;
  669. return;
  670. },
  671. replyUrl(status) {
  672. let username = this.profile.username;
  673. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  674. return '/p/' + username + '/' + id;
  675. },
  676. mentionUrl(status) {
  677. let username = status.account.username;
  678. let id = status.id;
  679. return '/p/' + username + '/' + id;
  680. },
  681. statusOwner(status) {
  682. let sid = status.account.id;
  683. let uid = this.profile.id;
  684. if(sid == uid) {
  685. return true;
  686. } else {
  687. return false;
  688. }
  689. },
  690. fetchStatusComments(status, card) {
  691. axios.get('/api/v2/status/'+status.id+'/replies')
  692. .then(res => {
  693. let comments = card.querySelectorAll('.comments')[0];
  694. let data = res.data;
  695. data.forEach(function(i, k) {
  696. let username = document.createElement('a');
  697. username.classList.add('font-weight-bold');
  698. username.classList.add('text-dark');
  699. username.classList.add('mr-2');
  700. username.setAttribute('href', i.account.url);
  701. username.textContent = i.account.username;
  702. let text = document.createElement('span');
  703. text.innerHTML = i.content;
  704. let comment = document.createElement('p');
  705. comment.classList.add('read-more');
  706. comment.classList.add('mb-0');
  707. comment.appendChild(username);
  708. comment.appendChild(text);
  709. comments.appendChild(comment);
  710. });
  711. }).catch(err => {
  712. })
  713. },
  714. fetchRelationships() {
  715. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  716. return;
  717. }
  718. axios.get('/api/v1/accounts/relationships', {
  719. params: {
  720. 'id[]': this.profileId
  721. }
  722. }).then(res => {
  723. this.relationship = res.data[0];
  724. if(res.data[0].blocking == true) {
  725. this.warning = true;
  726. }
  727. });
  728. },
  729. muteProfile(status = null) {
  730. if($('body').hasClass('loggedIn') == false) {
  731. return;
  732. }
  733. let id = this.profileId;
  734. axios.post('/i/mute', {
  735. type: 'user',
  736. item: id
  737. }).then(res => {
  738. this.fetchRelationships();
  739. this.$refs.visitorContextMenu.hide();
  740. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  741. }).catch(err => {
  742. swal('Error', 'Something went wrong. Please try again later.', 'error');
  743. });
  744. },
  745. unmuteProfile(status = null) {
  746. if($('body').hasClass('loggedIn') == false) {
  747. return;
  748. }
  749. let id = this.profileId;
  750. axios.post('/i/unmute', {
  751. type: 'user',
  752. item: id
  753. }).then(res => {
  754. this.fetchRelationships();
  755. this.$refs.visitorContextMenu.hide();
  756. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  757. }).catch(err => {
  758. swal('Error', 'Something went wrong. Please try again later.', 'error');
  759. });
  760. },
  761. blockProfile(status = null) {
  762. if($('body').hasClass('loggedIn') == false) {
  763. return;
  764. }
  765. let id = this.profileId;
  766. axios.post('/i/block', {
  767. type: 'user',
  768. item: id
  769. }).then(res => {
  770. this.warning = true;
  771. this.fetchRelationships();
  772. this.$refs.visitorContextMenu.hide();
  773. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  774. }).catch(err => {
  775. swal('Error', 'Something went wrong. Please try again later.', 'error');
  776. });
  777. },
  778. unblockProfile(status = null) {
  779. if($('body').hasClass('loggedIn') == false) {
  780. return;
  781. }
  782. let id = this.profileId;
  783. axios.post('/i/unblock', {
  784. type: 'user',
  785. item: id
  786. }).then(res => {
  787. this.fetchRelationships();
  788. this.$refs.visitorContextMenu.hide();
  789. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  790. }).catch(err => {
  791. swal('Error', 'Something went wrong. Please try again later.', 'error');
  792. });
  793. },
  794. deletePost(status, index) {
  795. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  796. return;
  797. }
  798. axios.post('/i/delete', {
  799. type: 'status',
  800. item: status.id
  801. }).then(res => {
  802. this.timeline.splice(index,1);
  803. swal('Success', 'You have successfully deleted this post', 'success');
  804. }).catch(err => {
  805. swal('Error', 'Something went wrong. Please try again later.', 'error');
  806. });
  807. },
  808. commentSubmit(status, $event) {
  809. if($('body').hasClass('loggedIn') == false) {
  810. return;
  811. }
  812. let id = status.id;
  813. let form = $event.target;
  814. let input = $(form).find('input[name="comment"]');
  815. let comment = input.val();
  816. let comments = form.parentElement.parentElement.getElementsByClassName('comments')[0];
  817. axios.post('/i/comment', {
  818. item: id,
  819. comment: comment
  820. }).then(res => {
  821. input.val('');
  822. input.blur();
  823. let username = document.createElement('a');
  824. username.classList.add('font-weight-bold');
  825. username.classList.add('text-dark');
  826. username.classList.add('mr-2');
  827. username.setAttribute('href', this.user.url);
  828. username.textContent = this.user.username;
  829. let text = document.createElement('span');
  830. text.innerHTML = comment;
  831. let wrapper = document.createElement('p');
  832. wrapper.classList.add('read-more');
  833. wrapper.classList.add('mb-0');
  834. wrapper.appendChild(username);
  835. wrapper.appendChild(text);
  836. comments.insertBefore(wrapper, comments.firstChild);
  837. });
  838. },
  839. statusModal(status) {
  840. this.modalStatus = status;
  841. this.$refs.statusModalRef.show();
  842. },
  843. masonryOrientation(status) {
  844. let o = status.media_attachments[0].orientation;
  845. if(!o) {
  846. o = 'square';
  847. }
  848. return o;
  849. },
  850. followProfile() {
  851. if($('body').hasClass('loggedIn') == false) {
  852. return;
  853. }
  854. axios.post('/i/follow', {
  855. item: this.profileId
  856. }).then(res => {
  857. this.$refs.visitorContextMenu.hide();
  858. if(this.relationship.following) {
  859. this.profile.followers_count--;
  860. if(this.profile.locked == true) {
  861. window.location.href = '/';
  862. }
  863. } else {
  864. this.profile.followers_count++;
  865. }
  866. this.relationship.following = !this.relationship.following;
  867. });
  868. },
  869. followingModal() {
  870. if($('body').hasClass('loggedIn') == false) {
  871. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  872. return;
  873. }
  874. if(this.profileSettings.following.list == false) {
  875. return;
  876. }
  877. if(this.following.length > 0) {
  878. this.$refs.followingModal.show();
  879. return;
  880. }
  881. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  882. params: {
  883. page: this.followingCursor
  884. }
  885. })
  886. .then(res => {
  887. this.following = res.data;
  888. this.followingCursor++;
  889. if(res.data.length < 10) {
  890. this.followingMore = false;
  891. }
  892. });
  893. this.$refs.followingModal.show();
  894. },
  895. followersModal() {
  896. if($('body').hasClass('loggedIn') == false) {
  897. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  898. return;
  899. }
  900. if(this.profileSettings.followers.list == false) {
  901. return;
  902. }
  903. if(this.followers.length > 0) {
  904. this.$refs.followerModal.show();
  905. return;
  906. }
  907. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  908. params: {
  909. page: this.followerCursor
  910. }
  911. })
  912. .then(res => {
  913. this.followers = res.data;
  914. this.followerCursor++;
  915. if(res.data.length < 10) {
  916. this.followerMore = false;
  917. }
  918. })
  919. this.$refs.followerModal.show();
  920. },
  921. followingLoadMore() {
  922. if($('body').hasClass('loggedIn') == false) {
  923. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  924. return;
  925. }
  926. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  927. params: {
  928. page: this.followingCursor
  929. }
  930. })
  931. .then(res => {
  932. if(res.data.length > 0) {
  933. this.following.push(...res.data);
  934. this.followingCursor++;
  935. }
  936. if(res.data.length < 10) {
  937. this.followingMore = false;
  938. }
  939. });
  940. },
  941. followersLoadMore() {
  942. if($('body').hasClass('loggedIn') == false) {
  943. return;
  944. }
  945. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  946. params: {
  947. page: this.followerCursor
  948. }
  949. })
  950. .then(res => {
  951. if(res.data.length > 0) {
  952. this.followers.push(...res.data);
  953. this.followerCursor++;
  954. }
  955. if(res.data.length < 10) {
  956. this.followerMore = false;
  957. }
  958. });
  959. },
  960. visitorMenu() {
  961. if($('body').hasClass('loggedIn') == false) {
  962. return;
  963. }
  964. this.$refs.visitorContextMenu.show();
  965. }
  966. }
  967. }
  968. </script>