Khác biệt giữa bản sửa đổi của “Mô đun:Wikibase”
Một thế giới nơi chỉ có đam mê, niềm vui và sắc màu...
Nội dung được thêm vào Nội dung được xóa
(Tạo trang mới với nội dung “---------- Module:Wikibase ---------------- require('strict') local p = {} -- Return the entity ID of the item linked to the current page. function p.id(frame) if not mw.wikibase then return "no mw.wikibase" end return mw.wikibase.getEntityIdForCurrentPage() or "no entity" end -- Return the URL of an entity given its entity ID -- or the item linked to the current page if no argument is provided. function p.wdurl(frame) return mw.wikibase.getE…”) |
Không có tóm lược sửa đổi |
||
Dòng 5: | Dòng 5: | ||
-- Return the entity ID of the item linked to the current page. |
-- Return the entity ID of the item linked to the current page. |
||
function p.id(frame) |
function p.id(frame) |
||
if not mw. |
if not mw.ext.UnlinkedWikibase then |
||
return "no mw. |
return "no mw.ext.UnlinkedWikibase" |
||
end |
end |
||
return mw. |
return mw.ext.UnlinkedWikibase.getEntityIdForCurrentPage() or "no entity" |
||
end |
end |
||
Dòng 14: | Dòng 14: | ||
-- or the item linked to the current page if no argument is provided. |
-- or the item linked to the current page if no argument is provided. |
||
function p.wdurl(frame) |
function p.wdurl(frame) |
||
return mw. |
return mw.ext.UnlinkedWikibase.getEntityUrl(frame.args[1] and mw.text.trim(frame.args[1])) -- defaults to entity URL of the item linked to the current page |
||
end |
end |
||
Dòng 20: | Dòng 20: | ||
-- or the item linked to the current page if no argument is provided. |
-- or the item linked to the current page if no argument is provided. |
||
function p.label(frame) |
function p.label(frame) |
||
return mw. |
return mw.ext.UnlinkedWikibase.getLabel(frame.args[1] and mw.text.trim(frame.args[1])) -- defaults to label of the item linked to the current page |
||
end |
end |
||
Dòng 26: | Dòng 26: | ||
-- or the item linked to the current page if no argument is provided. |
-- or the item linked to the current page if no argument is provided. |
||
function p.description(frame) |
function p.description(frame) |
||
return mw. |
return mw.ext.UnlinkedWikibase.getDescription(frame.args[1] and mw.text.trim(frame.args[1])) -- defaults to description of the item linked to the current page |
||
end |
end |
||
Dòng 34: | Dòng 34: | ||
local qid = frame.args[1] and mw.text.trim(frame.args[1]) |
local qid = frame.args[1] and mw.text.trim(frame.args[1]) |
||
if not qid or qid == '' then |
if not qid or qid == '' then |
||
qid = mw. |
qid = mw.ext.UnlinkedWikibase.getEntityIdForCurrentPage() -- default the item connected to the current page |
||
end |
end |
||
return mw. |
return mw.ext.UnlinkedWikibase.getSitelink(qid or '') -- requires one string arg |
||
end |
end |
||
-- Return the data type of a property given its entity ID. |
-- Return the data type of a property given its entity ID. |
||
function p.datatype(frame) |
function p.datatype(frame) |
||
local prop = mw. |
local prop = mw.ext.UnlinkedWikibase.getEntity(frame.args[1] and mw.text.trim(frame.args[1]):upper():gsub('PROPERTY:P', 'P')) -- trim and remove any "Property:" prefix |
||
return prop and prop.datatype |
return prop and prop.datatype |
||
end |
end |
Bản mới nhất lúc 12:50, ngày 3 tháng 6 năm 2024
Có thể viết tài liệu về mô đun này tại Mô đun:Wikibase/tài liệu.
---------- Module:Wikibase ----------------
require('strict')
local p = {}
-- Return the entity ID of the item linked to the current page.
function p.id(frame)
if not mw.ext.UnlinkedWikibase then
return "no mw.ext.UnlinkedWikibase"
end
return mw.ext.UnlinkedWikibase.getEntityIdForCurrentPage() or "no entity"
end
-- Return the URL of an entity given its entity ID
-- or the item linked to the current page if no argument is provided.
function p.wdurl(frame)
return mw.ext.UnlinkedWikibase.getEntityUrl(frame.args[1] and mw.text.trim(frame.args[1])) -- defaults to entity URL of the item linked to the current page
end
-- Return the label of an entity given its entity ID
-- or the item linked to the current page if no argument is provided.
function p.label(frame)
return mw.ext.UnlinkedWikibase.getLabel(frame.args[1] and mw.text.trim(frame.args[1])) -- defaults to label of the item linked to the current page
end
-- Return the description of an entity given its entity ID
-- or the item linked to the current page if no argument is provided.
function p.description(frame)
return mw.ext.UnlinkedWikibase.getDescription(frame.args[1] and mw.text.trim(frame.args[1])) -- defaults to description of the item linked to the current page
end
-- Return the local title of an item given its entity ID
-- or the item linked to the current page if no argument is provided.
function p.page(frame)
local qid = frame.args[1] and mw.text.trim(frame.args[1])
if not qid or qid == '' then
qid = mw.ext.UnlinkedWikibase.getEntityIdForCurrentPage() -- default the item connected to the current page
end
return mw.ext.UnlinkedWikibase.getSitelink(qid or '') -- requires one string arg
end
-- Return the data type of a property given its entity ID.
function p.datatype(frame)
local prop = mw.ext.UnlinkedWikibase.getEntity(frame.args[1] and mw.text.trim(frame.args[1]):upper():gsub('PROPERTY:P', 'P')) -- trim and remove any "Property:" prefix
return prop and prop.datatype
end
return p