Обсуждение шаблона:Pgnviewer

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску

Starting position[править код]

Подскажите, пожалуйста, как через FirstMove или иным способом заставить Pgnviewer начинать вывод с начальной позиции, а не с конечной? См., например, Лазар, Фредерик. Или без тега FEN не обойтись? LGB (обс.) 12:52, 15 марта 2019 (UTC)[ответить]

  • LGB, для этого есть параметр FirstMove - посмотрите, как он использован в примерах. Раммон (обс.) 07:14, 19 марта 2019 (UTC)[ответить]
    • FirstMove может указать, ПОСЛЕ какого хода выводится начальная позиция. А если надо вывести позицию ПЕРЕД первым ходом? LGB (обс.) 09:58, 19 марта 2019 (UTC)[ответить]
      • Да, получается, что изначальную расстановку фигур перед началом шахматной партии этот шаблон в текущей реализации не обеспечивает. Но, с другой стороны, в Вашем примере с этюдом он почему-то отображает изначальную позицию этого этюда. А Вам нужно изобразить изначальную расстановку фигур перед началом шахматной партии с помощью этого шаблона, или Вы хотите его использовать для показа этюдов? Раммон (обс.) 09:00, 20 марта 2019 (UTC)[ответить]
        • Для этюда проблем нет, тег FEN обеспечивает начальную установку позиции. А вот если нет ни FEN, ни FirstMove, то для просмотра партии (а не только её финала) естественно ожидать установки на исходную позицию перед первым ходом, но этого почему-то нет, и непонятно, как это сделать. Приходится каждый раз нажимать на кнопку «К началу».
        • И ещё одна странная накладка. Судя по примерам, комментарии, скажем, к 6-му ходу чёрных, выводятся не до номера хода «7.», а после него, что также вызывает недоумение. С этим можно бороться? LGB (обс.) 10:12, 20 марта 2019 (UTC)[ответить]

pardon my language. the script behave in a bit of a perverse way: if you provide "firstmove", it shows position after the move specified. otherwise, it will begin with either the first or last position, depending on whether or not FEN was provided. so, in order to show standard game, from starting position, one has to supply fen of "virgin" board ([FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"]), and of course, do not specify "FirstMove". HTH. (rationale: when FEN is given, opening position is informative. otherwise, it carries no information, presuming the reader is familiar with chess, so i chose to display, by default, the board at the last position. ideally, i should have allowed "FirstMove=0", but nobody asked for it until now... if this makes a big diff for ruwiki, i can add this behavior). peace - קיפודנחש (обс.) 12:07, 20 марта 2019 (UTC)[ответить]

I suppose the option «FirstMove=0» would be very useful in some situations. Well, what do you thihk about the second my problem (see above): the template places comments to 6th move of black side after 7th move rather than before it? LGB (обс.) 15:03, 20 марта 2019 (UTC)[ответить]
handling of comments was always a weak point of this script. personally, i am not sure it's even a good idea to show them in the window at all, and i definitely do not like the actual way they are shown now - it's the best i could find, but it's really not that good. maybe there is also a bug, as you say, where comments are shown in the wrong place. it is possible i did it to avoid the need to break 23. b5 f6 to 23. b5 <something something something> 23... f6, or, more likely, it's a simple off-by-1 bug. i'll have to go back to the code, and this may take some time. peace - קיפודנחש (обс.) 21:17, 21 марта 2019 (UTC)[ответить]
on further inspection, the script indeed had an off-by-one bug with comments, where it displayed those one move after the correct location. thanks for the report - somehow this was not noticed until you pointed it out. this should be fixed now. again - i am not happy with the way "comments" are displayed in the gadget - maybe the right thing would be simply not to display them at all. also, notice the "CC" button, which hides all the comments (in TVs and DVRs, CC stands for "Closed Captions", in the viewer you can read it as "Conceal Comments"). also, per your report, i added support for [FirstMove "0"], to show opening position instead of last one. peace - קיפודנחש (обс.) 16:22, 22 марта 2019 (UTC)[ответить]
Fantastic! Not only you quickly corrected errors (I had checked — everything works) but also you answered a question which I was just going to ask — about purpose of the right button. The only remained trifle is centering buttons panel under the board, now it stick out to the right. Thanks you very much for this excellent template! LGB (обс.)
you are correct it "sticks to the side", but this is b/c you feed "size=30". if you ask for "size=20" it will stick even more. the script's default is 45, and using this value,the buttons are practically under the board. 45 may look a bit large, but since you only need one template to display multiple games, (unlike the "chess diagram" template, which shows a single position from a single game), i thought that 45 is a good default. UI is really not my thing, and getting to this form took endless tinkering...
BTW: notice that one of the tabs is "fen". we have a module/template that displays chess position based on the fen, so if you want to show 3 or 4 different positions from the same game, and you have the PGN (which you usually do - this is the standard format in all the databases), it may be the easiest thing to throw the template inside wiki editor, with the PGN, click "preview", click on the positions you want to show, collect the FENs of those games, and once you have them, remove the "viewer" template (presuming you don't want to show the viewer - just the specific positions). this is usually more convenient than the complex
{{Шахматная диаграмма
| tright
| Заголовок
|rd|nd|bd|qd|kd|bd|nd|rd
|pd|pd|pd|pd|pd|pd|pd|pd
|  |  |  |  |  |  |  |  
|  |  |  |  |  |  |  |  
|  |  |  |  |  |  |  |  
|  |  |  |  |  |  |  |  
|pl|pl|pl|pl|pl|pl|pl|pl
|rl|nl|bl|ql|kl|bl|nl|rl
|Подпись}}
and look more or less like so:
{{Шахматная диаграмма
| tright
| Заголовок
| fen = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
|Подпись}}
when you want to show more than 2 or 3 positions, the 2nd form is much more convenient.
tbh, not so long ago i wrote another scribunto module, that allows you to display multiple positions from the same game by feeding the PGN itself, and then specifying which positions you want, and what should be the description of each. it works roughly so:
{{template name
| pgn = <feed pgn here>
| 4l = <comment for position after 4th move of white>
| 7d = <comment for position after 7th move of black>
| 11l = <you get the idea>
| 33l = <etc.>
| 34d = <etc.?
}}
this shows 5 boards, with 5 different positions from same game. i thought this can be useful for articles about chess... peace - קיפודנחש (обс.) 21:13, 22 марта 2019 (UTC)[ответить]

Превращение пешки[править код]

И ещё одна проблема — мне не удаётся в Pgnviewer указать превращение пешки. Скажем, формат c8=R воспринимается как ошибка, см. мой черновик. Пробовал старые форматы: c8/R и c8(R), тоже не работают. LGB (обс.) 13:36, 15 марта 2019 (UTC)[ответить]

Проблема решена, см. Википедия:Форум/Технический#Новый шахматный шаблон. LGB (обс.) 11:47, 18 марта 2019 (UTC)[ответить]

New improvements[править код]

There were wishes from users Alexei Kopylov and LGB on forum ВП:Форум/Технический#Новый шахматный шаблон.

  1. Please increase the speed of piece movement animation.
  2. It would be great to have the adjusted Pieces tag with 10 codes of white/black pieces for their displaying on the Notation tab:
[Pieces "KQRBNKQRBN"] — English default code set
[Pieces "♔♕♖♗♘♚♛♜♝♞"] —International
[Pieces "KDTLSKDTLS"] — German
etc.
  1. The template Chess Diagram allows common text on right or on left, so it is convenient to place there solution or accompanying comments. The Pgnviewer template, apparently, does not allow this, though it would be useful (probably the style parameter somehow influences?).
  2. It will be quite good if Pgnviewer allowed the built-in output of user-defined reference information (as Chess Diagram had) — a lines over a board and lines under a board (above buttons).

LGB (обс.) 11:03, 1 апреля 2019 (UTC)[ответить]

Why German code set is needed in Russian Wikipedia? Раммон (обс.) 11:05, 1 апреля 2019 (UTC)[ответить]
It's for example only. Russian traditional coding for pieces contains two-symbolic code Кр for the King, so it required separate discussion. If it is difficult to realize universal option, International code set is quite sufficient for me and for the most of users. LGB (обс.) 11:44, 1 апреля 2019 (UTC)[ответить]
hmmmm.... just a thought: how about i teach the script to look for mw.messages.get() for values? let's say, the message name will be called "pgnViewer-pieces", and will contain the translation? something like
mw.messages.set('pgnViewer-pieces', );
// or, dewiki can use
mw.messages.set('pgnViewer-pieces', {
    all: { K: 'K', Q: 'D' R: 'T', B: 'L', N: 'S' }
});
we can do something similar for the file and row display, e.g., conceivably, persian wiki (one wiki that _must_ be serious about chess, i think) may want to use ١٢٣٤٥٦٧٨ for rows, instead of 12345678, and hewiki may want to use אבגדהוזח instead of abcdefgh for file.
so the idea is that the enveloping script, before invoking the viewer, will load all the values to mw.messages (which can host objects and arrays, as well as simple strings), and the script will revert to the default if it's not there.
let me think about it a bit more, and i'd love to hear your input too.
peace קיפודנחש (обс.) 19:21, 8 апреля 2019 (UTC)[ответить]
UPDATE, У:Alexei Kopylov and everyone else. i did implement some level of i18n, but not through mw.messages like i thought i would, but rather via the config. config now can have and object named "translate". it looks like so:
{
	"delay": "",
	"translate": {
		"piece": {
        	"white": { "K": "♔", "Q": "♕" "R": "♖", "B": "♗", "N": "♘" },
			"black": { "K": "♚", "Q": "♛", "R": "♜", "B": "♝", "N": "♞" }
		},
		"file": {"a":"A"},
		"row": {"1":"1"}
    }
}
this should be encoded in the data-config tag of the wrapper. makes for a longish line. maybe you guys have a template that returns its parameters concatenated - this can make it a bit prettier.
instead of defining "black" and "white", "piece" itself can be the mapping object (imagine the content of "piece" is only the content of "white", and nothing else). this is what we are doing in hewiki, or what dewiki may want to use.
any "piece" not appearing in the mapping, will remain unchanged. any of the notations (e.g., O-O-O, +, x, etc.) can be translated, not just pieces.
you probably do not want to use "row" and "file" - these are for systems where the files should not be a-h, or the rows something other than 1-8 (e.g., in arabic there's different digits, in hebrew different file legends). if you choose to translate file and/or row, this will translate both the chess-board legends, and the move notations. "piece" affects only notation.
please note that if you load the CSS from hewiki, you might want to change that: the hewiki CSS is not more "rtl friendly", and can distort the display for ltr wikis. let me know if this works for you. peace - קיפודנחש (обс.) 08:16, 13 апреля 2019 (UTC)[ответить]
У:Alexei Kopylov - you are correct - i did not test the black/white config variety (in hewiki (we don't use the black/white way). silly bug - fixed. please try again. also, you may want to play with the CSS and give a bit more font size to the notation display (pgndiv) - with this size fonts, and using unicode chess pieces, it's too small, at least for me, to read it comfortably. peace = קיפודנחש (обс.) 16:33, 13 апреля 2019 (UTC)[ответить]
קיפודנחש, pieces "♔♕♖♗♘♚♛♜♝♞" have rather little unchangeable size (for instance see here). Could you make ability to change font size of the pieces, please? Раммон (обс.) 06:44, 16 апреля 2019 (UTC)[ответить]

You own the css, no? You can change font size for the whole annotation and comment view (pgn-pgn-display) or specifically for the "movelink", "steplink", and comments. Peace - קיפודנחש (обс.) 12:34, 16 апреля 2019 (UTC)[ответить]

In Russian Wikipedia - no, because administrator Dima st bk banned editing css-files of templates to all editors except sysops and engineers and I could not agrue this his decision due to topic-ban. Beside that I gave example (n:Магнус Карлсен спасся в 6-й партии матча за первенство мира 2018) from Russian Wikinews, where the template used css file of hewiki. Раммон (обс.) 12:51, 16 апреля 2019 (UTC)[ответить]
У:Раммон: i changed the CSS on hewiki used by runews. let me know if this is good (i.e., are the fonts large enough, or maybe too large) but in order to change the display on ruwiki you'll need to discuss with the maintainer of the local template-style CSS. what needed is to add to the .pgn-pgndiv class, something like font-size:1.25em; (this is the change i did for runews), or, you can try different other sizes. you can test it first, by adding to your personal Special:MyPage/common.css page, something like
.pgn-pgndiv { font-size:1.25em; } /* play with different sizes */
this will change the size of _all_ text in the notation tab. alternatively, you can change the font size just for the pgn-movelink class. this will not affect the display of the move numbers and comments, only the actual move notations (e.g., ♜ed8). HTH.
also please note that we made an effort to make this mobile-compatible, so you can activate it now on the mobile site. the way ruwiki loads "conditional scripts" (like the pgnviewer), does not work on the mobile site, so the games are not visible on mobile. in order to allow that, you will need to "upgrade" Template:выполнить скрипт, or create a similar template to work on mobile, and, of course, add some code to Mediawiki:mobile.js to support it.
some unrelated heads-up: even though this script and template exist and are in use on hewiki for more than 6 years, recent activity (ruwiki, runews, maybe ukwiki, hebook, and maybe some other projects recently started using it, and i got some feedback) pushed me to fix some old criticism regarding the way display and animation are implemented.
as a result, i plan to make some substantial changes to the script (development of changes is almost finished), which will require some CSS changes, so soon-ish i'll inform you (i.e., will post in this talk page) some instructions of CSS update. note that once the script changes will be deployed, the CSS changes will become essential in order for the viewer to work. peace - קיפודנחש (обс.) 16:22, 16 апреля 2019 (UTC)[ответить]
I deleted connection between {{Pgnviewer}} and {{Pgn/styles.css}}, so your changes in hewiki were seen in ruwiki. As to {{выполнить скрипт}}, then at first I suggested including call of your script into commons.js, but finally the call was realized through {{выполнить скрипт}}. I think now it's time to refuse call your scripts through {{выполнить скрипт}} to replace it with call your scripts through commons.js. Раммон (обс.) 06:40, 17 апреля 2019 (UTC)[ответить]
У:Раммон: personally, i think it's better to use local css. this gives each project better control. of course, if tempaltestyles is managed with high-priest permission level, the proletariat are pushed to solutions that bypass it, such as loading the css externally (e.g., from hewiki)... as to switch from {{выполнить скрипт}} to common.js: in this context, it will be useless, since common.js is not executed for the mobile view (there's a small perversion, where the _personal_ common.js _is_ executed for both desktop and mobile, but the mediawiki:common.js only executes on desktop, and on mobile, it's mediawiki:mobile.js that executes), so loading the script for mobile view _must_ be managed one way or the other via Mediawiki:mobile.js. whethere or not this is done with an "on demand" loading, a la {{выполнить скрипт}} or "hard-coded", is secondary. in hewiki, we use similar mechanism of "on demand" for mobile. peace - קיפודנחש (обс.) 16:17, 17 апреля 2019 (UTC)[ответить]

Please note that the code was revised substantially, and part of the change is significant more stuff in the CSS. if you ever want to return to "templatestyles", you must update the CSS. start by copying from hewiki, and then apply any local change you desire. in hewiki, you can copy either from the gadget css used today in ruwiki (he:Mediawiki:Gadget-pgnviewer.css), or the templatestyle actually in use on hewiki: he:Template:Pgn/styles.css. peace - קיפודנחש (обс.) 05:13, 18 апреля 2019 (UTC)[ответить]

As to me, then I have not technical ability to change {{Pgn/styles.css}}. Раммон (обс.) 05:53, 18 апреля 2019 (UTC)[ответить]
understood. if ruwiki will choose to switch back to use templatestyle for this template, you probably want to copy the hewiki page he:Template:Pgn/styles.css, and look for stuff like direction: rtl which you want to remove, or change to ltr. the main point of my last post was that this was substantial code change, so new bugs are possible (maybe even likely). peace - קיפודנחש (обс.) 14:45, 18 апреля 2019 (UTC)[ответить]

changes and comment[править код]

hi.

again, pardon my language. so the script was changed somewhat:

  • in order to make it a bit more mobile-friendly, the "collapse" functionality is gone, and the "collapsible" and "collapsed" parameters have no effect. if collapse support is still desired, it should be handled by the template itself, e.g. by packaging everything inside an external collapsible element
  • again, in order to make it more mobile-friendly, the "slider" to set the "speed" (really, the delay between moves) was removed. instead, i added 2 new buttons, "parenthesizing" the "Play" button: to the left is a pedestrian, for "slower, please", and to the right a motorcyclist, for "faster". it is possible to eliminate the "speed control" (and the 2 buttons) entirely, by defining a "delay" parameter to the config. the delay is the number of milliseconds to delay between moves. providing "0" (without the quotes) will preserve the current behavior, while eliminating the "faster/slower" buttons (so user can't modify speed).
  • as mentioned, the script is now "mobile friendly". as far as i know, the "load script on demand" mechanism used in ruwiki (Template:выполнить скрипт) does not work for the mobile version. i'd suggest creating a similar mechanism for mobile view. you then can decide whether you want to activate this particular script for mobile viewers.

there were some CSS changes, which i could not do myself (Шаблон:Pgn/styles.css is protected), so i'll write them here: change

.pgn-tabber { display: inline-block; vertical-align: top; max-width: 20em; }

to

.pgn-tabber { display: inline-block; position: relative; vertical-align: top; max-width: 20em; }

i.e., add position:relative;

and the comment: to the right of the board, there are 3 "tabs": one with the game notation, one for the FEN which can be used by Template:Шахматная диаграмма 8x8 as "fen" parameter, and then the game metadata.

these tabs have names, and the script supports "i18n" using the "tab_names" config parameter. i think you should localize these values (translate the values [but NOT the keys!] in {"notation":"Notation","info":"Info","fen":"FEN"}

peace - קיפודנחש (обс.) 18:47, 8 апреля 2019 (UTC)[ответить]

Шаблон временно не отображается[править код]

На самом деле пока не КУ :) Механика, на которой основан шаблон, сейчас отключена в у нас, пока автор ее не починит. Поэтому я скрыл его, чтобы внутренний код не лез в статьи. Как починят вернем, если не починят, то надо будет что-то придумать или удалить. С уважением, Iniquity 04:47, 4 декабря 2021 (UTC)[ответить]

I am not aware of it. Ikhitron asked me to install some communication app, which i did, but we did not succeed to communicate, and i eventually removed it... if you can send me an email with the details, i will try to understand the issue, and if I succeed to do that, i will try to fix whatever needs fixing. Peace. קיפודנחש (обс.) 04:53, 5 января 2022 (UTC)[ответить]

User:Iniquity: i did something quick and dirty, let me know if it's good enough... (more important: let me know if it's not good enough).

peace - קיפודנחש (обс.) 06:01, 5 января 2022 (UTC)[ответить]

User:Iniquity: sorry for the noise. i made another change - i think this is more correct, hopefully safer, too. if you already tested, then i apologize. can you test again? (or for the first time if you haven't tested yet...). peace - קיפודנחש (обс.) 20:48, 5 января 2022 (UTC)[ответить]