Thank you Thomas. There are two reasons to load "structural metadata" into
a Lua data page, to be imported with mw.loadData():
1. 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(a)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(a)gmail.com
To: wikisource-l(a)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(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikisource-l
_______________________________________________
Wikisource-l mailing list
Wikisource-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikisource-l