diff --git a/js/dist/forum.js.map b/js/dist/forum.js.map index de2eb3a..4f20e36 100644 --- a/js/dist/forum.js.map +++ b/js/dist/forum.js.map @@ -1 +1 @@ -{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,+BCL9D,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,iBCAlD,EAA+BF,OAAOC,KAAKC,OAAO,gC,aCAzC,SAASC,EAAgBhB,EAAGiB,GAKzC,OAJAD,EAAkBf,OAAOiB,eAAiBjB,OAAOiB,eAAeC,OAAS,SAAyBnB,EAAGiB,GAEnG,OADAjB,EAAEoB,UAAYH,EACPjB,CACR,EACMgB,EAAgBhB,EAAGiB,EAC3B,CCND,MAAM,EAA+BJ,OAAOC,KAAKC,OAAO,oB,ICEnCM,EAAAA,SAAAA,GCDN,IAAwBC,EAAUC,E,kDAAAA,E,GAAVD,E,GAC5Bf,UAAYN,OAAOuB,OAAOD,EAAWhB,WAC9Ce,EAASf,UAAUkB,YAAcH,EACjCJ,EAAeI,E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B,WAC9Fa,OAAQ,QAETC,MAAK,SAAC3B,GACL,EAAK4B,QAAQ5B,GACb,EAAKH,SAAU,CAChB,GACJ,E,EAED+B,QAAA,SAAQ5B,GACNJ,KAAKI,KAAOA,EACZ6B,EAAEC,QACH,E,EArEkBzC,C,MAAoB0C,IEGzCX,IAAAA,aAAAA,IAAqB,iCAAiC,YACpDY,EAAAA,EAAAA,QAAOC,IAAAA,UAAuB,YAAY,WAAY,MAC9CC,EAAYd,IAAAA,MAAAA,UAAoB,oCAChCe,EAAiBD,EACnBA,EAAUf,MAAM,KAAKiB,KAAI,SAAUC,GACjC,OAAOA,EAAKC,MACb,IACD,GACEC,EAAYnB,IAAAA,MAAAA,UAAoB,oCAChCoB,EAAiBD,EACnBA,EAAUpB,MAAM,KAAKiB,KAAI,SAAUC,GACjC,OAAOA,EAAKC,MACb,IACD,GACErC,EAAiB,SAAGmB,IAAAA,MAAAA,UAAoB,8CAAvB,EAETxB,KAAK6C,QAAQC,iBAAiB,qBAEtCC,SAAQ,SAAC7C,GACb,IAAMU,EAAOV,EAAKU,KACZoC,EAASpC,EAAKW,MAAM,KAAK,GAAGA,MAAM,KAAK0B,OAAO,GAAGC,KAAK,KAExDhD,EAAKiD,UAAUC,SAAS,gBAAkBlD,EAAKiD,UAAUC,SAAS,gBAEnER,EAAeS,SAAWT,EAAeU,SAASN,IAC/CT,EAAec,QAAUd,EAAee,SAASN,IAClDpC,EAAK2C,QAAQ,MAAO,MAAQrD,EAAKsD,YAAYD,QAAQ,MAAO,KAE7D/B,IAAAA,MAAAA,UAAoB,4CAA8CZ,EAAK6C,MAAM,gDAEjFxB,EAAEyB,MAAMxD,EAAM,CACZK,KAAM,WACJ,OAAO0B,EAAExC,EAAa,CAAES,KAAAA,EAAMG,kBAAmBA,GAClD,GAEJ,GACF,GACF,G","sources":["webpack://@datlechin/flarum-link-preview/webpack/bootstrap","webpack://@datlechin/flarum-link-preview/webpack/runtime/compat get default export","webpack://@datlechin/flarum-link-preview/webpack/runtime/define property getters","webpack://@datlechin/flarum-link-preview/webpack/runtime/hasOwnProperty shorthand","webpack://@datlechin/flarum-link-preview/webpack/runtime/make namespace object","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['forum/app']\"","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['common/extend']\"","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['forum/components/CommentPost']\"","webpack://@datlechin/flarum-link-preview/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['common/Component']\"","webpack://@datlechin/flarum-link-preview/./src/forum/components/LinkPreview.js","webpack://@datlechin/flarum-link-preview/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@datlechin/flarum-link-preview/./src/forum/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/CommentPost'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","import Component from 'flarum/common/Component';\n\nexport default class LinkPreview extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n this.loading = true;\n this.link = vnode.attrs.link;\n this.data = null;\n this.useGoogleFavicons = vnode.attrs.useGoogleFavicons;\n\n this.fetchData();\n }\n view() {\n return (\n
\n {this.useGoogleFavicons ? (\n
\n {this.loading ? (\n \n ) : (\n \n )}\n
\n ) : null}\n
\n
\n \n {this.loading ? this.getDomain() : this.data?.title ?? this.data.error}\n \n
\n
{this.loading ? '' : this.data?.description ?? ''}
\n
\n {this.useGoogleFavicons ? (\n \n ) : null}\n \n {this.loading ? this.getDomain() : this.data?.site_name ?? this.getDomain()}\n \n
\n
\n
\n );\n }\n\n oncreate(vnode) {\n this.link.parentNode.insertBefore(vnode.dom, this.link);\n }\n\n getHref() {\n return this.link.href;\n }\n\n getDomain() {\n return this.getHref().split('/')[2];\n }\n\n fetchData() {\n app\n .request({\n url: app.forum.attribute('apiUrl') + '/datlechin-link-preview?url=' + encodeURIComponent(this.getHref()),\n method: 'GET',\n })\n .then((data) => {\n this.setData(data);\n this.loading = false;\n });\n }\n\n setData(data) {\n this.data = data;\n m.redraw();\n }\n}\n","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport CommentPost from 'flarum/forum/components/CommentPost';\nimport LinkPreview from './components/LinkPreview';\n\napp.initializers.add('datlechin/flarum-link-preview', () => {\n extend(CommentPost.prototype, 'oncreate', function () {\n const blacklist = app.forum.attribute('datlechin-link-preview.blacklist');\n const blacklistArray = blacklist\n ? blacklist.split(',').map(function (item) {\n return item.trim();\n })\n : [];\n const whitelist = app.forum.attribute('datlechin-link-preview.whitelist');\n const whitelistArray = whitelist\n ? whitelist.split(',').map(function (item) {\n return item.trim();\n })\n : [];\n const useGoogleFavicons = app.forum.attribute('datlechin-link-preview.useGoogleFavicons') ?? false;\n\n const links = this.element.querySelectorAll('.Post-body a[rel]');\n\n links.forEach((link) => {\n const href = link.href;\n const domain = href.split('/')[2].split('.').slice(-2).join('.');\n\n if (link.classList.contains('PostMention') || link.classList.contains('UserMention')) return;\n if (\n (whitelistArray.length && !whitelistArray.includes(domain))\n || (blacklistArray.length && blacklistArray.includes(domain))\n || href.replace(/\\/$/, '') !== link.textContent.replace(/\\/$/, '')\n ) return;\n if (app.forum.attribute('datlechin-link-preview.convertMediaURLs') && href.match(/\\.(jpe?g|png|gif|svg|webp|mp3|mp4|m4a|wav)$/)) return;\n\n m.mount(link, {\n view: function () {\n return m(LinkPreview, { link, useGoogleFavicons: useGoogleFavicons });\n },\n });\n });\n });\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","LinkPreview","subClass","superClass","create","constructor","oninit","vnode","this","loading","link","attrs","data","useGoogleFavicons","fetchData","view","className","src","image","getDomain","href","target","title","error","description","getHref","site_name","oncreate","parentNode","insertBefore","dom","split","app","request","url","forum","attribute","encodeURIComponent","method","then","setData","m","redraw","Component","extend","CommentPost","blacklist","blacklistArray","map","item","trim","whitelist","whitelistArray","element","querySelectorAll","forEach","domain","slice","join","classList","contains","length","includes","replace","textContent","match","mount"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,I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B,iCAAiC,YACpDY,EAAAA,EAAAA,QAAOC,IAAAA,UAAuB,YAAY,WAAY,MAC9CC,EAAYd,IAAAA,MAAAA,UAAoB,oCAChCe,EAAiBD,EACnBA,EAAUf,MAAM,KAAKiB,KAAI,SAAUC,GACjC,OAAOA,EAAKC,MACb,IACD,GACEC,EAAYnB,IAAAA,MAAAA,UAAoB,oCAChCoB,EAAiBD,EACnBA,EAAUpB,MAAM,KAAKiB,KAAI,SAAUC,GACjC,OAAOA,EAAKC,MACb,IACD,GACErC,EAAiB,SAAGmB,IAAAA,MAAAA,UAAoB,8CAAvB,EAETxB,KAAK6C,QAAQC,iBAAiB,qBAEtCC,SAAQ,SAAC7C,GACb,IAAMU,EAAOV,EAAKU,KACZoC,EAASpC,EAAKW,MAAM,KAAK,GAAGA,MAAM,KAAK0B,OAAO,GAAGC,KAAK,KAExDhD,EAAKiD,UAAUC,SAAS,gBAAkBlD,EAAKiD,UAAUC,SAAS,gBAEnER,EAAeS,SAAWT,EAAeU,SAASN,IAClDT,EAAec,QAAUd,EAAee,SAASN,IAClDpC,EAAK2C,QAAQ,MAAO,MAAQrD,EAAKsD,YAAYD,QAAQ,MAAO,KAG1D/B,IAAAA,MAAAA,UAAoB,4CAA8CZ,EAAK6C,MAAM,gDAEjFxB,EAAEyB,MAAMxD,EAAM,CACZK,KAAM,WACJ,OAAO0B,EAAExC,EAAa,CAAES,KAAAA,EAAMG,kBAAmBA,GAClD,GAEJ,GACF,GACF,G","sources":["webpack://@datlechin/flarum-link-preview/webpack/bootstrap","webpack://@datlechin/flarum-link-preview/webpack/runtime/compat get default export","webpack://@datlechin/flarum-link-preview/webpack/runtime/define property getters","webpack://@datlechin/flarum-link-preview/webpack/runtime/hasOwnProperty shorthand","webpack://@datlechin/flarum-link-preview/webpack/runtime/make namespace object","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['forum/app']\"","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['common/extend']\"","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['forum/components/CommentPost']\"","webpack://@datlechin/flarum-link-preview/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@datlechin/flarum-link-preview/external root \"flarum.core.compat['common/Component']\"","webpack://@datlechin/flarum-link-preview/./src/forum/components/LinkPreview.js","webpack://@datlechin/flarum-link-preview/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@datlechin/flarum-link-preview/./src/forum/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/CommentPost'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","import Component from 'flarum/common/Component';\n\nexport default class LinkPreview extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n this.loading = true;\n this.link = vnode.attrs.link;\n this.data = null;\n this.useGoogleFavicons = vnode.attrs.useGoogleFavicons;\n\n this.fetchData();\n }\n view() {\n return (\n
\n {this.useGoogleFavicons ? (\n
\n {this.loading ? (\n \n ) : (\n \n )}\n
\n ) : null}\n
\n
\n \n {this.loading ? this.getDomain() : this.data?.title ?? this.data.error}\n \n
\n
{this.loading ? '' : this.data?.description ?? ''}
\n
\n {this.useGoogleFavicons ? (\n \n ) : null}\n \n {this.loading ? this.getDomain() : this.data?.site_name ?? this.getDomain()}\n \n
\n
\n
\n );\n }\n\n oncreate(vnode) {\n this.link.parentNode.insertBefore(vnode.dom, this.link);\n }\n\n getHref() {\n return this.link.href;\n }\n\n getDomain() {\n return this.getHref().split('/')[2];\n }\n\n fetchData() {\n app\n .request({\n url: app.forum.attribute('apiUrl') + '/datlechin-link-preview?url=' + encodeURIComponent(this.getHref()),\n method: 'GET',\n })\n .then((data) => {\n this.setData(data);\n this.loading = false;\n });\n }\n\n setData(data) {\n this.data = data;\n m.redraw();\n }\n}\n","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport CommentPost from 'flarum/forum/components/CommentPost';\nimport LinkPreview from './components/LinkPreview';\n\napp.initializers.add('datlechin/flarum-link-preview', () => {\n extend(CommentPost.prototype, 'oncreate', function () {\n const blacklist = app.forum.attribute('datlechin-link-preview.blacklist');\n const blacklistArray = blacklist\n ? blacklist.split(',').map(function (item) {\n return item.trim();\n })\n : [];\n const whitelist = app.forum.attribute('datlechin-link-preview.whitelist');\n const whitelistArray = whitelist\n ? whitelist.split(',').map(function (item) {\n return item.trim();\n })\n : [];\n const useGoogleFavicons = app.forum.attribute('datlechin-link-preview.useGoogleFavicons') ?? false;\n\n const links = this.element.querySelectorAll('.Post-body a[rel]');\n\n links.forEach((link) => {\n const href = link.href;\n const domain = href.split('/')[2].split('.').slice(-2).join('.');\n\n if (link.classList.contains('PostMention') || link.classList.contains('UserMention')) return;\n if (\n (whitelistArray.length && !whitelistArray.includes(domain)) ||\n (blacklistArray.length && blacklistArray.includes(domain)) ||\n href.replace(/\\/$/, '') !== link.textContent.replace(/\\/$/, '')\n )\n return;\n if (app.forum.attribute('datlechin-link-preview.convertMediaURLs') && href.match(/\\.(jpe?g|png|gif|svg|webp|mp3|mp4|m4a|wav)$/)) return;\n\n m.mount(link, {\n view: function () {\n return m(LinkPreview, { link, useGoogleFavicons: useGoogleFavicons });\n },\n });\n });\n });\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","LinkPreview","subClass","superClass","create","constructor","oninit","vnode","this","loading","link","attrs","data","useGoogleFavicons","fetchData","view","className","src","image","getDomain","href","target","title","error","description","getHref","site_name","oncreate","parentNode","insertBefore","dom","split","app","request","url","forum","attribute","encodeURIComponent","method","then","setData","m","redraw","Component","extend","CommentPost","blacklist","blacklistArray","map","item","trim","whitelist","whitelistArray","element","querySelectorAll","forEach","domain","slice","join","classList","contains","length","includes","replace","textContent","match","mount"],"sourceRoot":""} \ No newline at end of file