pixelfed/public/js/discover.js

1 line
9.5 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{"+nCD":function(t,e,n){Vue.component("discover-component",n("RlRG").default)},3:function(t,e,n){t.exports=n("+nCD")},"KHd+":function(t,e,n){"use strict";function s(t,e,n,s,i,a,o,r){var l,d="function"==typeof t?t.options:t;if(e&&(d.render=e,d.staticRenderFns=n,d._compiled=!0),s&&(d.functional=!0),a&&(d._scopeId="data-v-"+a),o?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},d._ssrRegister=l):i&&(l=r?function(){i.call(this,(d.functional?this.parent:this).$root.$options.shadowRoot)}:i),l)if(d.functional){d._injectStyles=l;var c=d.render;d.render=function(t,e){return l.call(e),c(t,e)}}else{var h=d.beforeCreate;d.beforeCreate=h?[].concat(h,l):[l]}return{exports:t,options:d}}n.d(e,"a",(function(){return s}))},RlRG:function(t,e,n){"use strict";n.r(e);var s={data:function(){return{authenticated:!1,loaded:!1,config:window.App.config,posts:{},trending:{},trendingDaily:{},trendingMonthly:{},searchTerm:"",trendingRange:"daily",trendingLoading:!0,recommendedLoading:!0}},beforeMount:function(){this.authenticated=$("body").hasClass("loggedIn")},mounted:function(){this.loaded=!0,this.loadTrending(),1==$("body").hasClass("loggedIn")&&(this.fetchData(),axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()})))},methods:{fetchData:function(){var t=this;this.recommendedLoading&&axios.get("/api/pixelfed/v2/discover/posts").then((function(e){t.posts=e.data.posts.filter((function(t){return null!=t})),t.recommendedLoading=!1}))},searchSubmit:function(){this.searchTerm.length>1&&(window.location.href="/i/results?q="+this.searchTerm)},loadTrending:function(){var t=this;"daily"==this.trendingRange&&this.trendingDaily.length&&(this.trending=this.trendingDaily,this.trendingLoading=!1),"monthly"==this.trendingRange&&this.trendingMonthly.length&&(this.trending=this.trendingMonthly,this.trendingLoading=!1),axios.get("/api/pixelfed/v2/discover/posts/trending",{params:{range:this.trendingRange}}).then((function(e){var n=e.data.filter((function(t){return null!==t}));"daily"==t.trendingRange&&(t.trendingDaily=n.filter((function(t){return 0==t.sensitive}))),"monthly"==t.trendingRange&&(t.trendingMonthly=n.filter((function(t){return 0==t.sensitive}))),t.trending=n,t.trendingLoading=!1}))},trendingRangeToggle:function(t){this.trendingLoading=!0,this.trendingRange=t,this.loadTrending()},formatCount:function(t){return App.util.format.count(t)}}},i=n("KHd+"),a=Object(i.a)(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t.loaded?n("div",[t.authenticated?n("div",{staticClass:"d-block d-md-none border-top-0 pt-3"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.searchTerm,expression:"searchTerm"}],staticClass:"form-control rounded-pill shadow-sm",attrs:{placeholder:"Search"},domProps:{value:t.searchTerm},on:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.searchSubmit(e)},input:function(e){e.target.composing||(t.searchTerm=e.target.value)}}})]):t._e(),t._v(" "),n("section",{staticClass:"mt-3 mb-5 section-explore"},[n("div",{staticClass:"profile-timeline"},[n("div",{staticClass:"row p-0 mt-5"},[n("div",{staticClass:"col-12 mb-3 d-flex justify-content-between align-items-center"},[n("p",{staticClass:"d-block d-md-none h1 font-weight-bold mb-0"},[t._v("Trending")]),t._v(" "),n("p",{staticClass:"d-none d-md-block display-4 font-weight-bold mb-0"},[t._v("Trending")]),t._v(" "),n("div",[n("div",{staticClass:"btn-group"},[n("button",{class:"daily"==t.trendingRange?"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",on:{click:function(e){return t.trendingRangeToggle("daily")}}},[t._v("Daily")]),t._v(" "),n("button",{class:"monthly"==t.trendingRange?"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",on:{click:function(e){return t.trendingRangeToggle("monthly")}}},[t._v("Monthly")])])])])]),t._v(" "),t.trendingLoading?n("div",{staticClass:"row d-flex align-items-center justify-content-center bg-light border",staticStyle:{"min-height":"40vh"}},[t._m(1)]):n("div",{staticClass:"row p-0 d-flex"},t._l(t.trending.slice(0,12),(function(e,s){return t.trending.length?n("div",{staticClass:"col-4 p-1 p-sm-2 p-md-3 pt-0"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.url}},[n("div",{staticClass:"square"},[e.sensitive?n("div",{staticClass:"square-content"},[t._m(0,!0),t._v(" "),n("blur-hash-canvas",{attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash}})],1):n("div",{staticClass:"square-content"},[n("blur-hash-image",{attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash,src:e.media_attachments[0].preview_url}})],1),t._v(" "),"photo:album"==e.pf_type?n("span",{staticClass:"float-right mr-3 post-icon"},[n("i",{staticClass:"fas fa-images fa-2x"})]):t._e(),t._v(" "),"video"==e.pf_type?n("span",{staticClass:"float-right mr-3 post-icon"},[n("i",{staticClass:"fas fa-video fa-2x"})]):t._e(),t._v(" "),"video:album"==e.pf_type?n("span",{staticClass:"float-right mr-3 post-icon"},[n("i",{staticClass:"fas fa-film fa-2x"})]):t._e(),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",[n("span",{staticClass:"far fa-heart fa-lg p-2 d-flex-inline"}),t._v(" "),n("span",{staticClass:"d-flex-inline"},[t._v(t._s(t.formatCount(e.favourites_count)))])]),t._v(" "),n("span",[n("span",{staticClass:"far fa-comment fa-lg p-2 d-flex-inline"}),t._v(" "),n("span",{staticClass:"d-flex-inline"},[t._v(t._s(t.formatCount(e.reply_count)))])])])])])])]):n("div",{staticClass:"col-12 d-flex align-items-center justify-content-center bg-light border",staticStyle:{"min-height":"40vh"}},[n("div",{staticClass:"h2"},[t._v("No posts found :(")])])})),0)])]),t._v(" "),t.authenticated?n("section",{staticClass:"pt-5 mb-5 section-explore"},[n("div",{staticClass:"profile-timeline pt-3"},[t._m(2),t._v(" "),t.recommendedLoading?n("div",{staticClass:"row d-flex align-items-center justify-content-center bg-light border",staticStyle:{"min-height":"40vh"}},[t._m(4)]):n("div",{staticClass:"row p-0 d-flex"},t._l(t.posts,(function(e,s){return t.posts.length?n("div",{key:"rmki:"+s,staticClass:"col-4 p-1 p-sm-2 p-md-3 pt-0"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.url}},[n("div",{staticClass:"square"},[e.sensitive?n("div",{staticClass:"square-content"},[t._m(3,!0),t._v(" "),n("blur-hash-canvas",{attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash}})],1):n("div",{staticClass:"square-content"},[n("blur-hash-image",{attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash,src:e.media_attachments[0].preview_url}})],1),t._v(" "),"photo:album"==e.pf_type?n("span",{staticClass:"float-right mr-3 post-icon"},[n("i",{staticClass:"fas fa-images fa-2x"})]):t._e(),t._v(" "),"video"==e.pf_type?n("span",{staticClass:"float-right mr-3 post-icon"},[n("i",{staticClass:"fas fa-video fa-2x"})]):t._e(),t._v(" "),"video:album"==e.pf_type?n("span",{staticClass:"float-right mr-3 post-icon"},[n("i",{staticClass:"fas fa-film fa-2x"})]):t._e(),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",[n("span",{staticClass:"far fa-heart fa-lg p-2 d-flex-inline"}),t._v(" "),n("span",{staticClass:"d-flex-inline"},[t._v(t._s(t.formatCount(e.favourites_count)))])]),t._v(" "),n("span",[n("span",{staticClass:"far fa-comment fa-lg p-2 d-flex-inline"}),t._v(" "),n("span",{staticClass:"d-flex-inline"},[t._v(t._s(t.formatCount(e.reply_count)))])])])])])])]):n("div",{staticClass:"col-12 d-flex align-items-center justify-content-center bg-light border",staticStyle:{"min-height":"40vh"}},[n("div",{staticClass:"h2"},[t._v("No posts found :(")])])})),0)])]):t._e()]):n("div",{staticClass:"d-flex justify-content-center align-items-center",staticStyle:{height:"70vh"}},[n("img",{attrs:{src:"/img/pixelfed-icon-grey.svg"}})])])}),[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"info-overlay-text-label"},[e("h5",{staticClass:"text-white m-auto font-weight-bold"},[e("span",[e("span",{staticClass:"far fa-eye-slash fa-lg p-2 d-flex-inline"})])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"spinner-border",attrs:{role:"status"}},[e("span",{staticClass:"sr-only"},[this._v("Loading...")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"row p-0 mt-5"},[e("div",{staticClass:"col-12 mb-3 d-flex justify-content-between align-items-center"},[e("p",{staticClass:"d-block d-md-none h1 font-weight-bold mb-0"},[this._v("For You")]),this._v(" "),e("p",{staticClass:"d-none d-md-block display-4 font-weight-bold mb-0"},[this._v("For You")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"info-overlay-text-label"},[e("h5",{staticClass:"text-white m-auto font-weight-bold"},[e("span",[e("span",{staticClass:"far fa-eye-slash fa-lg p-2 d-flex-inline"})])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"spinner-border",attrs:{role:"status"}},[e("span",{staticClass:"sr-only"},[this._v("Loading...")])])}],!1,null,null,null);e.default=a.exports}},[[3,0]]]);