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('div')
container:wikitext(frame:preprocess("== News =="))
frame:newChild({title = "Your page here"}, frame:preprocess("== News =="))
if #results > 0 then
container:node(mw.html.create('h2'):addClass('mw-collapsible'):wikitext('Interviews'))
empty = false
local ul = mw.html.create('ul')
local interviews = mw.html.create('div'):node(ul)
for r = 1, #results do
ul:node(mw.html.create('li'):node(News.main(pageNews.object(results[r]))))
end
container:node(interviews)
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