Extension talk:Widgets

About this board

Old messages are archived.


Widgets loaded before mw.hook is available

3
PetraMagna (talkcontribs)

I ported some functional widgets from a different wiki running MW 1.31 and Widgets v1.3.1 to mine, which is running MW 1.38 and Widgets v1.4.1. However, some of these ported widgets are not working. In particular, I see errors about mw.hook and mw.loader.using not being a function.

I tried to log them in the console as the widget loads, mw shows up as an object with all the expected properties, but mw.hook and mw.loader.using are both undefined.

A simple script to reproduce the issue is as follows:

window.RLQ.push(async () => {
    console.log(mw); // this shows up as a regular object
    console.log(mw.loader.using); // this shows up as undefined
    console.log(mw.hook); // this shows up as undefined
});

I typed the names of all these packages in the console after the web page loaded. Everything shows up normally, implying that the widget is perhaps loaded before core mw packages are available.

I feel like I'm missing something very obvious, but I don't know much about javascript and cannot find any migration guides/tutorials that may explain this phenomenon. Everything I saw suggested that mw.hook and mw.loader.using are loaded before everything else and that I don't need to do anything special to use them. Any help is appreciated. Thank you!

Cavila (talkcontribs)

Hi, I honestly don't know but you're relying on a number of ResourceLoader's core modules (mw.loader.using, etc.). As far as I know, the Widgets extension has no support for them out of the box, so I wonder how that issue was solved on the older wiki.

One hack you could try, though it really is a stab in the dark, is to edit extension.json and load the required modules as dependencies, which may or may not also include jQuery.

Another route you might consider is move your JavaScript to MediaWiki:Common.js instead, which comes with built-in support for ResourceLoader although you will probably have to rewrite some of your code (or have it rewritten).

PetraMagna (talkcontribs)

@Cavila Thanks for the reply! I saw in another thread called "JQuery access" that upgrading from MW 1.31 to 1.34 breaks jquery, so the issues with mw.hook and mw.loader.using might have a similar cause.

I thought extension.json configures the dependencies of an extension, so it shouldn't affect the order in which js scripts are loaded?

Reply to "Widgets loaded before mw.hook is available"

What triggers widgets to get cached/compiled?

2
Justin C Lloyd (talkcontribs)

Our wikis have a lot of widgets, some of which I'm seeing get recompiled into the compiled_templates directories many times per minute, even sometimes multiple times in a second. In that particular example, the only thing changing in the compiled code is the JS function name that is randomly generated by the call to PHP uniqid('', true). Is this probably something with how our Widgets are written, or perhaps about how they are used within templates and themselves use templates (it gets messy)? FWIW a while back I opened a Phabricator task on this.

Justin C Lloyd (talkcontribs)

Any thoughts on my question?

Reply to "What triggers widgets to get cached/compiled?"
Farvardyn (talkcontribs)

I upgraded from 1.34 to 1.38 and got Widgets error, so I used your manual for "mediawiki version 1.31 and later', it seems everything is done fine and I get no error, but Widgets.php is not under /Widgets folder. Why this file is missing from your git? I copied Widgets.php from my older 1.34 version to this new folder, but it seems there are still problems.

Kghbln (talkcontribs)

Did you migrate to wfLoadExtension( 'Widgets' );? See here.

Reply to "Widgets.php was not found!"

How to render mediawiki syntax before sending to a widget

1
FrViPofm (talkcontribs)

Hi, making a flashcard system on my wiki using SMW (flashcards are defined in pages and available in portals), the display is made with tabs with the input-radio trick (see for example : https://www.youtube.com/watch?v=oLqdy95LZSw ). So the html structure and css are in Widget:Flashcard.

But questions and answers may have links to pages (definitions...), images... in wikicode. And they are not rendered after being sent to the widget witch displays raw code.

Is it a way to render them ? Thanks

Reply to "How to render mediawiki syntax before sending to a widget"

Captcha on mediawikiwidgets.org not working

2
206.214.228.200 (talkcontribs)

Having issues creating a new account on mediawikiwidgets.org because the time calculation captcha says my answers are wrong. I have tried every combination of syntax I can think of. Any ideas how to get it to work?

Kghbln (talkcontribs)

Try e.g. 10:22. Probably you added the brackets [] which should not be done.

Reply to "Captcha on mediawikiwidgets.org not working"
2604:2D80:E507:3000:A5BA:527E:A9AE:8B43 (talkcontribs)

After trying to up any widget in i get "forbidden". I changed the dir to 777 and still no dice. Specifically iframe and form code gets me the forbidden.

Kghbln (talkcontribs)

Note that a lot of websites nowadays disallow iframing. This is probably where your "forbidden" comes from. Apart from that, I do not know.

Reply to "Forbidden?"

Error: Class 'Smarty' not found

4
94.223.127.19 (talkcontribs)

I got this error after updating my wiki recently. I tried to follow the steps under Installation from a .zip file, but I got a little confused by the wording.

So I installed the newest Widgest extension and then created a folder named 'smarty" (extensions/Widgets/smarty). Then I downloaded the newest Version of Smarty, unzipped it, and put the 'libs' folder in extensions/Widgets/smarty/libs.

But it didn't change anything, I still got the error message. What did I do wrong?

MGChecker (talkcontribs)

Please try installing the extension via Git, since the method via unzipping Smarty manually is outdated.

If you can not use git or composer directly on your server, you can run the respective command locally and afterwards upload the whole folder.

Gesslar (talkcontribs)

I am having the same error, but when I attempt to import from another wiki.


installed via git from github wikimedia/mediawiki-extensions-Widgets


I get the following:

[fae15bd5e378e271a99d65f5] /index.php?title=Special:Import&action=submit Error from line 24 of /frogdice/servers/com.thresholdrpg.wiki/extensions/mediawiki-extensions-Widgets/WidgetRenderer.php: Class 'Smarty' not found


@Gesslar

MGChecker (talkcontribs)

As stated in the documentation at Extension:Widgets#Download, you need to run Composer afterwards. This can also be done at your local machine before syncing with the server.

Reply to "Error: Class 'Smarty' not found"

Unable to load template 'wiki:Iframe'

1
JanTappenbeck (talkcontribs)

hi !

i want to use in lokal wiki the Widget#Iframe.

The folder ..\extensions\Widgets\compiled_templates has full permisson to IIS_IUSRS and the .htaccess file, include this folder (source: deny from all) i rename.

the template .../index.php?title=Vorlage:Wiki:Iframe is create with

<includeonly><iframe src="<!--{$url|validate:url}-->" style="border: <!--{$border|escape:html|default:0}-->" width="<!--{$width|escape:html|default:400}-->" height="<!--{$height|escape:html|default:300}-->"></iframe></includeonly>

then i copy the example into side - but now i get the misstake:

Unable to load template 'wiki:Iframe'

did someone could help?

regards Jan

os Windows Server 2016
mediawiki 1.36.1
php php-7.4.20-nts-Win32-vc15-x64
mysql mysql-5.7.12-winx64
Reply to "Unable to load template 'wiki:Iframe'"
192.69.180.130 (talkcontribs)

I cannot figure out this write error. It randomly started doing this recently, and the widget I'm using was working as of last week.


I'm receiving the following error:

Error in widget iframe unable to write file

Widgets slash compiled_templates slash wrt609346e2956705_70999129 (since I was getting a damn spam error)

The directory is currently 775 permissions. I even reinstalled it from the base git and did the instructions needed for my version, 1.32. Any help would be appreicated.

MMDUser (talkcontribs)

I'm receiving a similar error:

Unable to write file D:\home\site\wwwroot\extensions\Widgets\compiled_templates\d3288ecdd0052c9fea052081eede316e4be8e7d1_0.wiki.LearningPathMMD.php


How do I restore this page?

Reply to "Write error"

Google Presentation doesn't show

4
AdSvS (talkcontribs)

Hi, when I use the Google Presentation widget I only get a white plane in the place where the presentation should be. It doesn't say that the document doesn't exist (which it does when I change the docid) so apparently that is not the problem. But what is, I don't know!

89.178.102.165 (talkcontribs)

I have the same problem. It appears to be something wrong with new presentations. Old presentations with short ids can be displayed.

89.178.102.165 (talkcontribs)
174.88.166.175 (talkcontribs)

@AdSvS Hi, was there ever a solution or alternative to displaying presentations? thanks

Reply to "Google Presentation doesn't show"