Documentation for this module may be created at Module:AuthorNews/doc
local getArgs = require('Module:Arguments').getArgs
local News = require('Module:NewsItem')
local cargo = mw.ext.cargo
local limit = 100000
local p = {}
function p.main(frame)
local args = getArgs(frame)
local results = p.query(mw.title.getCurrentTitle().text)
if #results > 0 then
local container = mw.html.create('div'):attr('id', 'news-search-container')
local ul = mw.html.create('ul')
for r = 1, #results do
ul:node(mw.html.create('li'):node(News.main(newsObject(results[r]))))
end
container:node(ul)
return container
end
end
function p.query(author)
local tables = 'News'
local fields = '_pageName, date, category, game, image, content'
local cargoArgs = {
where = 'author ="' .. author .. '"',
orderBy = 'date DESC',
limit = limit
}
local results = cargo.query(tables, fields, cargoArgs)
return results
end
function newsObject(result)
local object = {
date = result.date,
_pageName = result._pageName,
category = result.category,
game = result.game,
content = result.content,
author = result.author
}
return object
end
return p