gnosygnu / xowa

xowa offline wiki application
Other
379 stars 40 forks source link

Wikibase: Implement formatValue and formatValues (Module:PropertyLink:167 attempt to call nil) #593

Open desb42 opened 5 years ago

desb42 commented 5 years ago

the page he.wikipedia.org/wiki/יובל_נאמן contains two instances of the above error (This is one of many hewiki pages exhibiting this problem)

On investigation, it seems that Module:PropertyLink is calling mw.wikibase.formatValues (potentially in many places)

Reviewing the xowa sources I can only find a definition for formatValue (singular) [although there is some commented out code with some php referring to formatValues]

I pluralised all formatValue to formatValues and am now getting Err: method not implemented which is kind of what is expected

Next is to understand what 'rich-wikitext' is all about

gnosygnu commented 5 years ago

Will be working on this next. It looks like formatValues is like formatValue but for lists. Relevant links below


gnosygnu commented 5 years ago

So, this looks pretty complicated as Wikibase has multiple formatters for each of the property types.

For now, I added a naive implementation which redirects formatValue and formatValues to renderSnak and renderSnaks. This removed the errors above, but will likely have other effects

I'm also going to move this back to to-do and tackle other issues next. Unfortunately, I have visitors from out of town this entire week, so probably won't be posting until November.

desb42 commented 4 years ago

Another example, this time using formatValue page he.wikipedia.org/wiki/The_Division_Bell in the 'external links' (I am using Google translate - my Hebrew is non existant)

This calls he.wikipedia.org/wiki/תבנית:קישורי_אלבומים (Template: Album links) which calls he.wikipedia.org/wiki/יחידה:מזהים_חיצוניים (Module: External identifiers)

most of the 'album links' are of the form Property - Name = LinkTemplate The exception is P1729-AllMusic= - no LinkTemplate

However, 'Module: External identifiers' can handle that, it uses formatValue in the line:

link = string.match(mw.wikibase.formatValue(properyVal[1].mainsnak), '%[([^ ]+)')

This does some magic that I cannot determine - but the result for this page is link = https://www.allmusic.com/album/mw0000113053

Another way to 'temporarily' fix this is to change 'Template: Album links' change the line

|P1729-AllMusic=

to

|P1729-AllMusic=https://www.allmusic.com/album/$1