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 returnString = ''
local results = cargo.query(tables, fields, cargoArgs)
-- local container = mw.html.create('div')
local container = mw.html.create()
if #results > 0 then
container:node(mw.html.create('h2'):addClass('mw-collapsible'):wikitext('Interviews'))
-- returnString = returnString .. tostring(mw.html.create('h2'):wikitext('Interviews'))
empty = false
local ul = mw.html.create('ul')
-- local interviews = mw.html.create('div'):node(ul)
-- local interviews = mw.html.create('ul')
for r = 1, #results do
ul:node(mw.html.create('li'):node(News.main(pageNews.object(results[r]))))
end
-- mw.log('itnervisdsdad')
-- mw.log(ul)
-- mw.logObject(ul)
-- returnString = returnString .. tostring(ul)
container:node(ul)
end
if empty then
return '<span class="d-none"></span>'
else
mw.log('stringggggg')
mw.log(returnString)
return container
-- return returnString
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