Module:RSPTest
| This module is rated as pre-alpha. It is incomplete and may or may not be in active development. Do not use it in article namespace pages. A module remains in pre-alpha until its developer, or another editor who adopts it if it is abandoned for some time, considers the basic structure complete. |
A test version of a "row-builder" module for the Perennial sources project. See Talk.
Usage
[edit]{{#invoke:RSPTest|main}}
See also
[edit]- {{RSPTest}} – wrapper
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=]] " .. 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