I got it :-)
Take a look to this pagehttp://it.wikisource.org/wiki/Pagina:Manuale_di_economia_politica_con_una_introduzione_alla_scienza_sociale.djvu/583. As you see, page numbers are simply wrapped into a tl|Pg. No other parameters. Nevertheless, they are transformed into active links do right djvu pages.
Now, go herehttp://it.wikisource.org/wiki/Manuale_di_economia_politica_con_una_introduzione_alla_scienza_sociale/Indice_dei_nomi_di_autori#pagename583 where the same page is transcluded in ns0. Page numbers now are active links to the right subpage/chapter.
This trick uses: Template:Pg http://it.wikisource.org/wiki/Template:Pg, Modulo:Pg http://it.wikisource.org/wiki/Modulo:Pg, and this Modulo:Dati/Manuale....http://it.wikisource.org/wiki/Modulo:Dati/Manuale_di_economia_politica_con_una_introduzione_alla_scienza_sociale.djvu; nothing more than this, no javascript and no AJAX, so I presume (I didn't test by now) that links are running too into any html-based export of ns0 pages as server builds them.
Scripts are rough, they don't consider any exception, they are not documented, I tested them on a couple of works only.... but they show that it can be done.
Alex
2013/6/1 Alex Brollo alex.brollo@gmail.com
Thank you Thomas. There are two reasons to load "structural metadata" into a Lua data page, to be imported with mw.loadData():
- often the tl|Pg - which reads data page by mw.loadData() and converts a
book page number/mark into a running link to djvu page - is called dozens, sometime hundreds of times by a single Page: this happens, i.e., into glossaries, indexes of people, indexes of lemmas; so, it's important IMHO that it's not server expensive; 2. I'm an absolute Lua beginner, and I'm searching for opportunities to test most interesting Lua features. ;-)
I'm using javascript to build data Lua data page since I find it comfortable for tests (much more comfortable when coupled with Chrome Shortcut Manager); data pages can be built with a python bot too, but I think that a "manual opportunity" by javascript should be saved for updates/tests and so on. And.... it's so exciting to see how code appears into a eyeblink.... :-)
I'm going to expand the data page adding ns0 names of pages and subpages and ranges of pages which they transclude (all the needed data are wrapped into Index: wiki code in it.source); so I hope that tl|Pg link will point djvu page in nsIndex and nsPage, and will point to ns0 page/subpage when transcluded into ns0.
Alex
2013/6/1 Thomas PT thomaspt@hotmail.fr
Hi!
It looks very good! In my opinion the template will be more interesting (but also more heavy) if you work directly with the Index page by loading its content (local page = mw.title.new( 'Index:XXX.djvu' ); local text = page:getContent()) and parsing the <pagelist> tag that will give you the displayed number <-> number in the djvu conversion.
Thomas
Date: Fri, 31 May 2013 16:10:47 +0200 From: alex.brollo@gmail.com To: wikisource-l@lists.wikimedia.org Subject: [Wikisource-l] Playing with Lua, javascript and pagelist tag
I'm testing a template [:it:s:Template:Pg]] (calling a Lua module) that fastly converts book page numbers, passed as the unique parameter to the template, into links to right djvu pages, without any need to add delta parameters and linking any format for page number (arabic, roman, other...) since page numbers are seen as strings.
The Lua script reads a data page, containing tables for conversion book page->djvu page and reverse, using mw.loadData() function for max efficiency (often there are dozens, sometimes hundreds of links to pages into a single book page; ity happens into analytical indexes, glossaries and so on).
The Lua data page is written in a eyeblink by a js script, which reads and parses html of Index: page, produced by pagelist tag; so it's very comfortable to fill such data page and to update it, if pagelist parameters are updated.
Is this "beginner's Lua exercise" someway interesting/inspiring in your opinion?
Alex brollo
_______________________________________________ Wikisource-l mailing list Wikisource-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikisource-l
Wikisource-l mailing list Wikisource-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikisource-l