Discover.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <div class="web-wrapper">
  3. <div v-if="isLoaded" class="container-fluid mt-3">
  4. <div class="row">
  5. <div class="col-md-4 col-lg-3">
  6. <sidebar :user="profile" />
  7. </div>
  8. <div v-if="tab == 'index'" class="col-md-8 col-lg-9 mt-n4">
  9. <div v-if="profile.is_admin" class="d-md-flex my-md-3">
  10. <grid-card
  11. :dark="true"
  12. :title="'Hello ' + profile.username"
  13. subtitle="Welcome to the new Discover experience! Only admins can see this"
  14. button-text="Manage Discover Settings"
  15. button-link="/i/web/discover/settings"
  16. icon-class="fal fa-cog"
  17. :small="true" />
  18. </div>
  19. <!-- <section class="mb-1 mb-md-3 mb-lg-4">
  20. <news-slider />
  21. </section> -->
  22. <!-- <discover-spotlight /> -->
  23. <!-- <div class="d-md-flex my-md-3">
  24. <grid-card
  25. :dark="true"
  26. title="The Not So Trending"
  27. subtitle="Explore the posts that deserve more attention"
  28. button-text="Explore posts"
  29. icon-class="fal fa-analytics"
  30. button-link="/i/web/discover/future-trending"
  31. :button-event="true"
  32. v-on:btn-click="toggleTab('trending')"
  33. :small="true" />
  34. <grid-card
  35. title="Behind The Posts"
  36. subtitle="Discover the people"
  37. button-text="Discover People"
  38. button-link="/i/web/discover/people"
  39. icon-class="fal fa-user-friends"
  40. :small="true" />
  41. </div> -->
  42. <daily-trending v-on:btn-click="toggleTab('trending')"/>
  43. <!-- <div class="d-md-flex my-md-3">
  44. <grid-card
  45. title="Explore Loops"
  46. subtitle="Loops are short, looping videos"
  47. button-text="Explore Loops"
  48. icon-class="fal fa-camcorder"
  49. button-link="/i/web/discover/loops"
  50. :small="false" />
  51. <grid-card
  52. :dark="true"
  53. title="Popular Places"
  54. subtitle="Explore posts by popular locations"
  55. button-text="Explore Popular Places"
  56. icon-class="fal fa-map"
  57. :button-event="true"
  58. v-on:btn-click="toggleTab('popular-places')"
  59. button-link="/i/web/discover/popular-places"
  60. :small="false" />
  61. </div> -->
  62. <div class="d-md-flex my-md-3">
  63. <grid-card
  64. v-if="config.hashtags.enabled"
  65. :dark="true"
  66. title="My Hashtags"
  67. subtitle="Explore posts tagged with hashtags you follow"
  68. button-text="Explore Posts"
  69. button-link="/i/web/discover/my-hashtags"
  70. icon-class="fal fa-hashtag"
  71. :small="false" />
  72. <grid-card
  73. v-if="config.memories.enabled"
  74. title="My Memories"
  75. subtitle="A distant look back"
  76. button-text="View Memories"
  77. button-link="/i/web/discover/my-memories"
  78. icon-class="fal fa-history"
  79. :small="false" />
  80. </div>
  81. <div class="d-md-flex my-md-3">
  82. <grid-card
  83. v-if="config.insights.enabled"
  84. title="Account Insights"
  85. subtitle="Get a rich overview of your account activity and interactions"
  86. button-text="View Account Insights"
  87. icon-class="fal fa-user-circle"
  88. button-link="/i/web/discover/account-insights"
  89. :small="false" />
  90. <grid-card
  91. v-if="config.friends.enabled"
  92. :dark="true"
  93. title="Find Friends"
  94. subtitle="Find accounts to follow based on common interests"
  95. button-text="Find Friends & Followers"
  96. button-link="/i/web/discover/find-friends"
  97. icon-class="fal fa-user-plus"
  98. :small="false" />
  99. </div>
  100. <div class="d-md-flex my-md-3">
  101. <grid-card
  102. v-if="config.server.enabled && config.server.domains && config.server.domains.length"
  103. :dark="true"
  104. title="Server Timelines"
  105. subtitle="Browse timelines of a specific remote instance"
  106. button-text="Browse Server Feeds"
  107. icon-class="fal fa-list"
  108. button-link="/i/web/discover/server-timelines"
  109. :small="false" />
  110. <!-- <grid-card
  111. title="Curate the Spotlight"
  112. subtitle="Apply to curate the spotlight for one week"
  113. button-text="Apply to Curate Spotlight"
  114. button-link="/i/web/discover/spotlight/curate/apply"
  115. icon-class="fal fa-thumbs-up"
  116. :small="false" /> -->
  117. </div>
  118. </div>
  119. <div v-else-if="tab == 'trending'" class="col-md-8 col-lg-9 mt-n4">
  120. <discover :profile="profile" />
  121. </div>
  122. <div v-else-if="tab == 'popular-places'" class="col-md-8 col-lg-9 mt-n4">
  123. <section class="mt-3 mb-5 section-explore">
  124. <div class="profile-timeline">
  125. <div class="row p-0 mt-5">
  126. <div class="col-12 mb-4 d-flex justify-content-between align-items-center">
  127. <p class="d-block d-md-none h1 font-weight-bold mb-0 font-default">Popular Places</p>
  128. <p class="d-none d-md-block display-4 font-weight-bold mb-0 font-default">Popular Places</p>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="row mt-5">
  133. <div class="col-12 col-md-12 mb-3">
  134. <div class="card-img big">
  135. <img src="/img/places/nyc.jpg">
  136. <div class="title font-default">New York City</div>
  137. </div>
  138. </div>
  139. <div class="col-12 col-md-6 mb-3">
  140. <div class="card-img">
  141. <img src="/img/places/edmonton.jpg">
  142. <div class="title font-default">Edmonton</div>
  143. </div>
  144. </div>
  145. <div class="col-12 col-md-6 mb-3">
  146. <div class="card-img">
  147. <img src="/img/places/paris.jpg">
  148. <div class="title font-default">Paris</div>
  149. </div>
  150. </div>
  151. <div class="col-12 col-md-4 mb-3">
  152. <div class="card-img">
  153. <img src="/img/places/london.jpg">
  154. <div class="title font-default">London</div>
  155. </div>
  156. </div>
  157. <div class="col-12 col-md-4 mb-3">
  158. <div class="card-img">
  159. <img src="/img/places/vancouver.jpg">
  160. <div class="title font-default">Vancouver</div>
  161. </div>
  162. </div>
  163. <div class="col-12 col-md-4 mb-3">
  164. <div class="card-img">
  165. <img src="/img/places/toronto.jpg">
  166. <div class="title font-default">Toronto</div>
  167. </div>
  168. </div>
  169. </div>
  170. </section>
  171. </div>
  172. </div>
  173. <drawer />
  174. </div>
  175. </div>
  176. </template>
  177. <script type="text/javascript">
  178. import Drawer from './partials/drawer.vue';
  179. import Sidebar from './partials/sidebar.vue';
  180. import Rightbar from './partials/rightbar.vue';
  181. import Discover from './sections/DiscoverFeed.vue';
  182. import DiscoverNewsSlider from './partials/discover/news-slider.vue';
  183. import DiscoverSpotlight from './partials/discover/discover-spotlight.vue';
  184. import DailyTrending from './partials/discover/daily-trending.vue';
  185. import DiscoverGridCard from './partials/discover/grid-card.vue';
  186. export default {
  187. components: {
  188. "drawer": Drawer,
  189. "sidebar": Sidebar,
  190. "rightbar": Rightbar,
  191. "discover": Discover,
  192. "news-slider": DiscoverNewsSlider,
  193. "discover-spotlight": DiscoverSpotlight,
  194. "daily-trending": DailyTrending,
  195. "grid-card": DiscoverGridCard
  196. },
  197. data() {
  198. return {
  199. isLoaded: false,
  200. profile: undefined,
  201. config: {},
  202. tab: 'index',
  203. popularAccounts: [],
  204. followingIndex: undefined
  205. }
  206. },
  207. updated() {
  208. // let u = new URLSearchParams(window.location.search);
  209. // if(u.has('ft') && u.get('ft') == '1') {
  210. // this.tab = 'index';
  211. // }
  212. },
  213. mounted() {
  214. this.profile = window._sharedData.user;
  215. this.fetchConfig();
  216. },
  217. methods: {
  218. fetchConfig() {
  219. axios.get('/api/pixelfed/v2/discover/meta')
  220. .then(res => {
  221. this.config = res.data;
  222. this.isLoaded = true;
  223. window._sharedData.discoverMeta = res.data;
  224. // this.fetchPopularAccounts();
  225. })
  226. },
  227. fetchPopularAccounts() {
  228. // axios.get('/api/pixelfed/discover/accounts/popular')
  229. // .then(res => {
  230. // this.popularAccounts = res.data;
  231. // })
  232. },
  233. followProfile(index) {
  234. event.currentTarget.blur();
  235. this.followingIndex = index;
  236. let id = this.popularAccounts[index].id;
  237. axios.post('/api/v1/accounts/' + id + '/follow')
  238. .then(res => {
  239. this.followingIndex = undefined;
  240. this.popularAccounts.splice(index, 1);
  241. }).catch(err => {
  242. this.followingIndex = undefined;
  243. swal('Oops!', 'An error occured when attempting to follow this account.', 'error');
  244. });
  245. },
  246. goToProfile(account) {
  247. this.$router.push({
  248. path: `/i/web/profile/${account.id}`,
  249. params: {
  250. id: account.id,
  251. cachedProfile: account,
  252. cachedUser: this.profile
  253. }
  254. })
  255. },
  256. toggleTab(index) {
  257. this.tab = index;
  258. setTimeout(() => {
  259. window.scrollTo({top: 0, behavior: 'smooth'});
  260. }, 300);
  261. },
  262. openManageModal() {
  263. event.currentTarget.blur();
  264. swal('Settings', 'Discover settings here', 'info');
  265. }
  266. }
  267. }
  268. </script>
  269. <style lang="scss" scoped>
  270. .card-img {
  271. position: relative;
  272. img {
  273. object-fit: cover;
  274. width: 100%;
  275. height: 200px;
  276. border-radius: 10px;
  277. }
  278. &:before,
  279. &:after {
  280. content: "";
  281. background: rgba(0,0,0,0.2);
  282. z-index: 2;
  283. width: 100%;
  284. height: 100%;
  285. position: absolute;
  286. left: 0;
  287. top: 0;
  288. border-radius: 10px;
  289. }
  290. .title {
  291. position: absolute;
  292. bottom: 5px;
  293. left: 10px;
  294. font-size: 40px;
  295. color: #fff;
  296. z-index: 3;
  297. font-weight: 700;
  298. }
  299. &.big {
  300. img {
  301. height: 300px;
  302. }
  303. }
  304. }
  305. .font-default {
  306. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  307. letter-spacing: -0.7px;
  308. }
  309. .bg-stellar {
  310. background: #7474BF;
  311. background: -webkit-linear-gradient(to right, #348AC7, #7474BF);
  312. background: linear-gradient(to right, #348AC7, #7474BF);
  313. }
  314. .bg-berry {
  315. background: #5433FF;
  316. background: -webkit-linear-gradient(to right, #acb6e5, #86fde8);
  317. background: linear-gradient(to right, #acb6e5, #86fde8);
  318. }
  319. .bg-midnight {
  320. background: #232526;
  321. background: -webkit-linear-gradient(to right, #414345, #232526);
  322. background: linear-gradient(to right, #414345, #232526);
  323. }
  324. .media-body {
  325. margin-right: 0.5rem;
  326. }
  327. .avatar {
  328. border-radius: 15px;
  329. }
  330. .username {
  331. font-size: 14px;
  332. line-height: 14px;
  333. margin-bottom: 2px;
  334. word-break: break-word !important;
  335. word-wrap: break-word !important;
  336. }
  337. .display-name {
  338. margin-bottom: 0;
  339. font-size: 12px;
  340. word-break: break-word !important;
  341. word-wrap: break-word !important;
  342. }
  343. .follower-count {
  344. margin-bottom: 0;
  345. font-size: 10px;
  346. word-break: break-word !important;
  347. word-wrap: break-word !important;
  348. }
  349. .follow {
  350. background-color: var(--primary);
  351. border-radius: 18px;
  352. font-weight: 600;
  353. padding: 5px 15px;
  354. }
  355. </style>