2018-11-04 04:09:51 +00:00
|
|
|
<template>
|
2019-08-06 03:39:11 +00:00
|
|
|
<div>
|
|
|
|
<div v-if="!loaded" style="height: 70vh;" class="d-flex justify-content-center align-items-center">
|
|
|
|
<img src="/img/pixelfed-icon-grey.svg">
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2021-02-06 04:20:19 +00:00
|
|
|
<div v-if="authenticated" class="d-block d-md-none border-top-0 pt-3">
|
2020-08-14 00:05:36 +00:00
|
|
|
<input class="form-control rounded-pill shadow-sm" placeholder="Search" v-model="searchTerm" v-on:keyup.enter="searchSubmit">
|
2019-11-26 04:29:50 +00:00
|
|
|
</div>
|
2020-08-14 00:05:36 +00:00
|
|
|
|
2021-01-31 07:49:40 +00:00
|
|
|
<section class="mt-3 mb-5 section-explore">
|
2019-08-06 03:39:11 +00:00
|
|
|
<div class="profile-timeline">
|
2019-11-24 22:53:24 +00:00
|
|
|
<div class="row p-0 mt-5">
|
2020-08-14 00:05:36 +00:00
|
|
|
<div class="col-12 mb-3 d-flex justify-content-between align-items-center">
|
|
|
|
<p class="d-block d-md-none h1 font-weight-bold mb-0">Trending</p>
|
|
|
|
<p class="d-none d-md-block display-4 font-weight-bold mb-0">Trending</p>
|
|
|
|
<div>
|
|
|
|
<div class="btn-group">
|
|
|
|
<button @click="trendingRangeToggle('daily')" :class="trendingRange == 'daily' ? 'btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-danger':'btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-outline-danger'">Daily</button>
|
|
|
|
<button @click="trendingRangeToggle('monthly')" :class="trendingRange == 'monthly' ? 'btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-danger':'btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-outline-danger'">Monthly</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
<div v-if="!trendingLoading" class="row p-0 d-flex">
|
|
|
|
<div v-if="trending.length" v-for="(s, index) in trending.slice(0, 12)" class="col-4 p-1 p-sm-2 p-md-3 pt-0">
|
2021-01-31 04:56:50 +00:00
|
|
|
<a class="card info-overlay card-md-border-0" :href="s.url">
|
2020-08-14 00:05:36 +00:00
|
|
|
<div class="square">
|
2021-01-31 04:56:50 +00:00
|
|
|
<div v-if="s.sensitive" class="square-content">
|
|
|
|
<div class="info-overlay-text-label">
|
|
|
|
<h5 class="text-white m-auto font-weight-bold">
|
|
|
|
<span>
|
|
|
|
<span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
|
|
|
|
</span>
|
|
|
|
</h5>
|
|
|
|
</div>
|
|
|
|
<blur-hash-canvas
|
|
|
|
width="32"
|
|
|
|
height="32"
|
|
|
|
:hash="s.media_attachments[0].blurhash"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-else class="square-content">
|
|
|
|
|
|
|
|
<blur-hash-image
|
|
|
|
width="32"
|
|
|
|
height="32"
|
|
|
|
:hash="s.media_attachments[0].blurhash"
|
|
|
|
:src="s.media_attachments[0].preview_url"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
|
|
|
|
<span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
|
|
|
|
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
|
|
|
|
<div class="info-overlay-text">
|
|
|
|
<h5 class="text-white m-auto font-weight-bold">
|
|
|
|
<span>
|
|
|
|
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
|
|
|
|
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
|
|
|
|
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
|
|
|
|
</span>
|
|
|
|
</h5>
|
2020-08-14 00:05:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
<div v-else class="col-12 d-flex align-items-center justify-content-center bg-light border" style="min-height: 40vh;">
|
|
|
|
<div class="h2">No posts found :(</div>
|
2020-08-14 00:05:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
<div v-else class="row d-flex align-items-center justify-content-center bg-light border" style="min-height: 40vh;">
|
|
|
|
<div class="spinner-border" role="status">
|
|
|
|
<span class="sr-only">Loading...</span>
|
2020-08-14 00:05:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-01-31 07:49:40 +00:00
|
|
|
|
2021-02-06 04:20:19 +00:00
|
|
|
<section v-if="authenticated" class="pt-5 mb-5 section-explore">
|
2020-08-14 00:05:36 +00:00
|
|
|
<div class="profile-timeline pt-3">
|
|
|
|
<div class="row p-0 mt-5">
|
|
|
|
<div class="col-12 mb-3 d-flex justify-content-between align-items-center">
|
|
|
|
<p class="d-block d-md-none h1 font-weight-bold mb-0">For You</p>
|
|
|
|
<p class="d-none d-md-block display-4 font-weight-bold mb-0">For You</p>
|
2019-11-24 22:53:24 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
<div v-if="!recommendedLoading" class="row p-0 d-flex">
|
|
|
|
<div v-if="posts.length" v-for="(s, index) in posts" :key="'rmki:'+index" class="col-4 p-1 p-sm-2 p-md-3 pt-0">
|
2021-01-31 04:56:50 +00:00
|
|
|
<a class="card info-overlay card-md-border-0" :href="s.url">
|
2019-08-06 03:39:11 +00:00
|
|
|
<div class="square">
|
2021-01-31 04:56:50 +00:00
|
|
|
<div v-if="s.sensitive" class="square-content">
|
|
|
|
<div class="info-overlay-text-label">
|
|
|
|
<h5 class="text-white m-auto font-weight-bold">
|
|
|
|
<span>
|
|
|
|
<span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
|
|
|
|
</span>
|
|
|
|
</h5>
|
|
|
|
</div>
|
|
|
|
<blur-hash-canvas
|
|
|
|
width="32"
|
|
|
|
height="32"
|
|
|
|
:hash="s.media_attachments[0].blurhash"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-else class="square-content">
|
|
|
|
|
|
|
|
<blur-hash-image
|
|
|
|
width="32"
|
|
|
|
height="32"
|
|
|
|
:hash="s.media_attachments[0].blurhash"
|
|
|
|
:src="s.media_attachments[0].preview_url"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
|
|
|
|
<span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
|
|
|
|
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
|
|
|
|
<div class="info-overlay-text">
|
|
|
|
<h5 class="text-white m-auto font-weight-bold">
|
|
|
|
<span>
|
|
|
|
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
|
|
|
|
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
|
|
|
|
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
|
|
|
|
</span>
|
|
|
|
</h5>
|
2019-08-06 03:39:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
<div v-else class="col-12 d-flex align-items-center justify-content-center bg-light border" style="min-height: 40vh;">
|
|
|
|
<div class="h2">No posts found :(</div>
|
2020-08-14 00:05:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
<div v-else class="row d-flex align-items-center justify-content-center bg-light border" style="min-height: 40vh;">
|
|
|
|
<div class="spinner-border" role="status">
|
|
|
|
<span class="sr-only">Loading...</span>
|
2020-08-14 00:05:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-31 07:49:40 +00:00
|
|
|
</section>
|
2019-08-06 03:39:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-04 04:09:51 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2019-08-06 03:39:11 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-02-06 04:20:19 +00:00
|
|
|
authenticated: false,
|
2019-08-06 03:39:11 +00:00
|
|
|
loaded: false,
|
|
|
|
config: window.App.config,
|
|
|
|
posts: {},
|
|
|
|
trending: {},
|
2020-08-14 00:05:36 +00:00
|
|
|
trendingDaily: {},
|
|
|
|
trendingMonthly: {},
|
2019-08-06 03:39:11 +00:00
|
|
|
searchTerm: '',
|
2021-01-31 07:49:40 +00:00
|
|
|
trendingRange: 'daily',
|
|
|
|
trendingLoading: true,
|
|
|
|
recommendedLoading: true
|
2019-08-06 03:39:11 +00:00
|
|
|
}
|
|
|
|
},
|
2021-02-06 04:20:19 +00:00
|
|
|
|
|
|
|
beforeMount() {
|
|
|
|
this.authenticated = $('body').hasClass('loggedIn');
|
|
|
|
},
|
|
|
|
|
2019-08-06 03:39:11 +00:00
|
|
|
mounted() {
|
2021-01-31 07:49:40 +00:00
|
|
|
this.loaded = true;
|
2020-08-14 00:05:36 +00:00
|
|
|
this.loadTrending();
|
2021-02-06 04:20:19 +00:00
|
|
|
if($('body').hasClass('loggedIn') == true) {
|
|
|
|
this.fetchData();
|
|
|
|
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
|
|
|
|
window._sharedData.curUser = res.data;
|
|
|
|
window.App.util.navatar();
|
|
|
|
});
|
|
|
|
}
|
2019-08-06 03:39:11 +00:00
|
|
|
},
|
2018-11-27 09:17:27 +00:00
|
|
|
|
2019-08-06 03:39:11 +00:00
|
|
|
methods: {
|
|
|
|
fetchData() {
|
2021-01-31 07:49:40 +00:00
|
|
|
if(!this.recommendedLoading) {
|
|
|
|
return;
|
|
|
|
}
|
2019-09-27 01:45:06 +00:00
|
|
|
axios.get('/api/pixelfed/v2/discover/posts')
|
2019-08-06 03:39:11 +00:00
|
|
|
.then((res) => {
|
2021-02-06 04:20:19 +00:00
|
|
|
this.posts = res.data.posts.filter(r => r != null);
|
2021-01-31 07:49:40 +00:00
|
|
|
this.recommendedLoading = false;
|
2019-08-06 03:39:11 +00:00
|
|
|
});
|
|
|
|
},
|
2019-02-11 04:34:12 +00:00
|
|
|
|
2019-08-06 03:39:11 +00:00
|
|
|
searchSubmit() {
|
|
|
|
if(this.searchTerm.length > 1) {
|
|
|
|
window.location.href = '/i/results?q=' + this.searchTerm;
|
|
|
|
}
|
2020-08-14 00:05:36 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
loadTrending() {
|
|
|
|
if(this.trendingRange == 'daily' && this.trendingDaily.length) {
|
|
|
|
this.trending = this.trendingDaily;
|
2021-01-31 07:49:40 +00:00
|
|
|
this.trendingLoading = false;
|
2020-08-14 00:05:36 +00:00
|
|
|
}
|
|
|
|
if(this.trendingRange == 'monthly' && this.trendingMonthly.length) {
|
|
|
|
this.trending = this.trendingMonthly;
|
2021-01-31 07:49:40 +00:00
|
|
|
this.trendingLoading = false;
|
2020-08-14 00:05:36 +00:00
|
|
|
}
|
|
|
|
axios.get('/api/pixelfed/v2/discover/posts/trending', {
|
|
|
|
params: {
|
|
|
|
range: this.trendingRange
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
2021-02-06 04:20:19 +00:00
|
|
|
let data = res.data.filter(r => {
|
|
|
|
return r !== null;
|
|
|
|
});
|
2020-08-14 00:05:36 +00:00
|
|
|
if(this.trendingRange == 'daily') {
|
2021-02-06 04:20:19 +00:00
|
|
|
this.trendingDaily = data.filter(t => t.sensitive == false);
|
2020-08-14 00:05:36 +00:00
|
|
|
}
|
|
|
|
if(this.trendingRange == 'monthly') {
|
2021-02-06 04:20:19 +00:00
|
|
|
this.trendingMonthly = data.filter(t => t.sensitive == false);
|
2020-08-14 00:05:36 +00:00
|
|
|
}
|
2021-02-06 04:20:19 +00:00
|
|
|
this.trending = data;
|
2021-01-31 07:49:40 +00:00
|
|
|
this.trendingLoading = false;
|
2020-08-14 00:05:36 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
trendingRangeToggle(r) {
|
2021-01-31 07:49:40 +00:00
|
|
|
this.trendingLoading = true;
|
2020-08-14 00:05:36 +00:00
|
|
|
this.trendingRange = r;
|
|
|
|
this.loadTrending();
|
|
|
|
},
|
|
|
|
|
2021-01-31 04:56:50 +00:00
|
|
|
formatCount(s) {
|
|
|
|
return App.util.format.count(s);
|
2019-08-06 03:39:11 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-04 04:09:51 +00:00
|
|
|
}
|
2019-08-06 03:39:11 +00:00
|
|
|
</script>
|