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/ear

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search

Draws the "ear", the small box beside the nameplate of the newspaper. Used by Template:News/ear by both nameplates in different context.

This module and template are already provided in the issue preload and do not require manual handling.

Usage

{{News/ear|<value>|for=<where>}}. for= may be front or issue.

value shows
default The ear from config for that page: frontEar with for=front, issueEar with for=issue.
latest A promo for the newest issue, its number, and a link to it. (labels are earLatestTop and earLatestLink).
none or blank outputs nothing
anything else an override that puts your text in the box

Notes

In any ear text, be it from config or typed, $newsroom is replaced with the title. This means that you should use [[$newsroom|NEWSROOOM]] for any link. Using default without for will crash the module.


local p = {}

local getArgs = require('Module:Arguments').getArgs
local News = require('Module:News')
local cfg = News.cfg

local function promo(state, frame)
	local latest = News.listed(News.today(frame))[1]
	if latest == nil then return nil end
	return '<span class="sn-news-ear-top">'
		.. News.text(state, 'earLatestTop')
		.. '</span>'
		.. '<span class="sn-news-ear-number">'
		.. News.numberText(state, latest)
		.. '</span>'
		.. '<span class="sn-news-ear-link">[['
		.. latest.page
		.. '|'
		.. News.text(state, 'earLatestLink')
		.. ']]</span>'
end

function p.main(frame)
	local args = getArgs(frame, { wrappers = cfg.wrappers })
	local state = News.newState()
	local value = args[1]
	if value == nil or value == 'none' then return '' end

	if value == 'default' then
		local which = args['for']
		if which == 'front' then
			value = cfg.frontEar
		elseif which == 'issue' then
			value = cfg.issueEar
		else
			return News.finish(state, News.errorText(state, 'unknownPart', { value = tostring(which) }))
		end
	end
	if value == nil then return '' end
	local content
	if value == 'latest' then
		content = promo(state, frame)
		if content == nil then return '' end
	else
		content = News.fill(value, { newsroom = News.pageTitle('newsroom') })
	end
	return News.finish(state, '<div class="sn-news-ear">' .. content .. '</div>')
end

return p