1
0
Fork 0
pixelfed/public/js/hashtag.js

1 line
15 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{"+fb5":function(t,e,s){var a=s("UNrL");"string"==typeof a&&(a=[[t.i,a,""]]);var n={hmr:!0,transform:void 0,insertInto:void 0};s("aET+")(a,n);a.locals&&(t.exports=a.locals)},16:function(t,e,s){t.exports=s("gqTO")},"9tPo":function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var s=e.protocol+"//"+e.host,a=s+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var n,r=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?t:(n=0===r.indexOf("//")?r:0===r.indexOf("/")?s+r:a+r.replace(/^\.\//,""),"url("+JSON.stringify(n)+")")}))}},I1BE:function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s=function(t,e){var s=t[1]||"",a=t[3];if(!a)return s;if(e&&"function"==typeof btoa){var n=(i=a,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),r=a.sources.map((function(t){return"/*# sourceURL="+a.sourceRoot+t+" */"}));return[s].concat(r).concat([n]).join("\n")}var i;return[s].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+s+"}":s})).join("")},e.i=function(t,s){"string"==typeof t&&(t=[[null,t,""]]);for(var a={},n=0;n<this.length;n++){var r=this[n][0];"number"==typeof r&&(a[r]=!0)}for(n=0;n<t.length;n++){var i=t[n];"number"==typeof i[0]&&a[i[0]]||(s&&!i[2]?i[2]=s:s&&(i[2]="("+i[2]+") and ("+s+")"),e.push(i))}},e}},"KHd+":function(t,e,s){"use strict";function a(t,e,s,a,n,r,i,o){var c,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=s,l._compiled=!0),a&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),i?(c=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__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},l._ssrRegister=c):n&&(c=o?function(){n.call(this,this.$root.$options.shadowRoot)}:n),c)if(l.functional){l._injectStyles=c;var f=l.render;l.render=function(t,e){return c.call(e),f(t,e)}}else{var u=l.beforeCreate;l.beforeCreate=u?[].concat(u,c):[c]}return{exports:t,options:l}}s.d(e,"a",(function(){return a}))},Pvfc:function(t,e,s){"use strict";s.r(e);function a(t){return function(t){if(Array.isArray(t)){for(var e=0,s=new Array(t.length);e<t.length;e++)s[e]=t[e];return s}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var n={props:["hashtag","hashtagCount"],data:function(){return{loaded:!1,page:1,authenticated:!1,following:!1,tags:[],top:[],forceNsfw:!1}},beforeMount:function(){this.authenticated=$("body").hasClass("loggedIn"),this.getResults(),this.hashtagCount=window.App.util.format.count(this.hashtagCount)},methods:{getResults:function(){var t=this;this.authenticated&&axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()})),axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(e){var s=e.data,a=s.tags.filter((function(t){return!(!t||0==t.length)}));t.tags=a,t.loaded=!0,t.following=s.follows,t.page++}))},infiniteLoader:function(t){var e=this;this.page>(this.authenticated?29:10)?t.complete():axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(s){var n=s.data;if(n.tags.length){var r,i=n.tags.filter((function(t){return!(!t||0==t.length)}));if((r=e.tags).push.apply(r,a(i)),i.length>9)return void t.complete();e.page++,t.loaded()}else t.complete()}))},followHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(e){t.following=!0}))},unfollowHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(e){t.following=!1}))}}},r=(s("t3j5"),s("KHd+")),i=Object(r.a)(n,(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",[t.loaded?s("div",{staticClass:"container"},[s("div",{staticClass:"profile-header row my-5"},[t._m(0),t._v(" "),s("div",{staticClass:"col-12 col-md-9 d-flex align-items-center"},[s("div",{staticClass:"profile-details"},[s("div",{staticClass:"username-bar pb-2"},[s("p",{staticClass:"tag-header mb-0"},[t._v("#"+t._s(t.hashtag))]),t._v(" "),s("p",{staticClass:"lead"},[s("span",{staticClass:"font-weight-bold"},[t._v(t._s(t.tags.length?t.hashtagCount:"0"))]),t._v(" posts")]),t._v(" "),s("div",{staticClass:"d-flex justify-content-between align-items-center"},[t.authenticated&&t.tags.length?s("p",{staticClass:"pt-3 mr-4"},[t.following?s("button",{staticClass:"btn btn-outline-secondary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.unfollowHashtag}},[t._v("\n\t\t\t\t\t\t\t\t\tUnfollow\n\t\t\t\t\t\t\t\t")]):s("button",{staticClass:"btn btn-primary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.followHashtag}},[t._v("\n\t\t\t\t\t\t\t\t\tFollow\n\t\t\t\t\t\t\t\t")])]):t._e(),t._v(" "),s("div",{staticClass:"custom-control custom-switch"},[s("input",{directives:[{name:"model",rawName:"v-model",value:t.forceNsfw,expression:"forceNsfw"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"nsfwSwitch"},domProps:{checked:Array.isArray(t.forceNsfw)?t._i(t.forceNsfw,null)>-1:t.forceNsfw},on:{change:function(e){var s=t.forceNsfw,a=e.target,n=!!a.checked;if(Array.isArray(s)){var r=t._i(s,null);a.checked?r<0&&(t.forceNsfw=s.concat([null])):r>-1&&(t.forceNsfw=s.slice(0,r).concat(s.slice(r+1)))}else t.forceNsfw=n}}}),t._v(" "),s("label",{staticClass:"custom-control-label font-weight-bold text-muted",attrs:{for:"nsfwSwitch"}},[t._v("Show NSFW Content")])])])])])])]),t._v(" "),t.tags.length?s("div",{staticClass:"tag-timeline"},[t.top.length?s("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Top Posts")]):t._e(),t._v(" "),s("div",{staticClass:"row pb-5"},t._l(t.top,(function(e,a){return s("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[s("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[s("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[e.status.sensitive&&0==t.forceNsfw?s("div",{staticClass:"square-content"},[t.s.sensitive?s("blur-hash-image",{attrs:{width:"32",height:"32",punch:"1",hash:e.status.media_attachments[0].blurhash}}):t._e()],1):s("div",{staticClass:"square-content",style:"background-image: url("+e.status.media_attachments[0].preview_url+")"}),t._v(" "),s("div",{staticClass:"info-overlay-text"},[s("h5",{staticClass:"text-white m-auto font-weight-bold"},[s("span",{staticClass:"pr-4"},[s("span",{staticClass:"far fa-heart fa-lg pr-1"}),t._v(" "+t._s(e.status.like_count)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),s("span",[s("span",{staticClass:"fas fa-retweet fa-lg pr-1"}),t._v(" "+t._s(e.status.share_count)+"\n\t\t\t\t\t\t\t\t\t")])])])])])])})),0),t._v(" "),s("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Most Recent")]),t._v(" "),s("div",{staticClass:"row"},[t._l(t.tags,(function(e,a){return s("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[s("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[s("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[e.status.sensitive&&0==t.forceNsfw?s("div",{staticClass:"square-content"},[t._m(1,!0),t._v(" "),s("blur-hash-canvas",{attrs:{width:"32",height:"32",hash:e.status.media_attachments[0].blurhash}})],1):s("div",{staticClass:"square-content"},[s("blur-hash-image",{attrs:{width:"32",height:"32",hash:e.status.media_attachments[0].blurhash,src:e.status.media_attachments[0].preview_url}})],1),t._v(" "),"photo:album"==e.status.pf_type?s("span",{staticClass:"float-right mr-3 post-icon"},[s("i",{staticClass:"fas fa-images fa-2x"})]):t._e(),t._v(" "),"video"==e.status.pf_type?s("span",{staticClass:"float-right mr-3 post-icon"},[s("i",{staticClass:"fas fa-video fa-2x"})]):t._e(),t._v(" "),"video:album"==e.status.pf_type?s("span",{staticClass:"float-right mr-3 post-icon"},[s("i",{staticClass:"fas fa-film fa-2x"})]):t._e(),t._v(" "),s("div",{staticClass:"info-overlay-text"},[s("h5",{staticClass:"text-white m-auto font-weight-bold"},[s("span",{staticClass:"pr-4"},[s("span",{staticClass:"far fa-heart fa-lg pr-1"}),t._v(" "+t._s(e.status.favourites_count)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),s("span",[s("span",{staticClass:"far fa-comment fa-lg pr-1"}),t._v(" "+t._s(e.status.reply_count)+"\n\t\t\t\t\t\t\t\t\t")])])])])])])})),t._v(" "),t.tags.length&&t.loaded?s("div",{staticClass:"card card-body text-center shadow-none bg-transparent border-0"},[s("infinite-loading",{on:{infinite:t.infiniteLoader}},[s("div",{staticClass:"font-weight-bold",attrs:{slot:"no-results"},slot:"no-results"}),t._v(" "),s("div",{staticClass:"font-weight-bold",attrs:{slot:"no-more"},slot:"no-more"})])],1):t._e()],2)]):s("div",[s("p",{staticClass:"text-center lead font-weight-bold"},[t._v("No public posts found.")])])]):s("div",{staticClass:"container text-center"},[t._m(2)])])}),[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"col-12 col-md-3"},[e("div",{staticClass:"profile-avatar"},[e("div",{staticClass:"bg-primary mb-3 d-flex align-items-center justify-content-center display-4 font-weight-bold text-white",staticStyle:{width:"172px",height:"172px","border-radius":"100%"}},[this._v("#")])])])},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:"mt-5 spinner-border",attrs:{role:"status"}},[e("span",{staticClass:"sr-only"},[this._v("Loading...")])])}],!1,null,"ed35bb9a",null);e.default=i.exports},UNrL:function(t,e,s){(t.exports=s("I1BE")(!1)).push([t.i,"\n.tag-header[data-v-ed35bb9a] {\n\tfont-size: 28px;\n\tfont-weight: 300;\n}\n",""])},"aET+":function(t,e,s){var a,n,r={},i=(a=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===n&&(n=a.apply(this,arguments)),n}),o=function(t,e){return e?e.querySelector(t):document.querySelector(t)},c=function(t){var e={};return function(t,s){if("function"==typeof t)return t();if(void 0===e[t]){var a=o.call(this,t,s);if(window.HTMLIFrameElement&&a instanceof window.HTMLIFrameElement)try{a=a.contentDocument.head}catch(t){a=null}e[t]=a}return e[t]}}(),l=null,f=0,u=[],d=s("9tPo");function h(t,e){for(var s=0;s<t.length;s++){var a=t[s],n=r[a.id];if(n){n.refs++;for(var i=0;i<n.parts.length;i++)n.parts[i](a.parts[i]);for(;i<a.parts.length;i++)n.parts.push(w(a.parts[i],e))}else{var o=[];for(i=0;i<a.parts.length;i++)o.push(w(a.parts[i],e));r[a.id]={id:a.id,refs:1,parts:o}}}}function p(t,e){for(var s=[],a={},n=0;n<t.length;n++){var r=t[n],i=e.base?r[0]+e.base:r[0],o={css:r[1],media:r[2],sourceMap:r[3]};a[i]?a[i].parts.push(o):s.push(a[i]={id:i,parts:[o]})}return s}function v(t,e){var s=c(t.insertInto);if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var a=u[u.length-1];if("top"===t.insertAt)a?a.nextSibling?s.insertBefore(e,a.nextSibling):s.appendChild(e):s.insertBefore(e,s.firstChild),u.push(e);else if("bottom"===t.insertAt)s.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var n=c(t.insertAt.before,s);s.insertBefore(e,n)}}function g(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=u.indexOf(t);e>=0&&u.splice(e,1)}function m(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var a=function(){0;return s.nc}();a&&(t.attrs.nonce=a)}return b(e,t.attrs),v(t,e),e}function b(t,e){Object.keys(e).forEach((function(s){t.setAttribute(s,e[s])}))}function w(t,e){var s,a,n,r;if(e.transform&&t.css){if(!(r="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=r}if(e.singleton){var i=f++;s=l||(l=m(e)),a=C.bind(null,s,i,!1),n=C.bind(null,s,i,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(s=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",b(e,t.attrs),v(t,e),e}(e),a=N.bind(null,s,e),n=function(){g(s),s.href&&URL.revokeObjectURL(s.href)}):(s=m(e),a=x.bind(null,s),n=function(){g(s)});return a(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;a(t=e)}else n()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=i()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var s=p(t,e);return h(s,e),function(t){for(var a=[],n=0;n<s.length;n++){var i=s[n];(o=r[i.id]).refs--,a.push(o)}t&&h(p(t,e),e);for(n=0;n<a.length;n++){var o;if(0===(o=a[n]).refs){for(var c=0;c<o.parts.length;c++)o.parts[c]();delete r[o.id]}}}};var _,y=(_=[],function(t,e){return _[t]=e,_.filter(Boolean).join("\n")});function C(t,e,s,a){var n=s?"":a.css;if(t.styleSheet)t.styleSheet.cssText=y(e,n);else{var r=document.createTextNode(n),i=t.childNodes;i[e]&&t.removeChild(i[e]),i.length?t.insertBefore(r,i[e]):t.appendChild(r)}}function x(t,e){var s=e.css,a=e.media;if(a&&t.setAttribute("media",a),t.styleSheet)t.styleSheet.cssText=s;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(s))}}function N(t,e,s){var a=s.css,n=s.sourceMap,r=void 0===e.convertToAbsoluteUrls&&n;(e.convertToAbsoluteUrls||r)&&(a=d(a)),n&&(a+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var i=new Blob([a],{type:"text/css"}),o=t.href;t.href=URL.createObjectURL(i),o&&URL.revokeObjectURL(o)}},gqTO:function(t,e,s){Vue.component("hashtag-component",s("Pvfc").default)},t3j5:function(t,e,s){"use strict";var a=s("+fb5");s.n(a).a}},[[16,0]]]);