Edukira joan

Topic on Lankide eztabaida:Theklan

קיפודנחש (eztabaidaekarpenak)

hi. so, in order to help get this template live on this wiki, i'll need to understand what difficulties did you encounter. please mention me (like so: User:קיפודנחש when you answer, as i do not frequent this wikipedia...


so, for this to work, three things are required: template, css, and script.

for the templatee, you might want to try the "simpler" use case, as it is on enwiki en:Template:Pgnviewer (notice that this template uses one sub-page - you'll need this too).


the hewiki version of the template contains lots of stuff you probably do not want or need, some of it has to do with using different alphabet, written right-to-left.


for the script and css, you may want to copy something like the content of

en:User:קיפודנחש/pgnwrapper.js

notice that the wrapper checks to see if the page contains one or more "pgnviewer" templates, and only loads the code from hewiki if needed.


there are quite a few parameters that can be passed from the template to the script, controlling all sorts of stuff, including legends, and even the images used for the pieces and buttons. most is documented as a comment at the top of the source.


please let me know if i can be of more help.


peace.




Theklan (eztabaidaekarpenak)
Theklan (eztabaidaekarpenak)

Ok! I can see it live! So I would need to install that for everyone at common.js.

קיפודנחש (eztabaidaekarpenak)

i think i see the issue now. you copied the usage of Txantiloi:Scripta exekutatu, but for this template to work, you are missing some lines in MediaWiki:Common.js

these lines are (this is how they are on hewiki):

// On demand loading of scripts and gadgets, initial version from ruwiki.
// Detects uses of templace "טען סקריפט"
// and loads specifically-named scripts or gadgets.
// for a script to be loadable this way, its name must begin with "Mediawiki:Scripts/"
// for a gadget, its name as defined in gadgets-definition must begin with "ondemand-"
if ( mw.config.get('wgCanonicalNamespace') !== 'Special' ) 
mw.hook( 'wikipage.content' ).add( function( content ) {
		var beenthere = {};
		$( '.executeJS', content ).each( function () {
			var script = $( this ).data( 'scriptname' );
			if ( script && $.trim( script ) ) {
				script = $.trim( script );
				if ( ! beenthere[script] )
					mw.loader.load( "/w/index.php?title=Mediawiki:Scripts/" + script + ".js&action=raw&ctype=text/javascript", "text/javascript" );
				beenthere[script] = true;
			}
			var gadget = $( this ).data( 'gadgetname' );
			if ( gadget && $.trim( gadget ) ) mw.loader.load( 'ext.gadget.ondemand-' + $.trim( gadget ) ); // np repetitions - resourceloader takes care
		} );
} );

this will enable "on-demand" scripts and gadgets on your wiki. this way, you can support more "on demand" stuff (i think ruwiki has maybe 6 or 7 different "on-deman" script, hewiki maybe 5 or 6)

if you choose to do this, then the lines for the "pgn wrapper" should not be put directly in common.js, but rather, as a hidden gadget. i can talk you through this, but this may be an overkill in this case.


let me know if i can help more, or provide more details regarding either the pgn script, or "on-demand" loading.


peace.

Theklan (eztabaidaekarpenak)

No, it's solved directly! Now I need to translate some stuff but it can be seen live. Thanks!

קיפודנחש (eztabaidaekarpenak)

Note that this looks bad on mobile. In hewiki, we do activate the viewer on mobile too, via mediawiki:mobile.js (we made some provisions: on mobile, there are no "tabs", so fen and metadata are not avaiable). Alternatively, you can hide the wrapper div on mobile using, e.g., mediawiki:mobile.css. Please look at a page containing the template using mobile view, to see what im talking about.

Peace.

Theklan (eztabaidaekarpenak)

Thanks! I have copied them (except one part that I understand is not for this gadget to work). I don't understand why MediaWiki:Mobile.js the first line is commented. Should it be?

קיפודנחש (eztabaidaekarpenak)

the first line is a special provision in hewiki, to support user-personal script on the mobile site. it is not really needed. basically, by having it, registered users on hewiki can have personal "mobile.js" in addition to "common.js".

it's harmless, but if no user has personal mobile.js, it is also useless...


The lines you copied are meant to work with Txantiloi:Scripta exekutatu, but not in its current version (taken from ruwiki, i think), but the way it's done on hewiki, which makes separate provisions for "scripts", "gadgets", and "mobile".

since you do not wish to install "load script on demand" functionality at this point, you should probably skip this (and remove those lines from mobile.js), and instead copy the segment that deals with the viewer straight from your common.js

in hewiki, the "on-demand" feature works nicely, and supports several different scripts in several situations, but if the pgnviewer is the only such script on euwiki, i agree with you it's an overkill, and individual treatment of the pgnviewer is the right thing.

peace.

Theklan (eztabaidaekarpenak)

Mmmm... I'm lost? Could you help me further with this? Which code should I have in each one?

Thanks!

קיפודנחש (eztabaidaekarpenak)

so, presuming "on-demand" loading of scripts on mobile is out, at least for now, all you need in

MediaWiki:Mobile.js are those lines, same as in common.js:

/* Xake partidak ikusteko kodea */
$( function() {
	if ( $( '.pgn-sourcegame' ).length ) {
		mw.loader.load('//he.wikipedia.org/w/index.php?title=Mediawiki:Gadget-pgnviewer.js&action=raw&ctype=text/javascript');
		mw.loader.load('//he.wikipedia.org/w/index.php?title=Mediawiki:Gadget-pgnviewer.css&action=raw&ctype=text/css', 'text/css');
	}
} );

it _is_ possible to use the "on-demand" way, but for this, the "load-script" template, as well as the lines in common.js and mobile.js which handle it, should be like those on hewiki, not the current one, which resemble the ruwiki way (and do not support on-demand loading for mobile).

the relevant difference is the fact that the hewiki code/template supports on-demand loading for mobile too.

this is not done blind: a template has to ask explicitly for a script to be loaded on desktop, mobile, or both, so the pgnviewer template on hewiki contains this:

{{טען סקריפט| gadgetname = pgnViewer | mobilegadget = pgnViewer}}

so the template is the "load script" template, and it is told to load the script as a gadget, both on desktop and mobile. ("as a gadget" means that this script appears in "gadgets-definition", and it is loaded by mw.loader.load('ext.gadget.ondemand-pgnViewer');

again these details are only relevant if you want the hewiki mechanism of "on-demand loading". otherwise, the lines i posted above should be copied from common.js to mobile.js, the current content of mobile.js can be discarded, and you should be all set.

peace.

Theklan (eztabaidaekarpenak)

Ok... let's see if it is working!

קיפודנחש (eztabaidaekarpenak)

seems to be working, but on android on chrome, samsung gal. 6, it's a tad too big: the board fits nicely on the screen, but you can't see board, buttons, and annotations without scrolling.

i think we (hewiki) default squaresize to 26, you use 35. we decided that 26 is actually more sensible for the desktop too: the viewer should not dominate too much of the screen. Txantiloi:Xake diagrama uses square size of 26, and renders pretty well on desktop and mobile.

anywhoo, you may want to experiment with different square sizes, and check how it looks on mobile. if you use google chrome, using "dev tools" (f12) provides some emulation of different mobile devices, so you can check how it looks on many of the popular devices from the desktop.

peace.

Theklan (eztabaidaekarpenak)

Thanks a lot!

"pgn template" mezuari erantzun