Jump to content

Extension talk:Widgets

About this board

Old messages are archived.


Michael Z Freeman (talkcontribs)
Yaron Koren (talkcontribs)

Amazingly, it looks like there's no standard widget yet for displaying a tweet, er, X post. (I think that text is there just to display something before the tweet finishes loading, by the way - the API is being accessed.) You could create the widget yourself, potentially...

Michael Z Freeman (talkcontribs)

"I think that text is there just to display something before the tweet finishes loading, by the way - the API is being accessed."

Ah, really ? Right. I’ll go back to trying this again.

So actually consulting the X API using https://publish.twitter.com/oembed?url=https://twitter.com/Michael86084836/status/1798253963143528714 gives ...

{"url":"https:\/\/twitter.com\/Michael86084836\/status\/1798253963143528714","author_name":"Michael Freeman","author_url":"https:\/\/twitter.com\/Michael86084836","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003E“We are awake to their woke"\u003Ca href=\"https:\/\/t.co\/5dRMkPd32a\"\u003Ehttps:\/\/t.co\/5dRMkPd32a\u003C\/a\u003E\u003C\/p\u003E— Michael Freeman (@Michael86084836) \u003Ca href=\"https:\/\/twitter.com\/Michael86084836\/status\/1798253963143528714?ref_src=twsrc%5Etfw\"\u003EJune 5, 2024\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}

Can I parse this, I think it’s JSON ? Does anyone know a widget example ?

Yaron Koren (talkcontribs)

Why parse it - why not just create a widget that displays the necessary HTML?

Michael Z Freeman (talkcontribs)

Sorry, having real problems getting started here. Can you give me a few clues as to what I need to look at ?

Michael Z Freeman (talkcontribs)

Could I filter that X response with something live "regex_replace:"#^(?!(https?:)?//).*#I":’' ? That’s taken from the iFrame widget.

Yaron Koren (talkcontribs)

Sorry for the delay. Actually, there is a Tweet widget - and it seems to still work fine, even though it was pre-name change. Have you tried it?

Reply to "Twitter/X Widget ?"

How to pass an array into widget

1
JeremiPlazas (talkcontribs)

Hi there,

I noticed in the doc it says:

"If you use the same parameter multiple times, the widget will get an array of values. You can use foreach to go through the array."

That's nice for manually specifying values. But actually passing a list of values into a widget gets more complicated and i have not yet been successful at transforming

one,two,three

into

|arrayValue=one|arrayValue=two|arrayValue=three

In order to then feed into the widget and indeed get a working array that you can iterate through.

I've tried arraymap[template] without luck. The pipe gets parsed too late.

Any thoughts, ideas? Thanks!

Reply to "How to pass an array into widget"

MediaWiki Search does not work on Widgets!

4
2A02:8388:15BF:C180:E8AB:38E6:17F1:733B (talkcontribs)

I am running MediaWiki 1.39.5. We have a Widget that loads projects information from OpenAIRE and make it available to all pages within our mediawiki setup. Widgets work perfectly fine. What we want is to do search over these loaded project information via MediaWiki search. However, The search provided by MediaWiki does not find these loaded information. We have tried advanced search but nothing happened. How can i search this data inside mediawiki? Do i need separate search function for this kind of data?

Ciencia Al Poder (talkcontribs)

MediaWiki search only has the data available in the wiki code of each page. Widgets load content from external sources on the browser, not on the server, and that's why MediaWiki search can't find it

2A02:8388:15BF:C180:E8AB:38E6:17F1:733B (talkcontribs)

Ahaan! so, what is the best way to perform search on this kind of data in mediawiki?

Ciencia Al Poder (talkcontribs)

There's no way to do that. A bot or some other automatic process would need to fetch the data and store it on the wiki page directly instead of relying on external requests (widgets)

Reply to "MediaWiki Search does not work on Widgets!"

Is this extension compatible with PHP 8.2?

5
Peculiar Investor (talkcontribs)

I am running MediaWiki 1.39.5 and recently switched to PHP 8.2.x (8.2.12 currently).

We have a Widget test page that loads sample Google presentation, Google document and Google Spreadsheet widgets.

All appear okay. However in the error_log we get:

[07-Nov-2023 23:12:33 UTC] PHP Warning: Undefined array key "width" in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 24 [07-Nov-2023 23:12:33 UTC] PHP Warning: Attempt to read property "value" on null in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 24 [07-Nov-2023 23:12:33 UTC] PHP Warning: Undefined array key "height" in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 25 [07-Nov-2023 23:12:33 UTC] PHP Warning: Attempt to read property "value" on null in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 25

I have gone through the individual Widget pages and purged the page so that the compiled templates are refreshed.

These seem to be indicative of something not compatible with PHP 8.2 changes or is some step required to recompile the template(s)?

Kghbln (talkcontribs)

I doubt it. Anyhow, MediaWiki is not compatible with PHP 8.2 either. Did the widget work with earlier versions of PHP, MediaWiki, and Widgets?

Peculiar Investor (talkcontribs)

According to Compatibility#PHP MediaWiki support for PHP 8.0 and above started with 1.39.0. The recent 1.39.5 release announcement makes mention that "Various patches aimed at PHP 8.0, 8.1, and 8.2 support have been back-ported."

The Widget's work as far as the end-user knows. The PHP Warnings in the error_log are something I would expect the Extension:Widgets developers to address.

Cavila (talkcontribs)

I don't know what your widget looks like and how it is used, so this is a wild guess, but the error messages read like the values for those parameters have not been specified. If those values were omitted, did you at least provide defaults or provided an 'if' condition to prevent such errors from occurring?

Cavila (talkcontribs)

Returning to this... I had the same issue, recently. At some point, the Widget extension has become less forgiving when you do not set a value for a parameter defined in the widget, which will trigger the warning you encountered. Like I mentioned at the time, you can use an 'if' condition to get around this[1], but what I didn't know is that defaults (https://www.smarty.net/docs/en/language.modifier.default.tpl) no longer seem to work and will emit same error message. I used the REL1.39 branch of the extension, which installed version 1.4.2, and I am using PHP 8.0.

This no longer works:

<!--{$myparam|escape:'quotes'|default:'Nothing to see here'}

It looks like the issue began with the inclusion of modifier.allowedvalues.php, which does not check for defaults.

[1] For anyone looking for am example, this solution checks if the param is set at all and if it is, if the value is not 'empty', similar to how you would wiki templates

<!--{if ( isset($myparam) && $myparam!="" )}-->
<!--{$myparam|escape:'quotes'}-->
<!--{else}-->
Nothing to see here [optional default]
<!--{/if}-->
Reply to "Is this extension compatible with PHP 8.2?"

How to render mediawiki syntax before sending to a widget

2
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

Chaeidras (talkcontribs)

I would also like to know if it is possible to send wikicode through the extension to be rendered. It would open up much more flexibility in my use case.

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

Twitter widget not working anymore since new Twitter method to share feed

5
Summary by DSquirrelGM

Widget code updated on MediaWikiWidgets.

Albert Ke (talkcontribs)

Hi all,

I just want to make people aware that the twitter feed widget is not working anymore since September 10th. I have marked them as such in the list (crossed text through). They don't work anymore as twitter changed there method of how you can tab into your twitter feed and removed the old option to link to your twitter feed

MGChecker (talkcontribs)
Kelson (talkcontribs)

Here is how mine works now, `id` is the Twitter user at:

* https://wiki.kiwix.org/wiki/Main_Page

* https://wiki.kiwix.org/wiki/Widget:Twitter

DSquirrelGM (talkcontribs)
Hurohukidaikon (talkcontribs)
Reply to "Twitter widget not working anymore since new Twitter method to share feed"

What triggers widgets to get cached/compiled?

5
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?

Revansx (talkcontribs)

I would like to understand this better too for similar reasons.

Revansx (talkcontribs)
Bawolff (talkcontribs)

it looks like the extension is currently using ParserAfterTidy hook to decide this, which is probably not the most correct option. Something LinksUpdate related would be better (although have to be careful about asyncness of linksupdate)

Reply to "What triggers widgets to get cached/compiled?"

Class "FlaggedArticle" not found

10
Manifestation (talkcontribs)

I use a Windows laptop with XAMPP. After I installed this extension, I enabled FlaggedRevs. However, when I then tried to save a page that transcluded a widget, I got this Internal error:

[67a635e5d3c566814dbcfeab] /wiki/Main_Page Error: Class "FlaggedArticle" not found

Backtrace:
from C:\xampp\htdocs\w\extensions\Widgets\SmartyResourceWiki.php(34)
#0 C:\xampp\htdocs\w\extensions\Widgets\vendor\smarty\smarty\libs\sysplugins\smarty_resource_custom.php(75): SmartyResourceWiki->fetch(string, NULL, NULL)
#1 C:\xampp\htdocs\w\extensions\Widgets\vendor\smarty\smarty\libs\sysplugins\smarty_template_source.php(211): Smarty_Resource_Custom->getContent(Smarty_Template_Source)
(...)

I don't think I have to post the entire log, but you get the idea. 😉

I can edit the Widget: page just fine. Approving and rejecting revisions also works. But when I try to transclude the widget, it crashes. The problem disappears when I turn FlaggedRevs off.

Yaron Koren (talkcontribs)

Sorry about that - this turned out to be a bug from 2012! I guess Widgets and FlaggedRevs don't get used much together. Anyway, I just checked in what I believe is a fix.

Manifestation (talkcontribs)

You did? That's great!

Manifestation (talkcontribs)
Yaron Koren (talkcontribs)

I think so...

Manifestation (talkcontribs)

This is really weird. I updated your extension using Composer. But apparently something went wrong. Composer only updated certain files, but not all. 😕

I then tried downloading the entire extension manually from the ExtensionDistributor. When I went there, it said "1.40 (latest stable MediaWiki)".

I was still on 1.39, so I upgraded to 1.40. As a result, my entire wiki collapsed. 1.40 doesn't appear to support Flagged Revisions at all! I posted about it here and here.

Manifestation (talkcontribs)

@Yaron Koren: Sorry for the confusion. I fixed the above issue.

I now have the latest stable MW version. I have the latest version of FlaggedRevs. I downloaded the latest version of Widgets (for MW 1.40) via Special:ExtensionDistributor. But it still gives me the exact same error.

Manifestation (talkcontribs)

@Yaron Koren: Ok, scratch that. I now downloaded the alpha version, i.e. the master version, i.e. the development version. Now it does work. Why is everything so complicated! 😩

Yaron Koren (talkcontribs)

It's not quite as complicated as you may have thought - you only had to switch to the latest version of the Widgets extension, not upgrade MediaWiki or FlaggedRevs. But I'm glad everything works now.

Manifestation (talkcontribs)

@Yaron Koren: Yeah I know, and I apologize for my convoluted response.

Do you know when the alpha/development/master version will become the stable version?

Reply to "Class "FlaggedArticle" not found"
2804:14C:6584:4F38:EC78:D90E:A50A:85DE (talkcontribs)

I'm getting the 502 Bad Gateway error when I save a page in my wiki that has the Widget template called, how do I solve this problem?

Reply to "502 Bad Gateway"

relative URL for a widget

2
Chantoune (talkcontribs)

I am using the widget video given in the list of already designed widgets

but this one use an absolute url

and i want something like src= instead of URL=

because videos are locales to my wiki and not external

Could you please give me the syntax to change this

best regards

Because in my old version of mediawiki i used HTML5Video extension and now with version 1.39 of mediawiki it doesn't work

Cavila (talkcontribs)

I would think that the Video widget already makes use of src internally. I'm not sure what you by mean "videos are locales to my wiki", but there's a couple of things you could do.

  • You could rewrite the widget to make use of $_SERVER['SERVER_NAME' ]
  • You could rewrite the widget to include a hard-coded reference to the domain.

Or before passing stuff to the widget:

  • You could use prefix your relative urls with Help:Magic words: e.g. https:{{SERVER}}/
  • If a video is uploaded to the wiki, you can retrieve its url by using filepath

Hope that helps.

Reply to "relative URL for a widget"