FANDOM


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.stub(frame)
    local left = p.left_image('Stub', 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Ambox_warning_blue.svg/54px-Ambox_warning_blue.svg.png')
    local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
    header = tostring(header:wikitext('This page is a stub.'))
 
    return frame:preprocess( p.main({
        message = 'It will be expanded later on.', 
        header = header, 
        left = left, 
        ['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.fate_palaces(frame)
    local pagename = mw.title.getCurrentTitle().text
    local sortname = ''
    local number
    local number_to_text
    local ordinal_number
    local text
    local next_category = ''
    local previous_category = ''
    local left = ''
    local right = ''
    local header = mw.html.create('span'):css('font-size', '130%'):css('font-weight', 'bold')
    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
            if #sortname == 1
                then sortname = '0'..sortname
            end
            number = tonumber(number)
            next_category = m.right_arrow( (number + 1)..' Fate Palaces' )
            previous_category = m.left_arrow( (number - 1)..' Fate Palaces' )
            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))
 
            if number == 1
                then 
                    previous_category = ''
                    message = 'Cultivators from the [[Palace Foundation]] level to [[Yun Physique]] level can have only one [[Fate Palace]].'
                elseif number == 2
                    then 
                        previous_category = m.left_arrow('1 Fate Palace')
                        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
            if number == 13
                then next_category = ''
            end
 
            output = p.main({message = message, header = header, left = previous_category, right = next_category})
        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
 
 
----------------------------------------------------------
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
 
 
return p
Community content is available under CC-BY-SA unless otherwise noted.