gnosygnu / xowa

xowa offline wiki application
Other
375 stars 41 forks source link

lua :extensiontag maplink not working #421

Open desb42 opened 5 years ago

desb42 commented 5 years ago

There seems to be an issue with the #tag mechanism when used by lua through the :extensionTag function I have come across this in frwiki

If within the frwiki sandbox (Aide:Bac_à_sable) I write the following

{{#invoke:Coordinates|coord
|{{Coord/dms2dec|N|37|27}}
|{{Coord/dms2dec|E|25|20}}
|display=title
|formatitle=dms
|type:landmark
}}

The result should be something like

<div id="mw-indicator-coordinates" class="mw-indicator">
  <span id="coordinates">
    <a class="mw-kartographer-maplink"
       mw-data="interface" 
       data-style="osm-intl" 
       href="/wiki/Sp%C3%A9cial:Map/13/37.45/25.33/fr" 
       data-zoom="13" 
       data-lat="37.45" 
       data-lon="25.33" 
       data-overlays="[&quot;_87e883e34028fd03b874a7f8f7298636bfb0fbd7&quot;]">37°&#160;27'&#160;N, 25°&#160;20'&#160;E</a>
  </span>
</div>

in xowa \ is vistigal; however there is enough code to place a breakpoint to see that it is processed (and ignored) In running the above code through xowa the \ tag is not hit

Reviewing the module fr.wikipedia.org/wiki/Module:Coordinates the lines at issue for me are lines 384-393

local maplink = mw.getCurrentFrame():extensionTag{
  name = 'maplink',
  content = mw.text.jsonEncode( jsonParams ),
  args = {
    text = displaycoords[1] .. ", " .. displaycoords[2],
    zoom = zoom( extraparams ) or default_zoom,
    latitude = decLat,
    longitude = decLong,
  }
}

When I put a dbg(maplink) following this code I get '"UNIQ--maplink-0-QINU"'

Which took me some time to pin down. I found something in Xop_uniq_mgr.java - Parse_recurse When it came to replacing the above UNIQ I found that this substitution had zero bytes(?)

Further work on looking at the Add function in this module showed that it added a UNIQ with zero bytes

My current suspicion is that it has something to do with the json construct (line 386)

I hope this make sense

gnosygnu commented 5 years ago

Great write-up. Just trying to fill in some gaps

<maplink> is a no-op extension. The extension links to online OpenStreetMap , which is sort of uesless in an offline environment. So in XOWA, I registered the maplink extension but just had it generate no HTML

With regards to UNIQ. I changed XOWA to follow MediaWiki's behavior. It uses UNIQ to armor pieces of text so that subsequent regexes don't change it.

The problem above is that UNIQ is armoring the contents of the maplink which, in turn, is empty. That's why it has zero bytes.

The correct resolution would be to implement maplink. But I don' t see much value to this (since OpenStreetMaps requires online access). Do the French Wikipedia pages look weird with the missing maplink?

desb42 commented 5 years ago

I am still slightly confused as to why the breakpoint I set did not hit

As it happens (and I don't expect anyone else to) I have my own tile server.

The differences showing the maplink stuff mykonos1 and mykonos2

so relatively minor - its just I like to see as little difference between xowa and mediawiki (it could just be text and no link)