Module:RSPTest

A test version of a "row-builder" module for the Perennial sources project. See Talk.

Module:RSPTest

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

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.