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

1 line
19 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{"51wX":function(t,e,s){var r=s("zZx1");"string"==typeof r&&(r=[[t.i,r,""]]);var a={hmr:!0,transform:void 0,insertInto:void 0};s("aET+")(r,a);r.locals&&(t.exports=r.locals)},9:function(t,e,s){t.exports=s("EnJJ")},"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,r=s+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var a,n=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(n)?t:(a=0===n.indexOf("//")?n:0===n.indexOf("/")?s+n:r+n.replace(/^\.\//,""),"url("+JSON.stringify(a)+")")}))}},EnJJ:function(t,e,s){Vue.component("search-results",s("IpYn").default)},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]||"",r=t[3];if(!r)return s;if(e&&"function"==typeof btoa){var a=(i=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),n=r.sources.map((function(t){return"/*# sourceURL="+r.sourceRoot+t+" */"}));return[s].concat(n).concat([a]).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 r={},a=0;a<this.length;a++){var n=this[a][0];"number"==typeof n&&(r[n]=!0)}for(a=0;a<t.length;a++){var i=t[a];"number"==typeof i[0]&&r[i[0]]||(s&&!i[2]?i[2]=s:s&&(i[2]="("+i[2]+") and ("+s+")"),e.push(i))}},e}},IpYn:function(t,e,s){"use strict";s.r(e);var r={props:["query","profileId"],data:function(){return{loading:!0,networkError:!1,results:{hashtags:[],profiles:[],statuses:[]},filters:{hashtags:!0,profiles:!0,statuses:!0},analysis:"profile"}},beforeMount:function(){this.bootSearch()},mounted:function(){$(".search-bar input").val(this.query)},methods:{bootSearch:function(){var t=this.searchLexer();this.analysis=t,this.fetchSearchResults()},fetchSearchResults:function(){this.searchContext(this.analysis)},followProfile:function(t,e){var s=this;this.loading=!0,axios.post("/i/follow",{item:t.entity.id}).then((function(r){return 1==t.entity.local?void s.fetchSearchResults():(s.loading=!1,void(s.results.profiles[e].entity.follow_request=!0))})).catch((function(t){t.response.data.message&&swal("Error",t.response.data.message,"error")}))},searchLexer:function(){var t=this.query;return t.startsWith("#")?"hashtag":2==(t.match(/@/g)||[]).length?"webfinger":t.startsWith("@")||-1!=t.search("@")?"profile":t.startsWith("https://")?"remote":"all"},buildUrl:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"hashtag",e=arguments.length>1?arguments[1]:void 0;switch(t){case"hashtag":return e.url+"?src=search";case"profile":return 1==e.entity.local?e.url:"/i/web/profile/_/"+e.entity.id;default:return e.url+"?src=search"}},searchContext:function(t){var e=this;switch(t){case"all":axios.get("/api/search",{params:{q:this.query,src:"metro",v:1,scope:"all"}}).then((function(t){var s=t.data;e.results.hashtags=s.hashtags?s.hashtags:[],e.results.profiles=s.profiles?s.profiles:[],e.results.statuses=s.posts?s.posts:[],e.loading=!1})).catch((function(t){e.loading=!1,console.log(t),e.networkError=!0}));break;case"hashtag":axios.get("/api/search",{params:{q:this.query.slice(1),src:"metro",v:1,scope:"hashtag"}}).then((function(t){var s=t.data;e.results.hashtags=s.hashtags?s.hashtags:[],e.results.profiles=s.profiles?s.profiles:[],e.results.statuses=s.posts?s.posts:[],e.loading=!1})).catch((function(t){e.loading=!1,console.log(t),e.networkError=!0}));break;case"profile":axios.get("/api/search",{params:{q:this.query,src:"metro",v:1,scope:"profile"}}).then((function(t){var s=t.data;e.results.hashtags=s.hashtags?s.hashtags:[],e.results.profiles=s.profiles?s.profiles:[],e.results.statuses=s.posts?s.posts:[],e.loading=!1})).catch((function(t){e.loading=!1,console.log(t),e.networkError=!0}));break;case"webfinger":axios.get("/api/search",{params:{q:this.query,src:"metro",v:1,scope:"webfinger"}}).then((function(t){var s=t.data;e.results.hashtags=[],e.results.profiles=s.profiles,e.results.statuses=[],e.loading=!1})).catch((function(t){e.loading=!1,console.log(t),e.networkError=!0}));break;default:this.loading=!1,this.networkError=!0}}}},a=(s("j3Fg"),s("KHd+")),n=Object(a.a)(r,(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"container"},[t.loading?s("div",{staticClass:"pt-5 text-center"},[t._m(0)]):t._e(),t._v(" "),t.networkError?s("div",{staticClass:"pt-5 text-center"},[t._m(1)]):t._e(),t._v(" "),t.loading||t.networkError?t._e():s("div",{staticClass:"mt-5"},["all"==t.analysis?s("div",{staticClass:"row"},[s("div",{staticClass:"col-12 mb-5"},[s("p",{staticClass:"h5 font-weight-bold text-dark"},[t._v("Showing results for "),s("i",[t._v(t._s(t.query))])]),t._v(" "),s("hr")]),t._v(" "),s("div",{staticClass:"col-md-3"},[s("div",{staticClass:"mb-4"},[s("p",{staticClass:"text-secondary small font-weight-bold"},[t._v("HASHTAGS "),s("span",{staticClass:"pl-1 text-lighter"},[t._v("("+t._s(t.results.hashtags.length)+")")])])]),t._v(" "),t.results.hashtags.length?s("div",t._l(t.results.hashtags,(function(e,r){return s("a",{staticClass:"mb-2 result-card",attrs:{href:t.buildUrl("hashtag",e)}},[s("div",{staticClass:"pb-3"},[s("div",{staticClass:"media align-items-center py-2 pr-3"},[t._m(2,!0),t._v(" "),s("div",{staticClass:"media-body text-truncate"},[s("p",{staticClass:"mb-0 text-truncate text-dark font-weight-bold",attrs:{"data-toggle":"tooltip",title:e.value}},[t._v("\n\t\t\t\t\t\t\t\t\t\t#"+t._s(e.value)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),e.count>2?s("p",{staticClass:"mb-0 small font-weight-bold text-muted text-uppercase"},[t._v("\n\t\t\t\t\t\t\t\t\t"+t._s(e.count)+" posts\n\t\t\t\t\t\t\t\t")]):t._e()])])])])})),0):s("div",[s("div",{staticClass:"border py-3 text-center font-weight-bold"},[t._v("No results found")])])]),t._v(" "),s("div",{staticClass:"col-md-5"},[s("div",{staticClass:"mb-4"},[s("p",{staticClass:"text-secondary small font-weight-bold"},[t._v("PROFILES "),s("span",{staticClass:"pl-1 text-lighter"},[t._v("("+t._s(t.results.profiles.length)+")")])])]),t._v(" "),t.results.profiles.length?s("div",t._l(t.results.profiles,(function(e,r){return s("a",{staticClass:"mb-2 result-card",attrs:{href:t.buildUrl("profile",e)}},[s("div",{staticClass:"pb-3"},[s("div",{staticClass:"media align-items-center py-2 pr-3"},[s("img",{staticClass:"mr-3 rounded-circle border",attrs:{src:e.avatar,width:"50px",height:"50px"}}),t._v(" "),s("div",{staticClass:"media-body"},[s("p",{staticClass:"mb-0 text-truncate text-dark font-weight-bold",attrs:{"data-toggle":"tooltip",title:e.value}},[t._v("\n\t\t\t\t\t\t\t\t\t\t"+t._s(e.value)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),s("p",{staticClass:"mb-0 small font-weight-bold text-muted text-uppercase"},[t._v("\n\t\t\t\t\t\t\t\t\t\t"+t._s(e.entity.post_count)+" Posts\n\t\t\t\t\t\t\t\t\t")])]),t._v(" "),s("div",{staticClass:"ml-3"},[e.entity.following?s("a",{staticClass:"btn btn-primary btn-sm font-weight-bold text-uppercase py-0",attrs:{href:t.buildUrl("profile",e)}},[t._v("Following")]):s("a",{staticClass:"btn btn-outline-primary btn-sm font-weight-bold text-uppercase py-0",attrs:{href:t.buildUrl("profile",e)}},[t._v("View")])])])])])})),0):s("div",[s("div",{staticClass:"border py-3 text-center font-weight-bold"},[t._v("No results found")])])]),t._v(" "),s("div",{staticClass:"col-md-4"},[s("div",{staticClass:"mb-4"},[s("p",{staticClass:"text-secondary small font-weight-bold"},[t._v("STATUSES "),s("span",{staticClass:"pl-1 text-lighter"},[t._v("("+t._s(t.results.statuses.length)+")")])])]),t._v(" "),t.results.statuses.length?s("div",t._l(t.results.statuses,(function(e,r){return s("a",{staticClass:"mr-2 result-card",attrs:{href:t.buildUrl("status",e)}},[s("img",{staticClass:"mb-2",attrs:{src:e.thumb,width:"90px",height:"90px"}})])})),0):s("div",[s("div",{staticClass:"border py-3 text-center font-weight-bold"},[t._v("No results found")])])])]):"hashtag"==t.analysis?s("div",{staticClass:"row"},[s("div",{staticClass:"col-12 mb-5"},[s("p",{staticClass:"h5 font-weight-bold text-dark"},[t._v("Showing results for "),s("i",[t._v(t._s(t.query))])]),t._v(" "),s("hr")]),t._v(" "),s("div",{staticClass:"col-md-6 offset-md-3"},[s("div",{staticClass:"mb-4"},[s("p",{staticClass:"text-secondary small font-weight-bold"},[t._v("HASHTAGS "),s("span",{staticClass:"pl-1 text-lighter"},[t._v("("+t._s(t.results.hashtags.length)+")")])])]),t._v(" "),t.results.hashtags.length?s("div",t._l(t.results.hashtags,(function(e,r){return s("a",{staticClass:"mb-2 result-card",attrs:{href:t.buildUrl("hashtag",e)}},[s("div",{staticClass:"pb-3"},[s("div",{staticClass:"media align-items-center py-2 pr-3"},[t._m(3,!0),t._v(" "),s("div",{staticClass:"media-body"},[s("p",{staticClass:"mb-0 text-truncate text-dark font-weight-bold",attrs:{"data-toggle":"tooltip",title:e.value}},[t._v("\n\t\t\t\t\t\t\t\t\t\t#"+t._s(e.value)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),e.count>2?s("p",{staticClass:"mb-0 small font-weight-bold text-muted text-uppercase"},[t._v("\n\t\t\t\t\t\t\t\t\t"+t._s(e.count)+" posts\n\t\t\t\t\t\t\t\t")]):t._e()])])])])})),0):s("div",[s("div",{staticClass:"border py-3 text-center font-weight-bold"},[t._v("No results found")])])])]):"profile"==t.analysis?s("div",{staticClass:"row"},[s("div",{staticClass:"col-12 mb-5"},[s("p",{staticClass:"h5 font-weight-bold text-dark"},[t._v("Showing results for "),s("i",[t._v(t._s(t.query))])]),t._v(" "),s("hr")]),t._v(" "),s("div",{staticClass:"col-md-6 offset-md-3"},[s("div",{staticClass:"mb-4"},[s("p",{staticClass:"text-secondary small font-weight-bold"},[t._v("PROFILES "),s("span",{staticClass:"pl-1 text-lighter"},[t._v("("+t._s(t.results.profiles.length)+")")])])]),t._v(" "),t.results.profiles.length?s("div",t._l(t.results.profiles,(function(e,r){return s("div",{staticClass:"card mb-4"},[t._m(4,!0),t._v(" "),s("div",{staticClass:"card-body"},[s("div",{staticClass:"text-center mt-n5 mb-4"},[s("img",{staticClass:"rounded-circle p-1 border mt-n4 bg-white shadow",attrs:{src:e.entity.thumb,width:"90px",height:"90px;",onerror:"this.onerror=null;this.src='/storage/avatars/default.png';"}})]),t._v(" "),s("p",{staticClass:"text-center lead font-weight-bold mb-1"},[t._v(t._s(e.value))]),t._v(" "),s("p",{staticClass:"text-center text-muted small text-uppercase mb-4"}),t._v(" "),s("div",{staticClass:"d-flex justify-content-center"},[e.entity.following?s("button",{staticClass:"btn btn-outline-secondary btn-sm py-1 px-4 text-uppercase font-weight-bold mr-3",staticStyle:{"font-weight":"500"},attrs:{type:"button"}},[t._v("Following")]):t._e(),t._v(" "),s("a",{staticClass:"btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold",staticStyle:{"font-weight":"500"},attrs:{href:t.buildUrl("profile",e)}},[t._v("View Profile")])])])])})),0):s("div",[s("div",{staticClass:"border py-3 text-center font-weight-bold"},[t._v("No results found")])])])]):"webfinger"==t.analysis?s("div",{staticClass:"row"},[s("div",{staticClass:"col-12 mb-5"},[s("p",{staticClass:"h5 font-weight-bold text-dark"},[t._v("Showing results for "),s("i",[t._v(t._s(t.query))])]),t._v(" "),s("hr"),t._v(" "),s("div",{staticClass:"col-md-6 offset-md-3"},t._l(t.results.profiles,(function(e,r){return s("div",{staticClass:"card mb-2"},[t._m(5,!0),t._v(" "),s("div",{staticClass:"card-body"},[s("div",{staticClass:"text-center mt-n5 mb-4"},[s("img",{staticClass:"rounded-circle p-1 border mt-n4 bg-white shadow",attrs:{src:e.entity.thumb,width:"90px",height:"90px;",onerror:"this.onerror=null;this.src='/storage/avatars/default.png';"}})]),t._v(" "),s("p",{staticClass:"text-center lead font-weight-bold mb-1"},[t._v(t._s(e.value))]),t._v(" "),s("p",{staticClass:"text-center text-muted small text-uppercase mb-4"}),t._v(" "),s("div",{staticClass:"d-flex justify-content-center"},[s("a",{staticClass:"btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold",staticStyle:{"font-weight":"500"},attrs:{href:"/i/web/profile/_/"+e.entity.id}},[t._v("View Profile")])])])])})),0)])]):s("div",{staticClass:"col-12"},[s("p",{staticClass:"text-center text-muted lead font-weight-bold"},[t._v("No results found")])])])])}),[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("p",{staticClass:"lead font-weight-lighter"},[this._v("An error occured, results could not be loaded."),e("br"),this._v(" Please try again later.")])},function(){var t=this.$createElement,e=this._self._c||t;return e("span",{staticClass:"d-inline-flex align-items-center justify-content-center border rounded-circle mr-3",staticStyle:{width:"50px",height:"50px"}},[e("i",{staticClass:"fas fa-hashtag text-muted"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("span",{staticClass:"d-inline-flex align-items-center justify-content-center border rounded-circle mr-3",staticStyle:{width:"50px",height:"50px"}},[e("i",{staticClass:"fas fa-hashtag text-muted"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"card-header p-0 m-0"},[e("div",{staticStyle:{width:"100%",height:"140px",background:"#0070b7"}})])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"card-header p-0 m-0"},[e("div",{staticStyle:{width:"100%",height:"140px",background:"#0070b7"}})])}],!1,null,"1e60658e",null);e.default=n.exports},"KHd+":function(t,e,s){"use strict";function r(t,e,s,r,a,n,i,o){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=s,c._compiled=!0),r&&(c.functional=!0),n&&(c._scopeId="data-v-"+n),i?(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__),a&&a.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):a&&(l=o?function(){a.call(this,this.$root.$options.shadowRoot)}:a),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(t,e){return l.call(e),u(t,e)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,l):[l]}return{exports:t,options:c}}s.d(e,"a",(function(){return r}))},"aET+":function(t,e,s){var r,a,n={},i=(r=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===a&&(a=r.apply(this,arguments)),a}),o=function(t,e){return e?e.querySelector(t):document.querySelector(t)},l=function(t){var e={};return function(t,s){if("function"==typeof t)return t();if(void 0===e[t]){var r=o.call(this,t,s);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(t){r=null}e[t]=r}return e[t]}}(),c=null,u=0,d=[],f=s("9tPo");function h(t,e){for(var s=0;s<t.length;s++){var r=t[s],a=n[r.id];if(a){a.refs++;for(var i=0;i<a.parts.length;i++)a.parts[i](r.parts[i]);for(;i<r.parts.length;i++)a.parts.push(_(r.parts[i],e))}else{var o=[];for(i=0;i<r.parts.length;i++)o.push(_(r.parts[i],e));n[r.id]={id:r.id,refs:1,parts:o}}}}function p(t,e){for(var s=[],r={},a=0;a<t.length;a++){var n=t[a],i=e.base?n[0]+e.base:n[0],o={css:n[1],media:n[2],sourceMap:n[3]};r[i]?r[i].parts.push(o):s.push(r[i]={id:i,parts:[o]})}return s}function v(t,e){var s=l(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 r=d[d.length-1];if("top"===t.insertAt)r?r.nextSibling?s.insertBefore(e,r.nextSibling):s.appendChild(e):s.insertBefore(e,s.firstChild),d.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 a=l(t.insertAt.before,s);s.insertBefore(e,a)}}function g(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=d.indexOf(t);e>=0&&d.splice(e,1)}function b(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var r=function(){0;return s.nc}();r&&(t.attrs.nonce=r)}return m(e,t.attrs),v(t,e),e}function m(t,e){Object.keys(e).forEach((function(s){t.setAttribute(s,e[s])}))}function _(t,e){var s,r,a,n;if(e.transform&&t.css){if(!(n="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=n}if(e.singleton){var i=u++;s=c||(c=b(e)),r=w.bind(null,s,i,!1),a=w.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",m(e,t.attrs),v(t,e),e}(e),r=S.bind(null,s,e),a=function(){g(s),s.href&&URL.revokeObjectURL(s.href)}):(s=b(e),r=x.bind(null,s),a=function(){g(s)});return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(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=i()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var s=p(t,e);return h(s,e),function(t){for(var r=[],a=0;a<s.length;a++){var i=s[a];(o=n[i.id]).refs--,r.push(o)}t&&h(p(t,e),e);for(a=0;a<r.length;a++){var o;if(0===(o=r[a]).refs){for(var l=0;l<o.parts.length;l++)o.parts[l]();delete n[o.id]}}}};var y,C=(y=[],function(t,e){return y[t]=e,y.filter(Boolean).join("\n")});function w(t,e,s,r){var a=s?"":r.css;if(t.styleSheet)t.styleSheet.cssText=C(e,a);else{var n=document.createTextNode(a),i=t.childNodes;i[e]&&t.removeChild(i[e]),i.length?t.insertBefore(n,i[e]):t.appendChild(n)}}function x(t,e){var s=e.css,r=e.media;if(r&&t.setAttribute("media",r),t.styleSheet)t.styleSheet.cssText=s;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(s))}}function S(t,e,s){var r=s.css,a=s.sourceMap,n=void 0===e.convertToAbsoluteUrls&&a;(e.convertToAbsoluteUrls||n)&&(r=f(r)),a&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */");var i=new Blob([r],{type:"text/css"}),o=t.href;t.href=URL.createObjectURL(i),o&&URL.revokeObjectURL(o)}},j3Fg:function(t,e,s){"use strict";var r=s("51wX");s.n(r).a},zZx1:function(t,e,s){(t.exports=s("I1BE")(!1)).push([t.i,"\n.result-card[data-v-1e60658e] {\n\ttext-decoration: none;\n}\n.result-card .media[data-v-1e60658e]:hover {\n\tbackground: #EDF2F7;\n}\n@media (min-width: 1200px) {\n.container[data-v-1e60658e] {\n\t\tmax-width: 995px;\n}\n}\n",""])}},[[9,0]]]);