No edit summary |
No edit summary |
||
Line 353: | Line 353: | ||
---- Template:Listof/Lineages/Treefather |
---- Template:Listof/Lineages/Treefather |
||
---- Template:Listof/Lineages/Grand Emperor |
---- Template:Listof/Lineages/Grand Emperor |
||
− | ---- |
+ | ---- Template:Listof/Lineages/Dao Lineages |
function p.imperial_lineages(frame) |
function p.imperial_lineages(frame) |
||
local args = getArgs(frame) |
local args = getArgs(frame) |
Revision as of 12:56, 2 August 2021
Documentation for this module may be created at Module:MessageBox/doc
local p = {}
local m = require("Module:Main")
local getArgs = require('Dev:Arguments').getArgs
function p.main(frame)
local args = getArgs (frame)
local pagename = mw.title.getCurrentTitle().text
local left = args['left'] or ''
local right = args['right'] or ''
local left_width = args['left-width'] or '5%'
local right_width = args['right-width'] or '5%'
local header = args['header'] or ''
local border_color = args['border-сolor'] or ''
local background_color = args['background-color'] or ''
local font_size = args['font-size'] or '100%'
local message = args[1] or args['message']
local output = ''
if not m.empty(header)
then header = header .. '<br />'
end
if not m.empty(left)
then left = p.td(left, left_width)
end
if not m.empty(right)
then right = p.td(right, right_width)
end
if m.empty(message)
then message = ''
end
message = '<td>' .. header .. message .. '</td>'
output = mw.html.create( 'table' )
:attr( 'class', 'MessageBox' )
:attr( 'align', 'center' )
:css( 'font-size', font_size)
:wikitext(left .. message .. right)
:done()
if not m.empty(border_color)
then output:css( 'border' , '1.3px solid ' .. border_color )
end
if not m.empty(background_color)
then output:css( 'background-color', background_color )
end
output = tostring(output)
if not m.empty(args['Message']) or not m.empty(args['Color'])
then output = output..m.add_category('Message Templates')
end
return output
end
function p.td(text, width)
local output = mw.html.create( 'td' )
:css( 'width', width )
:wikitext(text)
:done()
return tostring(output)
end
--------------------------------------------------------------------------------------------
function p.left_image(text, image)
return '<span class="plainlinks">[https://{{SERVER}}{{localurl:Template:'..text..'}} '..image..']</span>'
end
--------------------------------------------------------------------------------------------
function p.navigation_links(list_of_links)
local function nonexistent_page(text)
return tostring( mw.html.create('span'):css('color', 'silver'):wikitext(text))
end
local i
local output = {}
for i = 1, #list_of_links do
if m.exists({'Category:'..list_of_links[i][1]})
then table.insert( output, m.category_link(list_of_links[i][1], list_of_links[i][2]) )
else table.insert( output, nonexistent_page(list_of_links[i][2]) )
end
end
output = mw.text.listToText(output, ' · ', ' · ')
return '<br>'..tostring( mw.html.create('span'):css('font-size', '80%'):css('font-family', 'monospace'):wikitext(output) )
end
-- *****************************************************************************************
-- message templates
-- *****************************************************************************************
--------------------------------------------------------------------------------------------
function p.stub(frame)
local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
header = tostring(header:wikitext('This article is a stub.'))
return frame:preprocess( p.main({
message = 'You can help this wiki by expanding it.',
header = header,
['background-color'] = '#e9eef5',
['border-сolor'] = '#4c99f5'
}) )
end
--------------------------------------------------------------------------------------------
function p.image_templates(frame)
--local image = 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Ambox_warning_yellow.svg/54px-Ambox_warning_yellow.svg.png'
local pagename = mw.title.getCurrentTitle().text
local message = ''
if pagename == 'Fairuse'
then
message = '[[wikipedia:Fair use|This file will be used in a way that qualifies as fair use under US copyright law.]]'
--left = p.left_image(pagename, image)
end
return frame:preprocess( p.main({
message = message,
--left = left,
['background-color'] = '#fffbcc',
['border-сolor'] = '#f4c930'
}) )
end
--------------------------------------------------------------------------------------------
function p.delete(frame)
--local left = p.left_image('Delete', 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/16/Deletion_icon.svg/54px-Deletion_icon.svg.png')
local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
header = tostring(header:wikitext('This page is a candidate for deletion.'))
return frame:preprocess( p.main({
message = 'Remember to check [[Special:Whatlinkshere/{{FULLPAGENAME}}|what links here]] and [{{fullurl:{{FULLPAGENAME}}|action=history}} the page history] before deletion.',
header = header,
--left = left,
['background-color'] = '#fff4f2',
['border-сolor'] = 'red'
}) )
end
--------------------------------------------------------------------------------------------
function p.disambiguation(frame)
--local left = p.left_image('Disambig', 'https://upload.wikimedia.org/wikipedia/en/thumb/5/5f/Disambig_gray.svg/54px-Disambig_gray.svg.png')
local pagename = mw.title.getCurrentTitle().text
local header1 = mw.html.create('span'):css('font-size', '130%')
local header2 = mw.html.create('span'):css('font-weight', 'bold')
pagename = string.gsub(pagename, ' %([Dd]isambiguation%)', '')
header2 = tostring( header2:wikitext(pagename) )
header1 = tostring( header1:wikitext('This disambiguation page lists articles associated with '..header2..'.') )
return frame:preprocess( p.main({
message = 'If an internal link led you here, you may wish to change the link to point directly to the intended article.',
header = header1,
--left = left,
['background-color'] = 'whitesmoke',
['border-сolor'] = 'darkgray',
['font-size'] = '80%'
}) )
end
--------------------------------------------------------------------------------------------
function p.warning(frame)
local args = getArgs(frame)
local message = args[1] or ''
--local left = p.left_image('Warning', 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/Ambox_warning_pn.svg/54px-Ambox_warning_pn.svg.png')
return frame:preprocess( p.main({
message = message,
--left = left,
['background-color'] = '#fff4f2',
['border-сolor'] = 'red'
}) )
end
--------------------------------------------------------------------------------------------
function p.unofficial_name(frame)
--local left = p.left_image('Unofficial Name', 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/Ambox_warning_pn.svg/54px-Ambox_warning_pn.svg.png')
local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
header = tostring(header:wikitext('Unofficial Name'))
return frame:preprocess( p.main({
message = "The name of this article wasn't revealed in the novel and instead was given by editors of the wiki as substitute for lack thereof.",
header = header,
--left = left,
['background-color'] = '#fff4f2',
['border-сolor'] = 'red'
}) )
end
--------------------------------------------------------------------------------------------
function p.admin_tasks(frame, nocat, message)
local title = mw.title.getCurrentTitle()
local pagename = title.text
local basepagename = title.baseText
local subpagename = title.subpageText
local args = getArgs(frame)
local category = ''
local s = ''
local message2 = ''
--local left = p.left_image('Admin Tasks', 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Ambox_warning_purple.svg/54px-Ambox_warning_purple.svg.png')
local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
header = tostring(header:wikitext('This is a maintenance category; it is good if it is empty.'))
if m.empty(message) and m.empty(args['message'])
then message = 'It is used for maintenance of the wiki and is not part of the encyclopedia.'
else message = message or args['message']
end
local main_message = p.main({
message = message,
header = header,
--left = left,
['background-color'] = 'lavender',
['border-сolor'] = 'rebeccapurple'
})
if m.empty(nocat) and m.empty(args['nocat'])
then category = m.add_category('Admin Tasks')
end
s = string.match(pagename, '(.+) Category Needed')
if not m.empty(s)
then
message2 = p.main( { message = "Pages that have articles in <code>Category:——/"..s.."</code>, but category isn't created."} )
category = m.add_category('Category Needed')
end
if string.find(pagename, 'Unknown Region ') ~= nil
then
if basepagename == subpagename
then category = m.add_category('Unknown Region')
else category = ''
end
end
return frame:preprocess( main_message..'<br />'..message2..category )
end
--------------------------------------------------------------------------------------------
function p.fate_palaces(frame)
local pagename = mw.title.getCurrentTitle().text
local sortname = ''
local number
local number_to_text
local ordinal_number
local text
local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
local i
local navigation = {}
local message = ''
local categories = {}
local output = ''
number, text = string.match(pagename, '(%d+) (.+)')
if not m.empty(number)
then
table.insert(categories, 'Characters by Number of Fate Palaces')
sortname = number
number = tonumber(number)
number_to_text = string.lower(m.number_to_text(number))..' '
ordinal_number = m.ordinal_number(number)
text = m.link(text)..'.'
header = tostring(header:wikitext('List of characters who opened '..number_to_text..text))
table.insert(navigation, {'1 Fate Palace', 1})
for i = 2, 13 do
table.insert(navigation, {i..' Fate Palaces', i})
end
navigation = p.navigation_links(navigation)
if number == 1
then message = 'Cultivators from the [[Palace Foundation]] level to [[Yun Physique]] level can have only one [[Fate Palace]].'
elseif number == 2
then message = 'Cultivators from the [[Provisional Palace]] level to [[Royal Noble]] level can have only two [[Fate Palace]]s.'
elseif number == 3
then message = 'Cultivators at the [[Royal Noble]] level or higher.'
elseif number > 3 and number < 7
then message = 'Cultivators who opened their '..ordinal_number..' [[Fate Palace]] at the [[Royal Noble]] level or cultivators of the [[Ancient Saint]] level and higher.'
elseif number >= 7
then message = 'Cultivators who opened their '..ordinal_number..' [[Fate Palace]] at the [[Ancient Saint]] level.'
end
output = p.main({message = message..navigation, header = header})
elseif pagename == 'Characters by Number of Fate Palaces'
then
table.insert(categories, 'Characters by Cultivation')
table.insert(categories, 'Fate Palaces')
output = p.main({message = 'List of characters by the number of opened [[Fate Palace]]s.'})
elseif pagename == 'Characters by Fate Palace'
then
table.insert(categories, 'Characters by Cultivation')
table.insert(categories, 'Fate Palaces')
output = p.main({message = 'List of characters by type of the [[Fate Palace]].'})
elseif pagename == 'Fate Palaces'
then
table.insert(categories, 'Cultivation')
output = p.main({message = 'Types of [[Fate Palace]]s.'})
else
table.insert(categories, 'Characters by Fate Palace')
output = p.main({message = 'List of characters with '..m.link(pagename, _, true)..'.'})
end
return output..m.add_categories(categories, sortname)
end
--------------------------------------------------------------------------------------------
-- Template:Listof/Heaven's Will
function p.number_of_heaven_wills(frame)
local pagename = mw.title.getCurrentTitle().text
local n
local i
local navigation = {}
local message = ''
local categories = {}
local output = ''
table.insert(navigation, {"1 Heaven's Will", 1})
for i = 2, 12 do
table.insert(navigation, {i.." Heaven's Wills", i})
end
navigation = p.navigation_links(navigation)
n = string.match(pagename, '(%d+) ')
table.insert(categories, "Characters by Number of Heaven's Wills")
n = tonumber(n)
if n == 1
then output = 'one '..m.link("Heaven's Will")
else output = string.lower( m.number_to_text(n) )..' '..m.link("Heaven's Will", "Heaven's Wills")
end
output = p.main({message = 'List of characters with '..output..navigation})
return output..m.add_categories(categories)
end
--------------------------------------------------------------------------------------------
-- used in:
---- Template:Listof/Lineages/Immortal Emperor
---- Template:Listof/Lineages/Sea God
---- Template:Listof/Lineages/Treefather
---- Template:Listof/Lineages/Grand Emperor
---- Template:Listof/Lineages/Dao Lineages
function p.imperial_lineages(frame)
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().text
local list = {
['Imperial Lineages'] = 'Immortal Emperor',
['Treefather Lineages'] = 'Treefather',
['Sea God Lineages'] = 'Sea God',
['Grand Emperor Lineages'] = 'Grand Emperor',
['Dao Lineages'] = 'True Emperor',
}
local lineage_type = args.lineage
local i
local n
local l_type = ''
local navigation = {}
local output_category = ''
local output = ''
if pagename == lineage_type
then
output = p.main({message = 'List of '..m.link(pagename, _, true)..'.'})
output_category = 'Locations by Type'
else
output_category = lineage_type
n = string.match(pagename, '(%d+) ')
n = tonumber(n)
if n == 1
then l_type = list[lineage_type]
else l_type = list[lineage_type]..'s'
end
table.insert(navigation, {'1 '..list[lineage_type], 1})
for i = 2, 15 do
table.insert(navigation, {i..' '..list[lineage_type]..'s', i})
end
navigation = p.navigation_links(navigation)
n = string.lower( m.number_to_text(n) )
output = 'List of '..m.link(lineage_type, _, true)..' with '..n..' '..m.link(list[lineage_type], l_type, true)..'.'
output = p.main({message = output..navigation})
end
return output..m.add_category(output_category)
end
return p