RuneScape Wiki
Advertisement

Documentation for this module may be created at Module:Talkheader/doc

--<nowiki>
local p = {}

local hc = require('Module:Paramtest').has_content

local title = mw.title.getCurrentTitle()

local pagetype = {
	[''] = 'article',
	Template = 'template',
	RuneScape = 'project page',
	Project = 'project page',
	File = 'file',
}

function p.main(frame)
	local args = frame:getParent().args
	local subj = title.subjectPageTitle
	return p._main({
		subjectpage = subj.fullText,
		subjectpagenons = subj.text,
		talkpage = title.fullText,
		override = args[1],
		nolink = hc(args.nolink),
		ns = title.nsText,
	})
end


function p._main(args)
	
	local table = mw.html.create('table')
	local display, linkpg, link, str
	if hc(args.override) then
		display = args.override
	elseif args.ns == 'User talk' then
		display = args.subjectpagenons:gsub('/[Aa]rchive ?%d+$', '')
	else
		display = args.subjectpage:gsub('/[Aa]rchive ?%d+$', '')
	end
	
	
	linkpg = args.subjectpage:gsub('/[Aa]rchive ?%d+$', '')
	
	if args.nolink then
		link = display
	else
		link = '[[:' .. linkpg .. '|' .. display .. ']]'
	end
	
	
	if args.ns == 'User talk' then
		str = 'This is ' .. link .. '\'s [[RuneScape:Talk page|talk page]], where you can send messages to ' .. args.subjectpagenons .. '.'
	else
		str = string.format('This [[RuneScape:Talk page|talk page]] is for discussing changes to the %s %s.', link, pagetype[ns] or 'page')
	end
	
	table:addClass('messagebox info')
		:attr('id', 'talkheader')
		:css('border-left', 'none')
		:tag('tr')
			:tag('th')
				:attr('colspan', 2)
				:css({
					['text-align'] = 'center',
					['background-color'] = '#898989',
					color = 'white'
				})
				:wikitext(str)
			:done()
		:done()
	local bottomtr = table:tag('tr')
	local leftul = bottomtr:tag('td'):tag('ul')
	leftul:tag('li')
			:wikitext('[[RuneScape:Signatures|Sign and date your posts]] by typing four tildes (<code>~~~~</code>).')
	leftul:tag('li')
			:wikitext('Put new text under old text.')
			:tag('span')
				:addClass('plainlinks')
				:wikitext('['..tostring(mw.uri.fullUrl(args.talkpage, 'action=edit&section=new')) ..' Click here to start a new topic]')
			:done()
			:wikitext('.')
	leftul:tag('li')
			:wikitext('New to the RuneScape Wiki? [[RuneScape:Frequently asked questions|Read our FAQ]].')
	
	local rightul = bottomtr:tag('td'):tag('ul')
	rightul:tag('li')
			:wikitext('[[RuneScape:User treatment policy|Be civil]]')
	rightul:tag('li')
			:wikitext('[[RuneScape:Assume good faith|Assume good faith]]')
	rightul:tag('li')
			:wikitext('[[RuneScape:Don\'t delete discussions|Don\'t delete discussions]]')
	
	if args.ns == 'Talk' then
		rightul:tag('li')
				:wikitext('[[RuneScape:Neutral point of view|Take a neutral point of view]]')
	end
	
	return table
end



return p
Advertisement