(Created page with "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( args) 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]...") |
mNo edit summary |
||
Line 9: | Line 9: | ||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local results = p.query( | local results = p.query(mw.title.getCurrentTitle().text) | ||
if #results > 0 then | if #results > 0 then | ||
Line 26: | Line 26: | ||
end | end | ||
function p.query( | function p.query(author) | ||
local tables = 'News' | local tables = 'News' | ||
local fields = '_pageName, date, category, game, image, content' | local fields = '_pageName, date, category, game, image, content' |
Latest revision as of 14:43, 29 April 2024
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