Module:Reliability
Documentation for Module:Reliability, which is the only executable code on this wiki and the single source of truth for the reliability tags.
What it does
The module holds one table of tags. Each entry carries a label, a colour, the meaning shown on hover, and the tracking category the tag files a page into. Two functions read that table:
p.tag- Called by
{{R}}
. Renders one tag as an inline chip and, in the main namespace only, adds the tracking category.
p.legend- Called by
{{Legend}}
. Renders the whole table as the legend shown on the Main Page and in Help:Reading this wiki.
Both read the same table, which is the point: the legend cannot fall out of step with the tags in use. Add a tag to the module and it appears in the legend by itself.
Adding a tag
Add an entry to tags and its key to order. The order is the order of the legend, and it is not alphabetical — it runs from what one person will swear to down through what nobody will stand behind. Put a new tag where it belongs on that scale.
Then create the tracking category named in the entry, and give it a description, and file it under Category:Reliability tags.
Aliases go in aliases. Anything unrecognised falls back to unverified, which is also the default when the first parameter is empty or missing.
Notes for anyone editing it
- TemplateStyles is not installed on this wiki. All styling is inline, deliberately. Do not extract it into a stylesheet that does not exist.
- Colours are dark with light text so they survive whatever skin a reader is using. They are also required to be visually distinct from each other — with one exception, noted in the source:
astroturfis deliberately close tofirsthand, because that is what astroturf is built to resemble. - Categories are added in the main namespace only. A template or help page demonstrating a tag should not appear as though it were making a claim.
p.tagaccepts being called either through{{R}}
or directly via #invoke, and does not assume a parent frame exists.
Testing
The module is plain Lua 5.1 apart from its use of mw.text, mw.ustring and mw.title. It can be exercised outside the wiki by stubbing those three, which is how the current version was checked before it was imported — 52 assertions covering tag resolution, aliases, defaults, namespace gating, attribute escaping, the direct-invoke path, and that every chip colour is still distinct.
If you change the module, run something equivalent. A broken module does not fail quietly here: it puts a script error on every page that carries a tag, which is most of them.
-- Module:Reliability
--
-- Single source of truth for the wiki's reliability tags.
-- Template:R renders one tag. Template:Legend renders the whole table.
-- Add a tag here and it appears in the legend automatically.
local p = {}
-- Ordered because the legend reads as a scale: what one person swears to,
-- down through what nobody will stand behind.
local order = {
'firsthand', 'astroturf', 'unverified', 'contested', 'leaked',
'defector', 'inherited', 'warning', 'synthetic',
}
local tags = {
firsthand = {
label = 'firsthand',
colour = '#1f4d2e',
meaning = 'Someone claims they were there. Uncorroborated by definition — '
.. 'a seeker who survives an encounter is not thereby a reliable witness to it.',
category = 'Firsthand accounts',
},
astroturf = {
label = 'astroturf',
-- Deliberately close to firsthand's green. That is what astroturf is for:
-- it is built to be mistaken for the real thing at a glance. Read the word.
colour = '#3f7a3f',
meaning = 'A claim that is made to look like many independent people arriving at the '
.. 'same conclusion, and is not. Manufactured human consensus — as distinct from '
.. 'synthetic?, which is text with no person behind it at all.',
category = 'Manufactured consensus',
},
unverified = {
label = 'unverified',
colour = '#3a3a3a',
meaning = 'The default state of everything here. Written down, passed on, never confirmed. '
.. 'Absence of this tag means nothing; assume it.',
category = 'Unverified accounts',
},
contested = {
label = 'contested',
colour = '#6b4310',
meaning = 'Two or more accounts survive and they do not agree. Both are recorded. '
.. 'Do not resolve the contradiction by deleting half of it.',
category = 'Contested accounts',
},
leaked = {
label = 'leaked',
colour = '#4a1f3d',
meaning = 'Taken from a cult, an agency or a private archive by someone without permission. '
.. 'Consider who benefited from you reading it.',
category = 'Leaked material',
},
defector = {
label = 'defector',
colour = '#123f52',
meaning = 'Supplied by a former member of the body it describes. Detailed, bitter, '
.. 'and shaped by the leaving.',
category = 'Defector accounts',
},
inherited = {
label = 'inherited',
colour = '#4a3f22',
meaning = 'Copied from an older tome or an older wiki by hands that did not understand it. '
.. 'Errors here are centuries deep.',
category = 'Inherited material',
},
warning = {
label = '⚠ warning',
colour = '#6b1a1a',
meaning = 'Reading, repeating or attempting this has hurt people. '
.. 'The entry is kept because hiding it has also hurt people.',
category = 'Marked dangerous',
},
synthetic = {
label = 'synthetic?',
colour = '#2f2a5e',
meaning = 'Suspected of having been written by no one. Style without a source behind it. '
.. 'See [[The Pattern]].',
category = 'Suspected synthetic',
},
}
local aliases = {
['synthetic?'] = 'synthetic',
astroturfed = 'astroturf',
manufactured = 'astroturf',
ai = 'synthetic',
warn = 'warning',
unknown = 'unverified',
first = 'firsthand',
}
local function resolve( name )
name = mw.text.trim( ( name or '' ):lower() )
name = aliases[ name ] or name
return tags[ name ] and name or 'unverified'
end
-- The chip itself. TemplateStyles is not installed on this wiki, so the styles
-- are inline on purpose. Colours are dark with light text so they survive
-- whatever skin the reader is using.
local function chip( key, suffix, title )
local t = tags[ key ]
return mw.ustring.format(
'<span class="sp-tag sp-tag-%s" title="%s" style="display:inline-block;'
.. 'font-family:monospace;font-size:0.78em;line-height:1.5;padding:0 6px;'
.. 'border-radius:3px;white-space:nowrap;color:#e8e4dc;background:%s;'
.. 'border:1px solid rgba(255,255,255,0.2);">%s%s</span>',
key,
mw.text.encode( title or ( t.meaning:gsub( '%[%[(.-)%]%]', '%1' ) ) ),
t.colour,
t.label,
suffix or ''
)
end
-- {{R|leaked|by=anon|date=1998|note=...}}
function p.tag( frame )
local parent = frame:getParent()
local args = parent and parent.args or frame.args
local key = resolve( args[1] )
local suffix = ''
if args.by and args.by ~= '' then
suffix = suffix .. ' · ' .. args.by
end
if args.date and args.date ~= '' then
suffix = suffix .. ' · ' .. args.date
end
local out = chip( key, suffix, args.note )
-- Only track articles. Templates and help pages demonstrating a tag
-- should not show up as if they were claims.
if mw.title.getCurrentTitle().namespace == 0 then
out = out .. '[[Category:' .. tags[ key ].category .. ']]'
end
return out
end
function p.legend( frame )
local rows = {}
for _, key in ipairs( order ) do
table.insert( rows, mw.ustring.format(
'|-\n| style="padding:6px 10px;vertical-align:top;white-space:nowrap;" | %s\n'
.. '| style="padding:6px 10px;vertical-align:top;" | %s',
chip( key ), tags[ key ].meaning
) )
end
return '{| class="wikitable" style="width:100%;max-width:52em;"\n'
.. '! style="text-align:left;padding:6px 10px;" | Tag\n'
.. '! style="text-align:left;padding:6px 10px;" | What it means when you see it\n'
.. table.concat( rows, '\n' ) .. '\n|}'
end
return p