pixelfed/public/js/hashtag.js
2020-08-05 01:52:28 -06:00

1 line
14 KiB
JavaScript
Vendored

(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{16:function(t,e,n){t.exports=n("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 n=e.protocol+"//"+e.host,s=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var a,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:(a=0===r.indexOf("//")?r:0===r.indexOf("/")?n+r:s+r.replace(/^\.\//,""),"url("+JSON.stringify(a)+")")}))}},I1BE:function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",s=t[3];if(!s)return n;if(e&&"function"==typeof btoa){var a=(o=s,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),r=s.sources.map((function(t){return"/*# sourceURL="+s.sourceRoot+t+" */"}));return[n].concat(r).concat([a]).join("\n")}var o;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var s={},a=0;a<this.length;a++){var r=this[a][0];"number"==typeof r&&(s[r]=!0)}for(a=0;a<t.length;a++){var o=t[a];"number"==typeof o[0]&&s[o[0]]||(n&&!o[2]?o[2]=n:n&&(o[2]="("+o[2]+") and ("+n+")"),e.push(o))}},e}},"KHd+":function(t,e,n){"use strict";function s(t,e,n,s,a,r,o,i){var c,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=n,l._compiled=!0),s&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),o?(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__),a&&a.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},l._ssrRegister=c):a&&(c=i?function(){a.call(this,this.$root.$options.shadowRoot)}:a),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}}n.d(e,"a",(function(){return s}))},Pvfc:function(t,e,n){"use strict";n.r(e);function s(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(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 a={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;axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(e){var n=e.data,s=n.tags.filter((function(t){return!(!t||0==t.length)}));t.tags=s,t.loaded=!0,t.following=n.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(n){var a=n.data;if(a.tags.length){var r,o=a.tags.filter((function(t){return!(!t||0==t.length)}));if((r=e.tags).push.apply(r,s(o)),o.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=(n("mXeM"),n("KHd+")),o=Object(r.a)(a,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t.loaded?n("div",{staticClass:"container"},[n("div",{staticClass:"profile-header row my-5"},[t._m(0),t._v(" "),n("div",{staticClass:"col-12 col-md-9 d-flex align-items-center"},[n("div",{staticClass:"profile-details"},[n("div",{staticClass:"username-bar pb-2"},[n("p",{staticClass:"tag-header mb-0"},[t._v("#"+t._s(t.hashtag))]),t._v(" "),n("p",{staticClass:"lead"},[n("span",{staticClass:"font-weight-bold"},[t._v(t._s(t.tags.length?t.hashtagCount:"0"))]),t._v(" posts")]),t._v(" "),n("div",{staticClass:"d-flex justify-content-between align-items-center"},[t.authenticated&&t.tags.length?n("p",{staticClass:"pt-3 mr-4"},[t.following?n("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")]):n("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(" "),n("div",{staticClass:"custom-control custom-switch"},[n("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 n=t.forceNsfw,s=e.target,a=!!s.checked;if(Array.isArray(n)){var r=t._i(n,null);s.checked?r<0&&(t.forceNsfw=n.concat([null])):r>-1&&(t.forceNsfw=n.slice(0,r).concat(n.slice(r+1)))}else t.forceNsfw=a}}}),t._v(" "),n("label",{staticClass:"custom-control-label font-weight-bold text-muted",attrs:{for:"nsfwSwitch"}},[t._v("Show NSFW Content")])])])])])])]),t._v(" "),t.tags.length?n("div",{staticClass:"tag-timeline"},[t.top.length?n("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Top Posts")]):t._e(),t._v(" "),n("div",{staticClass:"row pb-5"},t._l(t.top,(function(e,s){return n("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[n("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[e.status.sensitive&&0==t.forceNsfw?n("div",{staticClass:"square-content",style:"background-image: url(/storage/no-preview.png)"}):n("div",{staticClass:"square-content",style:"background-image: url("+e.status.thumb+")"}),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",{staticClass:"pr-4"},[n("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(" "),n("span",[n("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(" "),n("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Most Recent")]),t._v(" "),n("div",{staticClass:"row"},[t._l(t.tags,(function(e,s){return n("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[n("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[e.status.sensitive&&0==t.forceNsfw?n("div",{staticClass:"square-content",style:"background-image: url(/storage/no-preview.png)"}):n("div",{staticClass:"square-content",style:"background-image: url("+e.status.thumb+")"}),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",{staticClass:"pr-4"},[n("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(" "),n("span",[n("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")])])])])])])})),t._v(" "),t.tags.length&&t.loaded?n("div",{staticClass:"card card-body text-center shadow-none bg-transparent border-0"},[n("infinite-loading",{on:{infinite:t.infiniteLoader}},[n("div",{staticClass:"font-weight-bold",attrs:{slot:"no-results"},slot:"no-results"}),t._v(" "),n("div",{staticClass:"font-weight-bold",attrs:{slot:"no-more"},slot:"no-more"})])],1):t._e()],2)]):n("div",[n("p",{staticClass:"text-center lead font-weight-bold"},[t._v("No public posts found.")])])]):n("div",{staticClass:"container text-center"},[t._m(1)])])}),[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:"mt-5 spinner-border",attrs:{role:"status"}},[e("span",{staticClass:"sr-only"},[this._v("Loading...")])])}],!1,null,"0b5bf014",null);e.default=o.exports},W8EH:function(t,e,n){var s=n("ou/g");"string"==typeof s&&(s=[[t.i,s,""]]);var a={hmr:!0,transform:void 0,insertInto:void 0};n("aET+")(s,a);s.locals&&(t.exports=s.locals)},"aET+":function(t,e,n){var s,a,r={},o=(s=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===a&&(a=s.apply(this,arguments)),a}),i=function(t,e){return e?e.querySelector(t):document.querySelector(t)},c=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var s=i.call(this,t,n);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}}(),l=null,f=0,u=[],d=n("9tPo");function p(t,e){for(var n=0;n<t.length;n++){var s=t[n],a=r[s.id];if(a){a.refs++;for(var o=0;o<a.parts.length;o++)a.parts[o](s.parts[o]);for(;o<s.parts.length;o++)a.parts.push(w(s.parts[o],e))}else{var i=[];for(o=0;o<s.parts.length;o++)i.push(w(s.parts[o],e));r[s.id]={id:s.id,refs:1,parts:i}}}}function h(t,e){for(var n=[],s={},a=0;a<t.length;a++){var r=t[a],o=e.base?r[0]+e.base:r[0],i={css:r[1],media:r[2],sourceMap:r[3]};s[o]?s[o].parts.push(i):n.push(s[o]={id:o,parts:[i]})}return n}function v(t,e){var n=c(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var s=u[u.length-1];if("top"===t.insertAt)s?s.nextSibling?n.insertBefore(e,s.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),u.push(e);else if("bottom"===t.insertAt)n.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 a=c(t.insertAt.before,n);n.insertBefore(e,a)}}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 s=function(){0;return n.nc}();s&&(t.attrs.nonce=s)}return b(e,t.attrs),v(t,e),e}function b(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function w(t,e){var n,s,a,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 o=f++;n=l||(l=m(e)),s=_.bind(null,n,o,!1),a=_.bind(null,n,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=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),s=E.bind(null,n,e),a=function(){g(n),n.href&&URL.revokeObjectURL(n.href)}):(n=m(e),s=x.bind(null,n),a=function(){g(n)});return s(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;s(t=e)}else a()}}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=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=h(t,e);return p(n,e),function(t){for(var s=[],a=0;a<n.length;a++){var o=n[a];(i=r[o.id]).refs--,s.push(i)}t&&p(h(t,e),e);for(a=0;a<s.length;a++){var i;if(0===(i=s[a]).refs){for(var c=0;c<i.parts.length;c++)i.parts[c]();delete r[i.id]}}}};var y,C=(y=[],function(t,e){return y[t]=e,y.filter(Boolean).join("\n")});function _(t,e,n,s){var a=n?"":s.css;if(t.styleSheet)t.styleSheet.cssText=C(e,a);else{var r=document.createTextNode(a),o=t.childNodes;o[e]&&t.removeChild(o[e]),o.length?t.insertBefore(r,o[e]):t.appendChild(r)}}function x(t,e){var n=e.css,s=e.media;if(s&&t.setAttribute("media",s),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function E(t,e,n){var s=n.css,a=n.sourceMap,r=void 0===e.convertToAbsoluteUrls&&a;(e.convertToAbsoluteUrls||r)&&(s=d(s)),a&&(s+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */");var o=new Blob([s],{type:"text/css"}),i=t.href;t.href=URL.createObjectURL(o),i&&URL.revokeObjectURL(i)}},gqTO:function(t,e,n){Vue.component("hashtag-component",n("Pvfc").default)},mXeM:function(t,e,n){"use strict";var s=n("W8EH");n.n(s).a},"ou/g":function(t,e,n){(t.exports=n("I1BE")(!1)).push([t.i,"\n.tag-header[data-v-0b5bf014] {\n\tfont-size: 28px;\n\tfont-weight: 300;\n}\n",""])}},[[16,0]]]);