Module:Wikipedia Signpost/Main page top preview

Revision as of 08:00, 16 July 2021 by Zoran (talk | contribs) (Pywikibot 6.4.0)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This module allows Wikipedia:Wikipedia Signpost/Templates/Main page top to be previewed with today's date and an incremented issue number. This is used by the Signpost Publication Script during "dry-run" publication tests. Template:Notice


Usage

{{#invoke:Wikipedia Signpost|top}}

Lua error at line 9: attempt to index a nil value.


-- This module allows [[Wikipedia:Wikipedia Signpost/Templates/Main page top]] to
-- be previewed with today's date and an incremented issue number.

p = {}

p.top = function()
	local title = mw.title.new("Wikipedia:Wikipedia Signpost/Templates/Main page top")
	local wikitext = title:getContent()
		:gsub("<!%-%-.-%-%->","") -- remove comments
		:gsub("<noinclude>.-</noinclude>","") -- remove noincludes
		:gsub("{{Wikipedia:Wikipedia Signpost/Issue|1}}", "{{TODAY}}") -- use current date
		:gsub( -- increment issue number
			"{{Str right|{{Wikipedia:Wikipedia Signpost/Issue|2}}|10}}",
			"issue {{#expr:1+{{Str right|{{Wikipedia:Wikipedia Signpost/Issue|2}}|16}}}}"
		)
	-- process and return the wikitext
	return mw.getCurrentFrame():preprocess( wikitext )
end

return p