No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
orderBy = 'date' | orderBy = 'date' | ||
} | } | ||
local results = cargo.query(tables, fields, cargoArgs) | local results = cargo.query(tables, fields, cargoArgs) | ||
local container = mw.html.create() | local container = mw.html.create() | ||
if #results > 0 then | if #results > 0 then | ||
container:node(mw.html.create('h2'):wikitext('Interviews')) | container:node(mw.html.create('h2'):wikitext('Interviews')) | ||
empty = false | empty = false | ||
local ul = mw.html.create('ul') | local ul = mw.html.create('ul') | ||
for r = 1, #results do | for r = 1, #results do | ||
ul:node(mw.html.create('li'):node(News.main(pageNews.object(results[r])))) | ul:node(mw.html.create('li'):node(News.main(pageNews.object(results[r])))) | ||
end | end | ||
container:node(ul) | container:node(ul) | ||
end | end | ||
Line 40: | Line 33: | ||
return '<span class="d-none"></span>' | return '<span class="d-none"></span>' | ||
else | else | ||
return container | return container | ||
end | end | ||
Revision as of 05:26, 11 October 2022
Documentation for this module may be created at Module:PageNews/doc
local cargo = mw.ext.cargo
local News = require('Module:NewsItem')
local pageNews = {}
function pageNews.main(frame)
local currentTitle = mw.title.getCurrentTitle().text
local empty = true
-- Check if there are any interviews for this page
local tables = 'News'
local fields = 'date, title, type, author, lang, source, trans_lang, translator, event, note, targets'
local cargoArgs = {
where = 'targets HOLDS "' .. currentTitle .. '" AND type="interview"',
orderBy = 'date'
}
local results = cargo.query(tables, fields, cargoArgs)
local container = mw.html.create()
if #results > 0 then
container:node(mw.html.create('h2'):wikitext('Interviews'))
empty = false
local ul = mw.html.create('ul')
for r = 1, #results do
ul:node(mw.html.create('li'):node(News.main(pageNews.object(results[r]))))
end
container:node(ul)
end
if empty then
return '<span class="d-none"></span>'
else
return container
end
end
function pageNews.object(result)
local object = {}
object.date = result.date
object.lang = result.lang
object.url = result.url
object.author = result.author
object.source = result.source
object.event = result.event
object.trans_lang = result.trans_lang
object.translator = result.translator
object.event = result.event
return object
end
return pageNews