Module:RSPTest: Difference between revisions – Wikipedia

Β 

Line 3: Line 3:

local p = {}

local p = {}

β€” Module entry point for generating a row

⚫

function p._row(args)

⚫

β€” Check for optional name qualifiers

⚫
for i, row in ipairs(data) do

local row_text =

local =

if args.name_qualifier then

⚫
β€œ|- class=\”s-” .. row.status .. β€œ\” id=\”” .. β€œ\n” ..

local name_qualifier = args.name_qualifier:gsub(β€œ^%((.+)%)$”, β€œ%1”) β€” remove data-provided brackets for italic reason

⚫

qualifier = qualifier .. ” <small>(”” .. name_qualifier .. β€œβ€)</small>”

⚫

end

⚫
row_text = row_text .. β€˜[[β€˜ .. row.shortcut .. β€˜|’ .. row.shortcut .. β€˜]]’

if args.content_qualifier then

qualifier = qualifier .. ” ” .. args.content_qualifier

end

β€” Create shortcut if it exists

local shortcut_text = β€œβ€

⚫ ⚫
= β€˜[[β€˜ .. .shortcut .. β€˜|’ .. .shortcut .. β€˜]]’

end

β€” gather RSN links

local rsn_links = {}

if args.rsnl then

for j, rsn in ipairs(args.rsnl) do

local archive = rsn.notice_id and β€œ/Archive ” .. rsn.notice_id or β€œβ€

local rsn_link = β€œ[[WP:Reliable sources/Noticeboard” .. archive .. β€œ#” .. rsn.notice_title .. β€œ|” .. (rsn.notice_year or rsn.notice_title) .. β€œ]]”

if rsn.rfc then

rsn_link = β€œ[[File:Treffpunkt.svg|20px|Request for comment|link=]]&nbsp;” .. rsn_link

end

end

rsn_links[j] = rsn_link

⚫
row_text = row_text .. ” || ” .. row.status ..
⚫

” || ” .. row.rsp_last ..

” || ” .. row.summary ..

⚫
” || ” β€” domain info to go here
⚫
β€” Mark deprecated entries with a tag
⚫
if row.status == β€œd” then
⚫
local section_begin = frame:extensionTag({name=”section”, args={begin=”deprecated”}})
⚫
local section_end = frame:extensionTag({name=”section”, args={[β€˜end’]=”deprecated”}})
⚫
row_text = section_begin .. β€œ\n” .. row_text .. β€œ\n” .. section_end

end

end

end

β€” Put it all together

local row_text =

⚫
β€œ|- class=\”s-” .. .status .. β€œ\” id=\”” .. β€œ\n” ..

β€œ| ” .. args.name .. qualifier .. shortcut_text ..

⚫

” || ” .. table.concat(rsn_links, ” β€œ) ..

⚫
” || ” ..
⚫
β€œ| ” .. .
⚫
” || ” β€” domain info to go here
⚫
β€” Mark deprecated entries with a tag
⚫
table.insert(out, row_text)
⚫
if .status == β€œd” then

local frame = mw.getCurrentFrame()

⚫
local section_begin = frame:extensionTag({name=”section”, args={begin=”deprecated”}})
⚫
local section_end = frame:extensionTag({name=”section”, args={[β€˜end’]=”deprecated”}})
⚫
row_text = section_begin .. β€œ\n” .. row_text .. β€œ\n” .. section_end

end

return row_text

end

β€” Template entry point for generating a row

β€” (Not perfectly supported right now, e.g. RSN entries require a table format)

function p.row(frame)

local args = require(β€œModule:Arguments”).getArgs(frame)

return p._row(args)

end

⚫ ⚫ ⚫
for i, row in ipairs(data) do
⚫
table.insert(out, )

end

end

return table.concat(out, β€œ\n”)

return table.concat(out, β€œ\n”)

local data = mw.loadData('Module:RSdata5/data')

local p = {}

-- Module entry point for generating a row
function p._row(args)
	-- Check for optional name qualifiers
	local qualifier = ""
	if args.name_qualifier then
		local name_qualifier = args.name_qualifier:gsub("^%((.+)%)$", "%1") -- remove data-provided brackets for italic reason
		qualifier = qualifier .. " <small>(''" .. name_qualifier .. "'')</small>"
	end
	if args.content_qualifier then
		qualifier = qualifier .. " " .. args.content_qualifier
	end
	
	-- Create shortcut if it exists
	local shortcut_text = ""
	if args.shortcut then
		shortcut_text = '<br />[[' .. args.shortcut .. '|<span class=wp-rsp-sc2>' .. args.shortcut .. '</span>]]'
	end
	
	-- gather RSN links
	local rsn_links = {}
	if args.rsnl then
		for j, rsn in ipairs(args.rsnl) do
			local archive = rsn.notice_id and "/Archive " .. rsn.notice_id or ""
			local rsn_link = "[[WP:Reliable sources/Noticeboard" .. archive .. "#" .. rsn.notice_title .. "|" .. (rsn.notice_year or rsn.notice_title) .. "]]"
			if rsn.rfc then
				rsn_link = "[[File:Treffpunkt.svg|20px|Request for comment|link=]]&nbsp;" .. rsn_link
			end
			rsn_links[j] = rsn_link
		end
	end
	
	-- Put it all together
	local row_text = 
		"|- class=\"s-" .. args.status .. "\" id=\"" .. "\n" ..
		"| " .. args.name .. qualifier .. shortcut_text .. 
		" || " .. args.status .. 
		" || " .. table.concat(rsn_links, " ") ..
		" || " .. args.rsp_last ..
		" || " .. args.summary ..
		" || " -- domain info to go here

	-- Mark deprecated entries with a <section> tag
	if args.status == "d" then
		local frame = mw.getCurrentFrame()
		local section_begin = frame:extensionTag({name="section", args={begin="deprecated"}})
		local section_end = frame:extensionTag({name="section", args={['end']="deprecated"}})
		row_text = section_begin .. "\n" .. row_text .. "\n" .. section_end
	end

	return row_text
end

-- Template entry point for generating a row
-- (Not perfectly supported right now, e.g. RSN entries require a table format)
function p.row(frame)
	local args = require("Module:Arguments").getArgs(frame)
	return p._row(args)
end

function p.main(frame)
	local out = {}
	for i, row in ipairs(data) do
		table.insert(out, p._row(row))
	end
	return table.concat(out, "\n")
end

return p

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version