Page MenuHomePhabricator

Proofreadpage Pages should have the associated pagelist's page number embedded in them
Closed, ResolvedPublic

Description

Sometimes, it's useful to know what the "pagelist" number of the current page is. The header and footer Index page fields have {{{PAGENUM}}} that's interpolated server-side, but sometimes it's useful to know what it is without that. For example, scripts that want to replace or format the header/footer can use the number rather than trying to parse it out of the wikitext on a page-by-page basis (or loading the Index page and parsing it out of that HTML).

Is it possible for the extension to set a variable or something so this can be retrieved in JS with something like mw.config.get("prpPageNum"), since the server clearly know what it is, as it's interpolating the {{{PAGENUM}}} text for the page?

prpPageQuality is already in the mw.config object.

Event Timeline

Everything Proofread Page knows would be useful to be able to access from JS: the associated Index: page, the page number, the previous and next pages, the values of the header and footer templates from the Index:, the CSS field from the Index: (quite possibly the other fields too, but I can't think of a use for them ottomh). Page name for Index and next/prev Page:, plus the {{{pagenum}}} are the obvious top priorities I'd say.

Oh, the DPI setting might be useful too, if you want to manipulate the scan image. And the associated File: plus physical page number in the file. And possibly the requested image size too.

Indeed, currently I get next/prev/index and current page offset in the file by scraping the links and wgTitle, which is not ideal.

Soda subscribed.

Will take a look at this :)

Change 611962 had a related patch set uploaded (by Sohom Datta; owner: Sohom Datta):
[mediawiki/extensions/ProofreadPage@master] Added formatted page number of Page: page to mw.config

https://gerrit.wikimedia.org/r/611962

@Soda thank you! Should I open a further issue for the other fields mentioned by @Xover? Several of those fields could be actively useful in gadgets at Wikisource and obviate the need for some fairly dodgy, if time-honoured, workarounds.

Change 611962 merged by jenkins-bot:
[mediawiki/extensions/ProofreadPage@master] Added formatted page number of Page: page to mw.config

https://gerrit.wikimedia.org/r/611962

Change 631938 had a related patch set uploaded (by Sohom Datta; owner: Sohom Datta):
[mediawiki/extensions/ProofreadPage@master] Moved mw.config vars from PageViewAction::show to getParserOutput

https://gerrit.wikimedia.org/r/631938

@Inductiveload I'll make a few more patches on this task to add some of the other requested variables.

I'm not really sure if having the header and footer will help given that they will probably be in wikitext format and extracting it from the html would be easier than attempting to parse the wikitext.

I'm not really sure if having the header and footer will help given that they will probably be in wikitext format and extracting it from the html would be easier than attempting to parse the wikitext.

I have a user script that tries to semi-automate updating headers containing the chapter name in the Page: namespace. It lets the user enter the "current chapter" and stores it using WebStorage keyed for the current work. Every time a page in the Page: namespace is loaded in edit mode the script infers the link to the Index: page, fetches both the wikitext and rendered HTML version of it, extracts the logical page number from the HTML version and the header formatting template from the wikitext version, and then updates the header text field on the current page using that formatting template, replacing instances of {{{pagenum}}} and {{{chapter}}} with the relevant string.

My code would be a lot cleaner (and shorter) if, on a Page:-namespace page, I could mw.config.get() the associated Index: page, the current rendered page number (and the next and previous page, for other scripts), and every structured field on the Index page as it looks when editing the Index: page (in this script, the header and footer; in other scripts I might want any and all Index: page fields).

Ideally I would also want to be able to write to the structured fields (e.g. to offer the user an option to change the formatting template without visiting the Index: page), but just being able to read stuff easily will go a long way.

Incidentally, it is likely that some or all of such functionality would be useful for different purposes in all of PRP's namespaces: Page: as described above; on Index: pages you might want to manipulate the associated pages in various ways (mass move or rename, say); and even in mainspace where such pages are transcluded (checking included pages, cleaning up after page moves, etc.). I think there probably are use cases for most of it.

Change 631938 merged by jenkins-bot:
[mediawiki/extensions/ProofreadPage@master] Moved mw.config vars from PageViewAction::show to getParserOutput

https://gerrit.wikimedia.org/r/631938

@Soda did this get deployed? The only PRP JS config I can see at enWS is prpPageQualityUser?

My mistake, it works, but not in edit mode until the page is previewed.

Change 739852 had a related patch set uploaded (by Inductiveload; author: Inductiveload):

[mediawiki/extensions/ProofreadPage@master] Set all JS vars in view, edit and submit modes

https://gerrit.wikimedia.org/r/739852

Change 739852 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] Set all JS vars in view, edit and submit modes

https://gerrit.wikimedia.org/r/739852