Modul:FilmRef
Modul:FilmRef
| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | |||
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
--[=[ FilmRef 2022-11-10
reference for films by Wikidata
Autor: Vollbracht
]=]
local p = {}
local _, SDA = pcall(require, "Modul:SimpleDataAccess")
local _, t = pcall(require, "Modul:Title")
local Title = t.service
IDbase = {
P345 = '[[IMDb]]: [https://www.imdb.com/title/%s',
P2639 = '[[filmportal.de]]: [https://www.filmportal.de/%s',
P3107 = '[[Lexikon des internationalen Films|LdiF]]: [https://www.filmdiens'
.. 't.de/film/details/%s',
P3138 = '[[OFDb.de]]: [https://www.ofdb.de/film/%s,',
P3933 = '[[Cinema]]: [https://www.cinema.de/%s',
P4947 = '[[The Movie Database|TMDb]]: [https://www.themoviedb.org/movie/%s',
P5786 = '[[Moviepilot]]: [https://www.moviepilot.de/movies/%s',
P8531 = '[[Filmstarts]]: [https://www.filmstarts.de/kritiken/%s.html'
}
local function byWD(frame)
local wdo = frame.args.wdObject
if not wdo then wdo = frame.args[1] end
if wdo then wdo = wdo:match('Q%d*')
else wdo = mw.wikibase.getEntityIdForCurrentPage() end
if not wdo then return '' end
local IDs = {}
for k, v in pairs(IDbase) do
local ID = SDA.MainSnackValue(wdo, k)
if ID and ID ~= '' then
table.insert(IDs, string.format(v, ID) .. ' ' .. ID .. ']')
end
end
if #IDs == 0 then return '' end
local tSource = Title:new(wdo)
if not tSource then return '' end
local title = tSource.title.text
local regie = SDA.MainSnackValue(wdo, 'P57')
local country = SDA.MainSnackValue(wdo, 'P495')
local year = SDA.MainSnackValue(wdo, 'P577')
local result = ''
if regie and regie ~= '' then
result = result .. 'Film von ' .. regie .. ': '
else result = result .. 'Film: ' end
result = result .. tSource:titleLink() .. '. '
if country then
if year then
result = result .. country .. ' ' .. year:format('yyyy') .. ', '
else
result = result .. country .. ', '
end
elseif year then
result = result .. year:format('yyyy') .. ', '
end
result = result .. ' ' .. table.concat(IDs, ', ')
local b = tSource:infoBrace(nil, nil, 1)
if b and b ~= '' then result = result .. ' ' .. b end
return result
end
local function message(frame)
mw.logObject(frame.args, 'message with')
local data = frame.args[1]
if not data or data == '' then
data = frame.args.wdObject
end
if data then mw.log('data is "' .. data .. '"') end
if not data or data == '' then
data = 'Bitte Datenobjekt angeben!'
elseif not data:match('Q%d+') then
data = 'Bitte Wikidata Datenobjekt (Q123...) angeben!'
else
data = 'Bitte im Datenobjekt [[d:' .. data:match('Q%d+')
.. ']] einen Titel ([[d:Property:P1476|P1476]]) angeben!'
end
data = frame:extensionTag('span', data, { style="color:#f00;" })
return data
end
p.ref = function(frame)
local data = byWD(frame)
if not data or data == '' then data = message(frame) end
local result
if frame.args.name and frame.args.name ~= '' then
if frame.args.group and frame.args.group ~= '' then
result = '<ref name="' .. frame.args.name .. '" group="'
.. frame.args.group .. '">' .. data .. '</ref>'
else
result = '<ref name="' .. frame.args.name .. '">' .. data
.. '</ref>'
end
else
if frame.args.group and frame.args.group ~= '' then
result = '<ref group="' .. frame.args.group .. '">' .. data
.. '</ref>'
else
result = '<ref>' .. data .. '</ref>'
end
end
return frame:preprocess(result)
end
p.entry = function(frame)
local data = byWD(frame)
if not data or data == '' then return message(frame) end
mw.log(data)
return data
end
p.weblinks = function(frame)
local wdo = mw.wikibase.getEntityIdForCurrentPage()
if not wdo then return '' end
local tSource = mw.title.getCurrentTitle()
if not tSource then return '' end
local title = tSource.text
local IDs = {}
for k, v in pairs(IDbase) do
local ID = SDA.MainSnackValue(wdo, k)
if ID and ID ~= '' then
table.insert(IDs, string.format(v, ID) .. ' ' .. ID .. ']')
end
end
if #IDs == 0 then return '' end
return title .. ' in...<ul><li>' .. table.concat(IDs, '</li><li>')
.. '</li></ul>'
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.