Module:Sandbox/Mant08/IMDb name
| This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome. |
Usage
This module implements the legacy Template:IMDb name logic, using Lua.
It is supposed to be used through Template:X., by writing:
{{#invoke:Sandbox/Mant08/IMDb name|imdb_name}}
This module was created with the goal to improve the perfomance of the Template:IMDb name, by utilising the advantages of speed, Scrubinito Lua modules enable.
For an example on how can this module be used to power Template:IMDb name, see: Template: X.
Implementation details
This code has been already tested, in a slightly altered manner to confrom for language diffrencies, in the EL-GR Wikipedia, with stable results, with it being used to power the IMDb name Template, in the mainspace.
See: [[1]]
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.imdb_name(frame)
local args = getArgs(frame)
return p._imdb_name(args)
end
function p._imdb_name(args)
local config = args
local section = config["3"] or config[3] or config["section"] or nil
local name = config["2"] or config [2] or config["name"] or mw.title.getCurrentTitle().text or "John Doe"
local id = config["1"] or config[1] or config["id"] or nil
local current_page_id = mw.wikibase.getEntityIdForCurrentPage()
if (id == nil)
then
if (current_page_id ~= nil)
then
local p345_value_table = mw.wikibase.getBestStatements( current_page_id, 'P345' )
if (p345_value_table ~= nil)
then
if (p345_value_table[1] ~= nil)
then
id = p345_value_table[1].mainsnak.datavalue.value
end
end
end
else
if (tonumber(id) ~= nil)
then
id = "nm" .. id
else
id = id
end
end
local at_imdb_text = "at [[IMDb]]."
if (id == nil)
then
local encoded_name = mw.uri.encode(name)
return pronoun .. " " .. "[https://imdb.com/find/?q=" .. encoded_name .. "&s=nm" .. " " .. name .. "]" .. at_imdb_text
else
local base_link_object = "[https://imdb.com/name/" .. id .. "/"
if (section == nil)
then
return pronoun .. " " .. base_link_object .. " " .. name .. "]" .. at_imdb_text
elseif (section == "biography" or section == "bio")
then
return "The biography of " .. base_link_object .. "bio/ " .. name .. "]" .. at_imdb_text
elseif (section == "awards" or section == "award")
then
return "The awards of " .. base_link_object .. "awards/ " .. name .. "]" .. at_imdb_text
else
return '<span class="error">IMDb Name: Error: A non-valid "section" variable input was given.</span>'
end
end
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.