MediaWiki talk:Gadget-Preview.js

From Wikidata
Jump to navigation Jump to search

Preview of search results[edit]

I think will be great to have preview functionality for search results. Should show preview of article on currently selected language (if article exist). --EugeneZelenko (talk) 15:29, 10 February 2013 (UTC)[reply]

I don't understand this proposal. Do you mean Special:Search? And which article should be previewed? --Bene* talk 22:07, 10 February 2013 (UTC)[reply]
Yes, you are correct, I meant Special:Search. Preview link should be for every item in search results. Preview of article on currently selected user language should be shown (if exist).
Actually functionality will be useful for items in properties values. Just to verify that right item was selected in case of ambiguous names.
EugeneZelenko (talk) 02:35, 11 February 2013 (UTC)[reply]

encodeURI[edit]

mw.util.wikiUrlencode() should be used instead of encodeURI(). --Fomafix (talk) 13:55, 13 February 2013 (UTC)[reply]

I put this and a lot of other changes into User:Fomafix/MediaWiki:Gadget-Preview.js (diff). --Fomafix (talk) 23:07, 15 February 2013 (UTC)[reply]
Do you plan any other changes? Otherwise I will implement your version. --Bene* talk 00:45, 17 February 2013 (UTC)[reply]
I did some more changes (diff). I’ll do more changes when I find more bugs or improvements. --Fomafix (talk) 10:56, 17 February 2013 (UTC)[reply]

When you implement my version you have to change in MediaWiki:Gadgets-definition from

Preview[ResourceLoader|dependencies=jquery.spinner]|Preview.js

to

Preview[ResourceLoader|dependencies=mediawiki.util,jquery.spinner]|Preview.js

. --Fomafix (talk) 10:56, 17 February 2013 (UTC)[reply]

I have added the changes, thanks a lot :-) --Bene* talk 12:39, 23 February 2013 (UTC)[reply]

fa.wiki[edit]

please add this translation for farsi

		'fa': {
			'title' :'پیش‌نمایش مقاله',
			'preview' :'پیش‌نمایش',
			'noarticle' :'شما هنوز مقاله‌ای را انتخاب نکرده‌اید.',
			'readmore' :'مطالعهٔ بیشتر',
			'hide' :'پنهان',
			'show' :'نمایش'
		},

Reza1615 (talk) 19:28, 14 February 2013 (UTC)[reply]

✓ Done. --Stryn (talk) 20:21, 15 February 2013 (UTC)[reply]

Some tweaks[edit]

Hi, thanks for this great gadget. I've made some tweaks and you can get the script from User:Inductiveload/scripts/Preview.js. Changes are:

  • Put the preview in the table directly under the relevant sitelink to reduce scrolling.
  • Add a translate link which will open a page with a Google translation of the text (I couldn't get it to do it in-place, as this needs an API key)

Feel free to take anything you like out of this script. I don't have the Farsi translations for "translate" and "remove" so they are still in English. Inductiveload (talk) 20:50, 23 February 2013 (UTC)[reply]

Spanish[edit]

                break;
	default:
	case 'es':
		mw.messages.set( {
			'title' :	'Previsualización del artículo',
			'preview' :	'previsualizar',
			'noarticle' :	'Aún no seleccionaste ningún artículo.',
			'readmore' :	'Leer más',
			'hide' :	'ocultar',
			'show' :	'mostar'
		} );

Please add this translation. --Vivaelcelta (talk) 01:43, 3 March 2013 (UTC)[reply]

✓ DoneReza1615 / T 09:40, 3 March 2013 (UTC)[reply]

Galician[edit]

{{edit request}}

                break;
	default:
	case 'gl':
		mw.messages.set( {
			'title' :	'Previsualización do artigo',
			'preview' :	'previsualizar',
			'noarticle' :	'Aínda non seleccionaches ningún artigo.',
			'readmore' :	'Ler máis',
			'hide' :	'ocultar',
			'show' :	'amosar'
		} );

Please add this translation. --Vivaelcelta (talk) 01:43, 3 March 2013 (UTC)[reply]

✓ Done. --Stryn (talk) 08:53, 3 March 2013 (UTC)[reply]

Italian[edit]

		'it': {
			'title' :'Anteprime della voce',
			'preview' :'anteprima',
			'noarticle' :'Non hai ancora selezionato una voce.',
			'readmore' :'Leggi tutto',
			'hide' :'nascondi',
			'show' :'mostra'
		},

Thanks. --ValterVB (talk) 08:39, 3 March 2013 (UTC)[reply]

✓ Done. Btw you're admin, so you can do this itself :) --Stryn (talk) 08:53, 3 March 2013 (UTC)[reply]

Indonesian & Minangkabau[edit]

Please add Indonesian & Minangkabau translations.

	case 'id':
		mw.messages.set( {
			'title' :	'Pratayang artikel',
			'preview' :	'pratayang',
			'noarticle' :	'Anda belum memilih artikel.',
			'readmore' :	'Lebih lanjut',
			'hide' :	'sembunyikan',
			'show' :	'tunjukan'
		} );
                break;
	case 'min':
		mw.messages.set( {
			'title' :	'Pratonton laman',
			'preview' :	'pratonton',
			'noarticle' :	'Sanak alum mamiliah laman.',
			'readmore' :	'Labiah lanjuik',
			'hide' :	'suruakan',
			'show' :	'tunjuakan'
		} );
                break;

Thanks in advance.  Ę-oиė  >>> 

✓ Done--CENNOXX (talk) 02:53, 20 March 2013 (UTC)[reply]

French[edit]

{{Edit request}}

	case 'fr':
		mw.messages.set( {
			'title' :	'Visualisation des articles',
			'preview' :	'visualiser',
			'noarticle' :	'Aucun article n'est sélectionné.',
			'readmore' :	'Lire la suite',
			'hide' :	'masquer',
			'show' :	'afficher'
		} );
                break;

Merci. Ljubinka (discussion) 14:56, 6 April 2013 (UTC)[reply]

✓ Done, thanks --Bene* talk 16:12, 6 April 2013 (UTC)[reply]

bn[edit]

	case 'bn':
		mw.messages.set( {
			'title' :	'নিবন্ধ প্রাকদর্শন',
			'preview' :	'প্রাকদর্শন',
			'noarticle' :	'আপনি এখনও কোন নিবন্ধ নির্বাচন করেন নি।',
			'readmore' :	'আরও পড়ুন',
			'hide' :	'লুকাও',
			'show' :	'দেখাও'
		} );
		break;

--Aftab1995 (talk) 14:59, 16 April 2013 (UTC)[reply]

✓ Done Thanks--DangSunM (talk) 16:29, 16 April 2013 (UTC)[reply]

In this change you the following lines are missing

		} );
		break;

For 'cs' there is also a break; is missing. --Fomafix (talk) 17:32, 16 April 2013 (UTC)[reply]

✓ Fixed. --Stryn (talk) 17:59, 16 April 2013 (UTC)[reply]

Ideas[edit]

Great gadget! Just some ideas:

  1. It's nowhere documented. Most other gadgets are listed under Wikidata:Tools#Gadgets, some have links in the preferences, this isn't.
  2. As it only displays the first section, it fails to display articles that start with a header (e.g. some disambiguation pages).
  3. It's nice it proposes me to preview the article in my defined language. It would be great if it could just preview it automatically (maybe that could be configured somehow?).
  4. When using a (not very) low screen resolution, it moves to the bottom of the page, while there still might be enough space on its original position in the upper right.

--YMS (talk) 17:33, 8 May 2013 (UTC)[reply]

Edit Request[edit]

{{Edit protected}}

In bn Translation replace this line 'hide' : 'লুকাও', with this

 'hide' :	'আড়াল করো',

(this one used in bn wikipedia)

--Aftab1995 (talk) 13:35, 21 May 2013 (UTC)[reply]

✓ Done The Anonymouse (talk | contribs) 17:34, 21 May 2013 (UTC)[reply]

Problems[edit]

I am currently not abel to see a Preview can someone confirm this? --Sk!d (talk) 23:10, 8 July 2013 (UTC)[reply]

I can confirm this. --Stryn (talk) 23:15, 8 July 2013 (UTC)[reply]
I suspect the problem is caused by the fact that languages now appear as **lang**wiki (e.g. enwiki) instead of just the language code. Harryboyles (talk) 12:42, 10 July 2013 (UTC)[reply]
User:Aude/preview.js is my attempt to make it work and forward compatible for when we get Wikivoyage site links.
Note that I'm not sure exactly what the default behavior was before. Did it show the article preview automatically for your language? or did you need to click to see the preview? (my personal preference is to show a preview automatically, but then can click to see previews for the other site links and is how my version of the script works) Aude (talk) 00:28, 13 July 2013 (UTC)[reply]
The gadget version doesn't automatically preview the default language first, but if yours does it automatically, I would use yours instead. Harryboyles (talk) 03:27, 13 July 2013 (UTC)[reply]

Error[edit]

if( !mw.config.get( 'wbEntityType' ) === 'item' ){ is wrong. On Special:Watchlist mw.config.get( 'wbEntityType' ) evaluates to null. But ( !null === 'item' ) evaluates to false. The code should be if ( mw.config.get( 'wbEntityType' ) !== 'item' ) { because ( null !== 'item' ) evaluates to true. --Fomafix (talk) 23:08, 13 September 2013 (UTC)[reply]

✓ Done --Ricordisamoa 03:22, 14 September 2013 (UTC)[reply]

Feature request for popups[edit]

Thanks a lot for this tool. Would it be much work to get it making popups like Wikipedia:Tools/Navigation popups (Q11305696)? That would be amazing! Regards and thanks in advance for any answer, --Marsupium (talk) 13:46, 19 January 2014 (UTC)[reply]

Chinese[edit]

case 'zh':
case 'zh-cn':
case 'zh-hans':
case 'zh-my':
case 'zh-sg':
	mw.messages.set( {
		'title' :	'条目预览',
		'preview' :	'预览',
		'noarticle' :	'您尚未选择一个条目。',
		'readmore' :	'阅读更多',
		'hide' :	'隐藏',
		'show' :	'显示'
	} );
	break;
case 'zh-hant':
case 'zh-hk':
case 'zh-mo':
case 'zh-tw':
	mw.messages.set( {
		'title' :	'條目預覽',
		'preview' :	'預覽',
		'noarticle' :	'您尚無選擇一個條目。',
		'readmore' :	'閱讀更多',
		'hide' :	'隱藏',
		'show' :	'顯示'
	} );
	break;

--Liuxinyu970226 (talk) 02:24, 10 February 2014 (UTC)[reply]

✓ Done (diff) --Fomafix (talk) 09:25, 10 February 2014 (UTC)[reply]

Proposed fix for broken gadget[edit]

{{Editrequest}}

The gadget is broken due to upgrade of jquery to 1.9.

I have come up with a fix for it:

https://www.wikidata.org/w/index.php?title=User:Aude/preview.js&oldid=132885378

Aude (talk) 19:57, 23 May 2014 (UTC)[reply]

✓ Done John F. Lewis (talk) 20:18, 23 May 2014 (UTC)[reply]

Default display[edit]

Would folks like if this gadget display a preview from the 'default' (guessed) wikipedia (based on user lang + 'wiki', e.g. en + wiki = English Wikipedia)? This way, one doesn't need to click on preview, though if they want to see preview from another wiki then one can still do that.

I have patched my script User:Aude/preview.js to do this. I have personally been using this for a while, and it's invaluable to me.

There is some flaw in this, as some cases, user lang and wikipedia subdomain don't correspond. (e.g. there is no 'simple' user lang) In that case, then no default preview is shown and the gadget would behave like it does now. In most cases, the guess should be ok. Aude (talk) 19:57, 23 May 2014 (UTC)[reply]

I would not prefer this. Often I view a Q on my mobile in response to an email notification, in order to see what was changed (because the emails dont provide a label), and I wouldnt like additional load and traffic. If there is a way to only automatically load it on desktop, I would be in favour. If others really want auto preview even on mobile, I'll live ;-) John Vandenberg (talk) 23:34, 23 May 2014 (UTC)[reply]
Agree about mobile. Probably there is a way to have auto preview on desktop only. (can try to look at that the next days) Aude (talk) 02:23, 24 May 2014 (UTC)[reply]
@Aude: On desktop, for me at least, the preview appears at the top in a column to the right of the claims, and is in the viewport. On mobile, the preview area is underneath everything else, way way way out of the viewport. In which case, if you can detect whether the preview div is in the viewport, it can autopreview. John Vandenberg (talk) 02:52, 24 May 2014 (UTC)[reply]

New version of this gadget[edit]

Hi guys, I created a new version of this gadget which includes a complete redesign and also fixes the autoload issue above. The basic change is that now there is an arrow on the right site of the page which moves down when you scroll down and which you can expand to view the preview of a Wikipedia article. If the screen is wide enough, the box is even expanded by default and the article in your language is visible. Before replacing the gadget by this new version I first ask you to test it by adding importScript( 'User:Bene*/preview.js' ); to your common.js. Also do not forget to disable the gadget in preferences to avoid conflicts between the two versions. Feedback is very appreciated. -- Bene* talk 21:03, 25 May 2014 (UTC)[reply]

Wow, looks nice! Only issue is the preview overlaps and interferes with the central notice banner. I suggest to prepend to #bodyContent and tweak the css:
$( '#bodyContent' ).prepend( $( html ) );
instead of
$( 'body' ).prepend( $( html ) );
and top': '20px' css for articlepreview instead of 100px.
I've not tried on mobile yet. Aude (talk) 13:59, 28 May 2014 (UTC)[reply]
also, we probably don't want autopreview when viewing diffs. Aude (talk) 22:49, 28 May 2014 (UTC)[reply]
There is problem that preview is on the top layer and when I want to merge or delete item, preview is over that. There is also space conflict with Wikidata useful, but this is not gadget but userscript.
Bug
I fixed the conflict with the action menu by changing the JavaScript and the CSS. --Fomafix (talk) 08:39, 10 June 2014 (UTC)[reply]

With gerrit:150855 the function getLanguage() get replaced by getLanguageDirection(). When gerrit:150855 is active this implementation must be updated. --Fomafix (talk) 13:38, 10 August 2014 (UTC)[reply]

gerrit:150855 is included in MediaWiki 1.24wmf17 and gets deployed here on Tuesday, 19 August 2014. I implemented a fallback to support both functions. getLanguage().dir can removed then getLanguageDirection() is live. --Fomafix (talk) 14:03, 17 August 2014 (UTC)[reply]

✓ Done --Fomafix (talk) 22:42, 19 August 2014 (UTC)[reply]

Bug[edit]

If I move the cursor to an article and I move it somewhere else, the title and badge of the article disappears. I saw this first today (is it in connection with the software update or directly with the badges?). Screenshots: step 1, step 2, step 3 (there are on a free picture upload site, say if there are deleted). --Tacsipacsi (talk) 06:24, 20 August 2014 (UTC)[reply]

Same problem, first noticed yesterday evening - while all changes were going live. JAn Dudík (talk) 06:35, 20 August 2014 (UTC)[reply]
Fixed (diff) --Fomafix (talk) 06:59, 20 August 2014 (UTC)[reply]
Thanks, it was fast! --Tacsipacsi (talk) 11:22, 20 August 2014 (UTC)[reply]

Fix gadget for new sitelink selectors[edit]

{{Editrequest}} Class names in the site links part of the UI have changed. The gadget needs to be updated accordingly:

https://www.wikidata.org/w/index.php?title=User%3AAude%2Fpreview.js&diff=155565615&oldid=155557869

PS. the preview displays at the bottom of the page. I'm not sure if that's how it's supposed to work(?) or it's just me? Aude (talk) 08:06, 3 September 2014 (UTC)[reply]

MediaWiki:Gadget-Preview.css also needs updating from:
table.wb-sitelinks .wb-editsection > .wikibase-toolbar {
to
table. wikibase-sitelinklistview .wb-editsection > .wikibase-toolbar {
Aude (talk) 10:39, 3 September 2014 (UTC)[reply]
✓ Done by Bene* it seems. John F. Lewis (talk) 19:37, 10 September 2014 (UTC)[reply]

Other projects[edit]

Would it be possible to change gadget to show preview of another family (wikiquote, wikisource, wikinews) article in my language, when wikipedia article does not exists? JAn Dudík (talk) 20:50, 10 September 2014 (UTC)[reply]

Edit links removed[edit]

Today was a software update and [edit] links were removed from sitelinks (there is only a blank <td></td> without class, it's used when editing, it says), so the preview buttons doesn't appear. Can you do something with it? --Tacsipacsi (talk) 20:58, 30 September 2014 (UTC)[reply]

I changed the JavaScript and the CSS. --Fomafix (talk) 08:49, 3 October 2014 (UTC)[reply]
Thanks! (For right-to-left languages, the icon appears at the left side. It's not a bug, I just noticed it.) --Tacsipacsi (talk) 14:02, 3 October 2014 (UTC)[reply]

Italian update[edit]

{{Editrequest}}

	case 'it':
		mw.messages.set( {
			'title' :	'Anteprima della voce',
			'preview' :	'anteprima',
			'noarticle' :	'Non hai ancora selezionato una voce.',
			'missing' :	'Questa voce non esiste.',
			'readmore' :	'Leggi tutto',
			'hide' :	'nascondi',
			'show' :	'mostra'
		} );
		break;

Please update. Thanks in advance. --FRacco (talk) 01:02, 4 October 2014 (UTC)[reply]

✓ Done (diff) --Fomafix (talk) 13:31, 4 October 2014 (UTC)[reply]

suggestion....[edit]

I'd like to make a suggestion, to ease the use of this gadget : when there is only 1 language link on an item, display it in Preview by default, instead of "no article". :)

Also, this gadget does not display correctly wikisource pages like Q17352415, because they are transcluded texts (which is the case of most wikisource pages) - do you think it could be fixed ?

Thanks for this tool --Hsarrazin (talk) 20:25, 5 October 2014 (UTC)[reply]

The tool has currently a strange logic on startup based on the size of the window. In a big window the preview is automatically opened and the content gets loaded. In a small window the preview is kept closed and not loaded and shows "no article" when opened. I think it would be wise to change the behaviour on small windows and also load the article.
The problem on Wikisource or on other pages has to solved in the extension TextExtracts.
Also the selection of the default wiki can improved. --Fomafix (talk) 21:43, 5 October 2014 (UTC)[reply]

Long sitelink[edit]

With long sitelink like in Category:Athletics at the 2008 Summer Olympics (Q8274293) in italian, don't work. --ValterVB (talk) 18:41, 17 January 2015 (UTC)[reply]

@ValterVB: It doesn't seem to be a general error; works for me. Can you add more details (browser, OS, error log etc.)? --Tacsipacsi (talk) 19:24, 17 January 2015 (UTC)[reply]
@Tacsipacsi: OS: Win 8.1, Browser IE11 and Chrome 32 and 64 bit. If I select preview for Italian Q8274293 the message is "'This article does not exist." --ValterVB (talk) 19:30, 17 January 2015 (UTC)[reply]
@ValterVB: Thanks for reporting. I'll fix it. --Fomafix (talk) 19:39, 17 January 2015 (UTC)[reply]
✓ Done (diff). Please test if the error is fixed and if there are new errors. --Fomafix (talk) 20:03, 17 January 2015 (UTC)[reply]

Don’t auto-show on diff pages[edit]

This gadget is really useful in general, but when patrolling recent changes it drives me mad because on every page I have to hide the preview before I can see the right-hand side of the diff, including (most importantly) the “Mark as patrolled” link. Can the gadget please not auto-expand when showing a diff? —DSGalaktos (talk) 14:15, 29 January 2015 (UTC)[reply]

This is annoying. I see. You can reduce the width of your window. Then the preview window is closed on start. This is a strange behavior. --Fomafix (talk) 18:26, 29 January 2015 (UTC)[reply]
Workaround: Import User:DSGalaktos/hidePreviewOnDiff.js in your common.js. —DSGalaktos (talk) 14:30, 30 April 2015 (UTC)[reply]
The workaround doesn’t always work (particularly when loading many diffs at once, i. e., when it’s most annoying that it doesn’t work :D), so instead I forked this gadget and fixed it properly. @Fomafix: can you please apply this change to this version too? —Galaktos (talk) 18:01, 30 August 2015 (UTC)[reply]
Applied. --Fomafix (talk) 18:25, 30 August 2015 (UTC)[reply]
Great, thanks! —Galaktos (talk) 18:28, 30 August 2015 (UTC)[reply]

Ukrainian translation[edit]

{{Edit request}}

	case 'uk':
		mw.messages.set( {
			'title' :	'Попередній перегляд статті',
			'preview' :	'попередній перегляд',
			'noarticle' :	'Ви ще не вибрали статтю.',
			'missing' :	'Цієї статті не існує.',
			'readmore' :	'Читати більше',
			'hide' :	'сховати',
			'show' :	'показати'
		} );
                break;

Please add this translation, thanks!--Piramidion (talk) 02:45, 6 March 2016 (UTC)[reply]

✓ Done (diff) --Fomafix (talk) 05:08, 7 March 2016 (UTC)[reply]

Russian translation[edit]

{{Edit request}}

	case 'ru':
		mw.messages.set( {
			'title' :	'Предварительный просмотр статей',
			'preview' :	'предпросмотр',
			'noarticle' :	'Вы ещё не выбрали статью.',
			'missing' :	'Такой статьи не существует.',
			'readmore' :	'Читать ещё',
			'hide' :	'скрыть',
			'show' :	'показать'
		} );
                break;

Please add this translation, thanks! --Kaganer (talk) 01:03, 24 June 2016 (UTC)[reply]

✓ Done Matěj Suchánek (talk) 06:05, 24 June 2016 (UTC)[reply]

Macedonian (mk) version[edit]

{{Editprotected}} Hello. Can someone please add this Macedonian version. Thanks a lot. --B. Jankuloski (talk) 20:42, 18 July 2016 (UTC)[reply]

	case 'mk':
		mw.messages.set( {
			'title' :	'Преглед на статијата',
			'preview' :	'прегледај',
			'noarticle' :	'Уште немате избрано статија.',
			'missing' :	'Таква статија не постои.',
			'readmore' :	'Прочитајте повеќе',
			'hide' :	'сокриј',
			'show' :	'прикажи'
		} );
		break;
✓ Done Matěj Suchánek (talk) 14:48, 7 August 2016 (UTC)[reply]

Polish (pl)[edit]

Please insert this code. Sp5uhe (talk) 06:45, 6 February 2017 (UTC)[reply]

	case 'pl':
		mw.messages.set( {
			'title' :	'Podgląd artykułu',
			'preview' :	'podgląd',
			'noarticle' :	'Jeszcze nie wybrałeś artykułu.',
			'missing' :	'Taki artykuł nie istnieje.',
			'readmore' :	'Więcej informacji',
			'hide' :	'ukryj',
			'show' :	'pokaż'
		} );
✓ Done --Jarekt (talk) 17:36, 18 January 2018 (UTC)[reply]

Remove zh-my[edit]

{{Edit request}} We recently got consensus to drop it: Wikidata:互助客栈#简繁问题 and phab:T156572. --Liuxinyu970226 (talk) 01:48, 6 January 2018 (UTC)[reply]

✓ Done --Jarekt (talk) 17:36, 18 January 2018 (UTC)[reply]

Use Page Previews instead of text extracts[edit]

Would it make sense to change this gadget to use the API behind Page Previews? Text extracts have various limitations which will likely not be fixed soon, since more work has been invested into making page previews suitable for general rollout (they were finally deployed to enwiki a few months ago – see this blog post by the Foundation).

Technically, this would mean using the REST API instead of the Action API, requesting e. g. https://en.wikipedia.org/api/rest_v1/page/summary/Dog instead of https://en.wikipedia.org/w/api.php?action=query&format=json&formatversion=2&prop=extracts%7Cinfo%7Cpageprops%7Cpageimages&exintro=true&exchars=1000&piprop=thumbnail&pithumbsize=180&titles=Dog. Documentation is available at mw:Page Content Service#Summary. --Galaktos (talk) 12:53, 24 August 2018 (UTC)[reply]

sv translation[edit]

{{Editrequest}}

	case 'sv':
		mw.messages.set( {
			'title' :	'Förhandsvisning av artikel',
			'preview' :	'förhandsvisning',
			'noarticle' :	'Du har inte valt någon artikel.',
			'missing' :	'Den här artikeln finns inte.',
			'readmore' :	'Läs mer',
			'hide' :	'göm',
			'show' :	'visa'
		} );

--Sabelöga (talk) 01:27, 24 July 2021 (UTC)[reply]

✓ DoneMisterSynergy (talk) 10:22, 26 October 2021 (UTC)[reply]