Introducing: Representatives. swedishwin.com, chud.win, and soyzellig.party positions are vacant.
The new Community missions system is now live! Where anyone can propose a task, discuss nominations, or join the current mission. Community missions give editors a place to turn requests from the Janny noticeboard into focused projects. No mission can be too small
Module:News/latest
From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
| This module is rated as ready for general use. It is considered stable and may be used wherever appropriate. Improvements should be developed and tested in a sandbox before changing the live module. |
| This module depends on the following other modules: |
Finds the newest listed issue of the newspaper and returns a piece of it. Used by Template:News/latest by the nameplates and links row. Do not ever invoke this module for anything else if you don't know what you are doing.
Usage
{{News/latest|<part>}}
| part | returns |
|---|---|
page |
The newest issue's page title |
number |
Its number,, as "No. x" |
date |
Its date, in the short format from config |
line |
the latest label from config, e.g. "Latest: No 2, November 15, 2026"
|
Notes
Newest listed will skip drafts and embargoed issues and there is no override.
local p = {}
local getArgs = require('Module:Arguments').getArgs
local News = require('Module:News')
local cfg = News.cfg
local function part(state, what, latest, list)
if what == 'link' then
if latest == nil then return '' end
return News.link(latest.page, News.text(state, 'latestIssueLink'))
end
if what == 'count' then return tostring(#list) end
if what == 'line' then
if latest == nil then return News.text(state, 'noIssues') end
return News.text(state, 'latest', {
number = News.numberText(state, latest),
date = News.formatDate(News.need('shortDateFormat'), latest.date),
})
end
if what ~= 'page' and what ~= 'number' and what ~= 'date' then
return News.errorText(state, 'unknownPart', { value = tostring(what) })
end
if latest == nil then return '' end
if what == 'page' then return latest.page end
if what == 'number' then return News.numberText(state, latest) end
return News.formatDate(News.need('shortDateFormat'), latest.date)
end
function p.main(frame)
local args = getArgs(frame, { wrappers = cfg.wrappers })
local state = News.newState()
local list = News.listed(News.today(frame))
local what = args[1]
local output = part(state, what, list[1], list)
if not state.hasError and (what == 'page' or what == 'number' or what == 'date' or what == 'count') then
return output
end
return News.finish(state, output)
end
return p
