Module:Wikibase
Jump to navigation
Jump to search
This module is copied from the example from the module documentation at mw:Extension:Wikibase Client/Lua. It should be kept consistent with that documentation, rather than being adapted further for use on PBC.
Usage
- id
{{#invoke: Wikibase | id }}
- wdurl
{{#invoke: Wikibase | wdurl }}
{{#invoke: Wikibase | wdurl | entity id (Q# or P#) }}
- label
{{#invoke: Wikibase | label }}
{{#invoke: Wikibase | label | entity id (Q# or P#) }}
- description
{{#invoke: Wikibase | description }}
{{#invoke: Wikibase | description | entity id (Q# or P#) }}
- page
{{#invoke: Wikibase | page }}
{{#invoke: Wikibase | page | item id (Q#) }}
- datatype
{{#invoke: Wikibase | datatype | property id (P#) }}
Examples
id
{{#invoke:Wikibase | id }}
→ Q230
wdurl
{{#invoke:Wikibase | wdurl }}
→ https://pornbasedata.com/wiki/Special:EntityPage/Q230{{#invoke:Wikibase | wdurl | Q8 }}
→ https://pornbasedata.com/wiki/Special:EntityPage/Q8{{#invoke:Wikibase | wdurl | P1 }}
→ https://pornbasedata.com/wiki/Special:EntityPage/P1
label
{{#invoke:Wikibase | label }}
→ Module:Wikibase{{#invoke:Wikibase | label | Q8 }}
→ Andrey Vic{{#invoke:Wikibase | label | P1 }}
→ instance of
description
{{#invoke:Wikibase | description }}
→ PBC module{{#invoke:Wikibase | description | Q8 }}
→ Ukrainian pornographic actor and adult model{{#invoke:Wikibase | description | P1 }}
→ that class of which this subject is a particular example and member (subject typically an individual member with a proper name label);
page
{{#invoke:Wikibase | page }}
→ Module:Wikibase{{#invoke:Wikibase | page | Q8 }}
→ Andrey Vic
datatype
Commons media file: see also (P18)
{{#invoke:Wikibase | datatype | P18 }}
→ wikibase-property{{#invoke:Wikibase | datatype | Property:P18 }}
→ wikibase-property
Geographic coordinates: coordinate location (P48)
{{#invoke:Wikibase | datatype | P48 }}
→ globe-coordinate{{#invoke:Wikibase | datatype | Property:P48 }}
→ globe-coordinate
Item: (P6)
{{#invoke:Wikibase | datatype | P6 }}
→{{#invoke:Wikibase | datatype | Property:P6 }}
→
Property: subproperty of (P8)
{{#invoke:Wikibase | datatype | P8 }}
→ wikibase-property{{#invoke:Wikibase | datatype | Property:P8 }}
→ wikibase-property
String: title (P225)
{{#invoke:Wikibase | datatype | P225 }}
→ monolingualtext{{#invoke:Wikibase | datatype | Property:P225 }}
→ monolingualtext
Monolingual text: official name (P77)
{{#invoke:Wikibase | datatype | P77 }}
→ monolingualtext{{#invoke:Wikibase | datatype | Property:P77 }}
→ monolingualtext
Quantity: population (P59)
{{#invoke:Wikibase | datatype | P59 }}
→ quantity{{#invoke:Wikibase | datatype | Property:P59 }}
→ quantity
Point in time: date of birth (P9)
{{#invoke:Wikibase | datatype | P9 }}
→ time{{#invoke:Wikibase | datatype | Property:P9 }}
→ time
{{#invoke:Wikibase | datatype | P52 }}
→ url{{#invoke:Wikibase | datatype | Property:P52 }}
→ url
Mathematical expression: defining formula (P232)
{{#invoke:Wikibase | datatype | P232 }}
→ math{{#invoke:Wikibase | datatype | Property:P232 }}
→ math
---------- Module:Wikibase ----------------
local p = {}
-- Return the item ID of the item linked to the current page.
function p.id(frame)
if not mw.wikibase then
return "no mw.wikibase"
end
entity = mw.wikibase.getEntityObject()
if entity == nil then
return "no entity"
end
return entity.id
end
-- Return the WD entity URL of a given data item, or of connected page
-- if no argument is provided to this method.
function p.wdurl(frame)
if frame.args[1] == nil then
entity = mw.wikibase.getEntityObject()
if not entity then return nil end
id = entity.id
else
id = mw.text.trim(frame.args[1])
end
return mw.wikibase.getEntityUrl( id )
end
-- Return the label of a given data item, or of connected page
-- if no argument is provided to this method.
function p.label(frame)
if frame.args[1] == nil then
entity = mw.wikibase.getEntityObject()
if not entity then return nil end
id = entity.id
else
id = mw.text.trim(frame.args[1])
end
return mw.wikibase.label( id )
end
-- Return the description of a given data item, or of connected page
-- if no argument is provided to this method.
function p.description(frame)
if frame.args[1] == nil then
entity = mw.wikibase.getEntityObject()
if not entity then return nil end
id = entity.id
else
id = mw.text.trim(frame.args[1])
end
return mw.wikibase.description( id )
end
-- Return the local page about a given data item, or of connected page
-- if id is not specified.
function p.page(frame)
if frame.args[1] == nil then
entity = mw.wikibase.getEntityObject()
if not entity then return nil end
id = entity.id
else
id = mw.text.trim(frame.args[1])
end
return mw.wikibase.sitelink( id )
end
-- Return the data type of a property
function p.datatype(frame)
if frame.args[1] and string.find(frame.args[1], "Property:P") then
if mw.wikibase.getEntityObject(string.gsub(frame.args[1], "Property:P", "P")) then
return mw.wikibase.getEntityObject(string.gsub(frame.args[1], "Property:P", "P") ).datatype
end
elseif frame.args[1] and string.find(frame.args[1], "P") then
if mw.wikibase.getEntityObject(frame.args[1]) then
return mw.wikibase.getEntityObject(frame.args[1]).datatype
end
end
end
return p