Jump to content

Extension talk:Widgets

About this board

Old messages are archived.


2001:B011:300D:10F3:42D5:9A1:DC5F:86BA (talkcontribs)
  • 傳入參數使用wiki的語法時,無法正確轉換,會變成文字直接輸出?無解?
  • widget:Infobox
<includeonly>
<table class="infobox" cellspacing="5" style="width: 450px; font-size: 90%; text-align: left;"><tbody>

<tr><td colspan="2" style="text-align: center; font-size: 130%; font-weight: bold;"><!--{$name|default:""}--></td></tr>
<tr><td colspan="2" style="text-align: center;"><!--{$logo|default:""}--></td></tr>

<!--{if $screenshot neq ""}-->
<tr><td colspan="2" style="text-align: center;"><!--{$screenshot|default:""}--><br /><!--{$caption|default:""}--></td></tr>
<!--{/if}-->

<!--{assign var="i" value=1}-->
<!--{while $i<=30}-->
<!--{assign var="label" value=$<!--{"label$i"}-->}-->
<!--{assign var="data" value=$<!--{"data$i"}-->}-->
<!--{if ($data|default:"") neq ""}-->
<tr><td><!--{$label|default:""}--></td><td><!--{$data|default:""}--></td></tr>
<!--{/if}-->
<!--{assign var="i" value=$i+1}-->
<!--{/while}-->

</tbody></table>
</includeonly>
  • Template:Infobox software2
{{#widget:Infobox
|name = {{{name}}}
|logo = {{{logo|}}}
|screenshot = {{{screenshot|}}}
|caption = {{{caption|}}}
| label1 = 其他名稱
| data1 = {{{other_names|}}}
| label2 = 原作者
| data2 = {{{author|}}}
| label3 = 開發者
| data3 = {{{developer|}}}
| label4 = 首次發佈
| data4 = {{{released|}}}
| label5 = {{#if:{{{discontinued|}}}|最終版本|當前版本}}
| data5 = {{{latest release|}}}
| label6 = 原始程式
| data6 = {{{repo|}}}
| label7 = 程式語言
| data7 = {{{programming language|}}}
| label8 = 中間件
| data8 = {{{middleware|}}}
| label9 = 引擎
| data9 = {{{engines|}}}
| label10 = 作業系統
| data10 = {{{operating system|{{{operating_system|}}}}}}
| label11 = 系统平台
| data11 = {{{platform|}}}
| label12 = 内置於
| data12 = {{{included with|{{{included_with|}}}}}}
| label13 = 取代
| data13 = {{{replaces|}}}
| label14 = 由…取代
| data14 = {{{replaced_by|}}}
| label15 = 服務名稱
| data15 = {{{service_name|}}}
| label16 = 文件大小
| data16 = {{{size|}}}
| label17 = 標準
| data17 = {{{standard|}}}
| label18 = 語言
| data18 = {{#if:{{{language count|}}}|{{{language count}}}種語言|{{{language|}}}}}{{{language footnote|}}}
| data19 = {{#if:{{{language count|}}}|{{#if:{{{language|}}}|{{hidden begin|toggle=left|title=语言列表|titlestyle=background-color: transparent;}}{{{language|}}}{{hidden end}}}}}}
| label20 = 類型
| data20 = {{{genre|}}}
| label21 = 授權方式
| data21 = {{{license|}}}
| label22 = 網站
| data22 = {{{website|}}}
| data23    = {{{嵌入插座|{{{embedded|{{{module|}}}}}}}}}
| label24 = 數據截至
| data24 = {{{AsOf|}}}
}}
  • Test
{{Infobox Software2
| name = 7-Zip
| developer = Igor Pavlov
| released = {{Start date and age|1999|7|19|df=yes}}
| latest release version = 24.07
| latest release date    = {{start date and age|2024|06|19}}
| programming language = [[組合語言]]、[[C]]、[[C++]]
| operating system = [[Windows]]/[[ReactOS]], [[BSD]], [[macOS]], [[Linux]]
| language count = 89
| genre = 檔案壓縮
| license = https://7-zip.org/license.txt
| website = https://7-zip.org
}}
-2001:B011:300D:10F3:42D5:9A1:DC5F:86BA 12:34, 11 August 2024 (UTC)
Reply to "實驗失敗中"
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&quot;\u003Ca href=\"https:\/\/t.co\/5dRMkPd32a\"\u003Ehttps:\/\/t.co\/5dRMkPd32a\u003C\/a\u003E\u003C\/p\u003E&mdash; 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"