fix incompatible for PHP 8.2
parent
3e21fb44bc
commit
1bab22e474
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
namespace Isekai\Widgets\Parsoid;
|
||||||
|
|
||||||
|
use Wikimedia\Parsoid\DOM\DocumentFragment;
|
||||||
|
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
|
||||||
|
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
||||||
|
|
||||||
|
class VEvalTagHandler extends ExtensionTagHandler {
|
||||||
|
public function toArgs(array $extArgs): array {
|
||||||
|
$ret = [];
|
||||||
|
/** @var KV $extArg */
|
||||||
|
foreach ($extArgs as $extArg) {
|
||||||
|
$ret[$extArg->k] = $extArg->v;
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs): DocumentFragment {
|
||||||
|
$src = preg_replace('/^([ ]*)([#*]+)/', '${1}<nowiki>${2}</nowiki>', $src);
|
||||||
|
$args = $this->toArgs($extArgs);
|
||||||
|
|
||||||
|
$type = 'block';
|
||||||
|
if (isset($args['inline'])) {
|
||||||
|
$type = 'inline';
|
||||||
|
}
|
||||||
|
|
||||||
|
$wrapperTag = '';
|
||||||
|
$contextType = '';
|
||||||
|
switch ($type) {
|
||||||
|
case 'inline':
|
||||||
|
$wrapperTag = 'span';
|
||||||
|
$contextType = 'inline';
|
||||||
|
break;
|
||||||
|
case 'block':
|
||||||
|
$wrapperTag = 'div';
|
||||||
|
$contextType = 'block';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $extApi->extTagToDOM(
|
||||||
|
$extArgs,
|
||||||
|
'',
|
||||||
|
$src,
|
||||||
|
[
|
||||||
|
'wrapperTag' => $wrapperTag,
|
||||||
|
'parseOpts' => [
|
||||||
|
'extTag' => 'veval',
|
||||||
|
'context' => $contextType
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace Isekai\Widgets;
|
||||||
|
|
||||||
|
class VEvalWidget {
|
||||||
|
public static function create($text, $params, \Parser $parser, \PPFrame $frame) {
|
||||||
|
$content = $text = $parser->recursiveTagParse($text, $frame);
|
||||||
|
return [$content, "markerType" => 'nowiki'];
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
(()=>{var e={153:e=>{e.exports=function(e,t){var n=e.split(".");"isekai"in window||(window.isekai={});for(var i=window.isekai,r=0;r<n.length-1;r++){var o=n[r];o in i||(i[o]={}),i=i[o]}i[n[r]]=t}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}(()=>{function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}n(153)("ui.DiscoverWidget",function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.baseDom=e,this.pageUrl=null,this.api=new mw.Api,this.initDom(),this.refreshPage()}var n,i;return n=t,(i=[{key:"initDom",value:function(){this.reloadButton=new OO.ui.ButtonWidget({icon:"reload",label:mw.message("isekai-discover-change-btn").parse()}),this.reloadButton.on("click",this.refreshPage.bind(this)),this.readMoreButton=new OO.ui.ButtonWidget({icon:"ellipsis",label:mw.message("isekai-discover-readmore-btn").parse(),flags:["primary","progressive"]}),this.readMoreButton.on("click",this.showMore.bind(this)),this.loadingBar=new OO.ui.ProgressBarWidget({progress:!1}),this.baseDom.find(".card-body .loading .spinner").append(this.loadingBar.$element),this.buttonGroup=new OO.ui.ButtonGroupWidget({items:[this.reloadButton,this.readMoreButton]}),this.baseDom.find(".card-header .card-header-buttons").append(this.buttonGroup.$element),this.loading=this.baseDom.find(".card-body .loading"),this.title=this.baseDom.find(".card-body .card-title"),this.contentContainer=this.baseDom.find(".card-body .card-content")}},{key:"showMore",value:function(){this.pageUrl&&window.open(this.pageUrl)}},{key:"refreshPage",value:function(){var e=this;this.pageUrl=null,this.clearContent(),this.showLoading(),this.getRandomPage().then((function(t){e.loadPage(t)}))}},{key:"setTitle",value:function(e){this.title.text(e)}},{key:"showLoading",value:function(){this.loading.show(),this.contentContainer.hide()}},{key:"hideLoading",value:function(){this.loading.hide(),this.contentContainer.show()}},{key:"clearContent",value:function(){this.contentContainer.children().remove()}},{key:"setContent",value:function(e){this.hideLoading(),this.clearContent(),this.contentContainer.append(e)}},{key:"showError",value:function(e){var t=new OO.ui.MessageWidget({type:"error",label:e});this.setContent(t.$element)}},{key:"getRandomPage",value:function(){var e=this;return new Promise((function(t,n){e.api.get({action:"query",list:"random",rnlimit:1,rnnamespace:0}).done((function(n){if(n.query&&n.query.random&&n.query.random.length>0){var i=n.query.random[0].title;e.setTitle(i),t(i)}else n.error?e.showError(n.error.info):e.showError(mw.message("isekai-discover-error-cannotload").parse())}))}))}},{key:"parseHTMLString",value:function(e){try{return(new DOMParser).parseFromString(e,"text/html")}catch(e){console.error(e.message)}return null}},{key:"loadPage",value:function(e){var t=this,n=mw.util.getUrl(e);this.pageUrl=n,n.indexOf("?")>=0?n+="&":n+="?",n+="action=render",$.get(n,(function(e){var n=$(t.parseHTMLString(e)).find(".mw-parser-output");n.length>0&&(n.find(".toc").remove(),t.setContent(n))}),"html")}}])&&e(n.prototype,i),t}())})()})();
|
(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,o=function(t,n){if("object"!==e(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!==e(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===e(o)?o:String(o)),r)}var o}!function(e,t){var n="ui.DiscoverWidget".split(".");"isekai"in window||(window.isekai={});for(var i=window.isekai,r=0;r<n.length-1;r++){var o=n[r];o in i||(i[o]={}),i=i[o]}i[n[r]]=t}(0,function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.baseDom=t,this.pageUrl=null,this.api=new mw.Api,this.initDom(),this.refreshPage()}var n,i;return n=e,(i=[{key:"initDom",value:function(){this.reloadButton=new OO.ui.ButtonWidget({icon:"reload",label:mw.message("isekai-discover-change-btn").parse()}),this.reloadButton.on("click",this.refreshPage.bind(this)),this.readMoreButton=new OO.ui.ButtonWidget({icon:"ellipsis",label:mw.message("isekai-discover-readmore-btn").parse(),flags:["primary","progressive"]}),this.readMoreButton.on("click",this.showMore.bind(this)),this.loadingBar=new OO.ui.ProgressBarWidget({progress:!1}),this.baseDom.find(".card-body .loading .spinner").append(this.loadingBar.$element),this.buttonGroup=new OO.ui.ButtonGroupWidget({items:[this.reloadButton,this.readMoreButton]}),this.baseDom.find(".card-header .card-header-buttons").append(this.buttonGroup.$element),this.loading=this.baseDom.find(".card-body .loading"),this.title=this.baseDom.find(".card-body .card-title"),this.contentContainer=this.baseDom.find(".card-body .card-content")}},{key:"showMore",value:function(){this.pageUrl&&window.open(this.pageUrl)}},{key:"refreshPage",value:function(){var e=this;this.pageUrl=null,this.clearContent(),this.showLoading(),this.getRandomPage().then((function(t){e.loadPage(t)}))}},{key:"setTitle",value:function(e){this.title.text(e)}},{key:"showLoading",value:function(){this.loading.show(),this.contentContainer.hide()}},{key:"hideLoading",value:function(){this.loading.hide(),this.contentContainer.show()}},{key:"clearContent",value:function(){this.contentContainer.children().remove()}},{key:"setContent",value:function(e){this.hideLoading(),this.clearContent(),this.contentContainer.append(e)}},{key:"showError",value:function(e){var t=new OO.ui.MessageWidget({type:"error",label:e});this.setContent(t.$element)}},{key:"getRandomPage",value:function(){var e=this;return new Promise((function(t,n){e.api.get({action:"query",list:"random",rnlimit:1,rnnamespace:0}).done((function(n){if(n.query&&n.query.random&&n.query.random.length>0){var i=n.query.random[0].title;e.setTitle(i),t(i)}else n.error?e.showError(n.error.info):e.showError(mw.message("isekai-discover-error-cannotload").parse())}))}))}},{key:"parseHTMLString",value:function(e){try{return(new DOMParser).parseFromString(e,"text/html")}catch(e){console.error(e.message)}return null}},{key:"loadPage",value:function(e){var t=this,n=mw.util.getUrl(e);this.pageUrl=n,n.indexOf("?")>=0?n+="&":n+="?",n+="action=render",$.get(n,(function(e){var n=$(t.parseHTMLString(e)).find(".mw-parser-output");n.length>0&&(n.find(".toc").remove(),t.setContent(n))}),"html")}}])&&t(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}())})();
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
|||||||
console.log("Hello World!");
|
|
@ -1,63 +0,0 @@
|
|||||||
@playIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/play.svg');
|
|
||||||
@loopIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/loop.svg');
|
|
||||||
@stopIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/stop.svg');
|
|
||||||
@pauseIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/pause.svg');
|
|
||||||
@muteIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/volume-mute.svg');
|
|
||||||
@volumeLowIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/volume-low.svg');
|
|
||||||
@volumeMediumIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/volume-medium.svg');
|
|
||||||
@volumeHighIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/volume-high.svg');
|
|
||||||
@enlargeIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/enlarge.svg');
|
|
||||||
@shrinkIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/shrink.svg');
|
|
||||||
@playlistIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/list.svg');
|
|
||||||
@nextIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/next.svg');
|
|
||||||
@prevIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/prev.svg');
|
|
||||||
@firstIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/first.svg');
|
|
||||||
@lastIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/last.svg');
|
|
||||||
@forwardIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/forward.svg');
|
|
||||||
@backwardIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/backward.svg');
|
|
||||||
@shareIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/share.svg');
|
|
||||||
@equalizerIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/equalizer.svg');
|
|
||||||
@ejectIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/eject.svg');
|
|
||||||
@shuffleIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/shuffle.svg');
|
|
||||||
@randomIconLight: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/light/dice.svg');
|
|
||||||
|
|
||||||
@playIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/play.svg');
|
|
||||||
@loopIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/loop.svg');
|
|
||||||
@stopIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/stop.svg');
|
|
||||||
@pauseIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/pause.svg');
|
|
||||||
@muteIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/volume-mute.svg');
|
|
||||||
@volumeLowIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/volume-low.svg');
|
|
||||||
@volumeMediumIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/volume-medium.svg');
|
|
||||||
@volumeHighIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/volume-high.svg');
|
|
||||||
@enlargeIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/enlarge.svg');
|
|
||||||
@shrinkIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/shrink.svg');
|
|
||||||
@playlistIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/list.svg');
|
|
||||||
@nextIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/next.svg');
|
|
||||||
@prevIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/prev.svg');
|
|
||||||
@firstIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/first.svg');
|
|
||||||
@lastIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/last.svg');
|
|
||||||
@forwardIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/forward.svg');
|
|
||||||
@backwardIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/backward.svg');
|
|
||||||
@shareIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/share.svg');
|
|
||||||
@equalizerIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/equalizer.svg');
|
|
||||||
@ejectIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/eject.svg');
|
|
||||||
@shuffleIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/shuffle.svg');
|
|
||||||
@randomIconDark: data-uri('image/svg+xml;charset=UTF-8', 'source/images/media/dark/dice.svg');
|
|
||||||
|
|
||||||
@checkIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/checkmark.svg');
|
|
||||||
@crossIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/cross.svg');
|
|
||||||
@searchIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/search.svg');
|
|
||||||
@eyeIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/eye.svg');
|
|
||||||
@plusIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/plus.svg');
|
|
||||||
@minusIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/minus.svg');
|
|
||||||
@helpIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/help.svg');
|
|
||||||
@leftArrowIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/arrow-left.svg');
|
|
||||||
@rightArrowIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/arrow-right.svg');
|
|
||||||
@calendarIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/calendar.svg');
|
|
||||||
@clockIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/clock.svg');
|
|
||||||
@menuIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/menu.svg');
|
|
||||||
@uploadIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/upload.svg');
|
|
||||||
@pencilIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/pencil.svg');
|
|
||||||
@chevronLeftIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/chevron-left.svg');
|
|
||||||
@chevronRightIcon: data-uri('image/svg+xml;charset=UTF-8', 'source/images/apps/chevron-right.svg');
|
|
||||||
|
|
Loading…
Reference in New Issue