Module:Sandbox: Difference between revisions

From Fanon Wiki
mNo edit summary
mNo edit summary
Line 9: Line 9:
local source = frame.args["source"] or "No source specified [[Category:Files lacking a source]]"
local source = frame.args["source"] or "No source specified [[Category:Files lacking a source]]"
local result = {}
local result = {}
local t = {
local t = {}
    audio, song, music, sound = "Audio [[Category:Audio files]]", audio, audio, audio,
t = {
    photo, photograph, photography = "Photograph [[Category:Photographs]]", photo, photo,
    ['art'] = "Official artwork [[Category:Official artworks]]",
    sprite, spritesheet, ['sprite sheet'] = "Sprite [[Category:Sprites]]", sprite, sprite,
    ['artwork'] = "Official artwork [[Category:Official artworks]]",
    screenshot, printscreen, prtscr, ['screen shot'] = "Screenshot [[Category:Screenshots]]", screenshot, screenshot, screenshot,
    ['art work'] = "Official artwork [[Category:Official artworks]]",
    map = "Map [[Category:Maps]]",
     
    flag = "Flag [[Category:Flags]]",
    ['audio'] = "Audio [[Category:Audio files]]",
    art, artwork, ['art work'] = "Official artwork [[Category:Official artworks]]", art,
    ['sound'] = "Audio [[Category:Audio files]]",
    fanart, fanartowrk, ['fan art'] = "Fanart [[Category:Fanarts]]", fanart, fanart, fanart,
    ['music'] = "Audio [[Category:Audio files]]",
    logo, logotype, logomark, wordmark = "Logotype [[Category:Logos]]", logo, logo, logo,
    ['sound'] = "Audio [[Category:Audio files]]",
    video, film, movie, short = "Video [[Category:Video files]]", video, video, video,
     
    scan, magazine = "Scan [[Category:Scans]]", scan,
    ['fanart'] = "Fanart [[Category:Fanarts]]",
    vector, svg = "Vector graphic [[Category:Vector images]]", vector
    ['fan art'] = "Fanart [[Category:Fanarts]]",
    ['fanartwork'] = "Fanart [[Category:Fanarts]]",
   
    ['flag'] = "Flag [[Category:Flags]]",
     
    ['logo'] = "Logotype [[Category:Logos]]",
    ['logotype'] = "Logotype [[Category:Logos]]",
    ['logomark'] = "Logotype [[Category:Logos]]",
    ['wordmark'] = "Logotype [[Category:Logos]]",
   
    ['map'] = "Map [[Category:Maps]]",
   
    ['photo'] = "Photograph [[Category:Photographs]]",
    ['photograph'] = "Photograph [[Category:Photographs]]",
    ['photography'] = "Photograph [[Category:Photographs]]",
     
    ['scan'] = "Scan [[Category:Scans]]",
    ['magazine'] = "Scan [[Category:Scans]]",
   
    ['screenshot'] = "Screenshot [[Category:Screenshots]]",
    ['screen shot'] = "Screenshot [[Category:Screenshots]]",
    ['printscreen'] = "Screenshot [[Category:Screenshots]]",
    ['print screen'] = "Screenshot [[Category:Screenshots]]",
    ['prtscr'] = "Screenshot [[Category:Screenshots]]",
     
    ['sprite'] = "Sprite [[Category:Sprites]]",
    ['spritesheet'] = "Sprite [[Category:Sprites]]",
    ['sprite sheet'] = "Sprite [[Category:Sprites]]",
     
    ['vector'] = "Vector graphic [[Category:Vector images]]",
    ['svg'] = "Vector graphic [[Category:Vector images]]",
   
    ['video'] = "Video [[Category:Video files]]",
    ['movie'] = "Video [[Category:Video files]]",
    ['film'] = "Video [[Category:Video files]]",
    ['short'] ="Video [[Category:Video files]]"
}
}
 
 
type = t[type] or "No type specified. [[Category:Unspecified files]]"
type = t[type] or "No type specified. [[Category:Unspecified files]]"
table.insert(result, 'DESC:'.. description .. ' / TYPE:'.. type ..' / SRC:'.. source..'')
table.insert(result, '<div class="panel" style="--panel-color: #c5c5c5"><div class="mb-2 panel-title">File information</div><table><tr><th class="p-1" style="background: #ff4242; color: #fff; border-radius: .5rem 0 0 0">Description</th><td class="p1">'.. description ..'</td></tr><tr><th class="p-1" style="background: #4292ff; color: #fff">Type</th><td class="p1" style="background: rgba(0,0,0,.12)">'.. type ..'</td></tr><tr><th class="p-1" style="background: #f5ff42; border-radius: 0 0 0 .5rem">Source/author</th><td class="p1">'.. source ..'</td></tr></table></div>')
table.insert(result, '<div class="panel" style="--panel-color: #c5c5c5"><div class="mb-2 panel-title">File information</div><table><tr><th class="p-1" style="background: #ff4242; color: #fff; border-radius: .5rem 0 0 0">Description</th><td class="p1">'.. description ..'</td></tr><tr><th class="p-1" style="background: #4292ff; color: #fff">Type</th><td class="p1" style="background: rgba(0,0,0,.12)">'.. type ..'</td></tr><tr><th class="p-1" style="background: #f5ff42; border-radius: 0 0 0 .5rem">Source/author</th><td class="p1">'.. source ..'</td></tr></table></div>')
return table.concat(result, "")
return table.concat(result, "")

Revision as of 19:34, 17 May 2022

A sandbox for testing lua modules. Since this is a module, it uses actual programming code instead of wiki formatting.


--Hey, this is a sandbox for Lua!
--Be careful :O

local f = {}

function f.main(frame)
	local description = frame.args["description"] or "No description provided [[Category:Files lacking description]]"
	local type = mw.ustring.lower(frame.args["type"] or "")
	local source = frame.args["source"] or "No source specified [[Category:Files lacking a source]]"
	local result = {}
	local t = {}
	t = {
	    ['art'] = "Official artwork [[Category:Official artworks]]",
	    ['artwork'] = "Official artwork [[Category:Official artworks]]",
	    ['art work'] = "Official artwork [[Category:Official artworks]]",
	    
	    ['audio'] = "Audio [[Category:Audio files]]",
	    ['sound'] = "Audio [[Category:Audio files]]",
	    ['music'] = "Audio [[Category:Audio files]]",
	    ['sound'] = "Audio [[Category:Audio files]]",
	    
	    ['fanart'] = "Fanart [[Category:Fanarts]]",
	    ['fan art'] = "Fanart [[Category:Fanarts]]",
	    ['fanartwork'] = "Fanart [[Category:Fanarts]]",
	    
	    ['flag'] = "Flag [[Category:Flags]]",
	    
	    ['logo'] = "Logotype [[Category:Logos]]",
	    ['logotype'] = "Logotype [[Category:Logos]]",
	    ['logomark'] = "Logotype [[Category:Logos]]",
	    ['wordmark'] = "Logotype [[Category:Logos]]",
	    
	    ['map'] = "Map [[Category:Maps]]",
	    
	    ['photo'] = "Photograph [[Category:Photographs]]",
	    ['photograph'] = "Photograph [[Category:Photographs]]",
	    ['photography'] = "Photograph [[Category:Photographs]]",
	    
	    ['scan'] = "Scan [[Category:Scans]]",
	    ['magazine'] = "Scan [[Category:Scans]]",
	    
	    ['screenshot'] = "Screenshot [[Category:Screenshots]]",
	    ['screen shot'] = "Screenshot [[Category:Screenshots]]",
	    ['printscreen'] = "Screenshot [[Category:Screenshots]]",
	    ['print screen'] = "Screenshot [[Category:Screenshots]]",
	    ['prtscr'] = "Screenshot [[Category:Screenshots]]",
	    
	    ['sprite'] = "Sprite [[Category:Sprites]]",
	    ['spritesheet'] = "Sprite [[Category:Sprites]]",
	    ['sprite sheet'] = "Sprite [[Category:Sprites]]",
	    
	    ['vector'] = "Vector graphic [[Category:Vector images]]",
	    ['svg'] = "Vector graphic [[Category:Vector images]]",
	    
	    ['video'] = "Video [[Category:Video files]]",
	    ['movie'] = "Video [[Category:Video files]]",
	    ['film'] = "Video [[Category:Video files]]",
	    ['short'] ="Video [[Category:Video files]]"
	 }
	 
	type = t[type] or "No type specified. [[Category:Unspecified files]]"
	
	table.insert(result, '<div class="panel" style="--panel-color: #c5c5c5"><div class="mb-2 panel-title">File information</div><table><tr><th class="p-1" style="background: #ff4242; color: #fff; border-radius: .5rem 0 0 0">Description</th><td class="p1">'.. description ..'</td></tr><tr><th class="p-1" style="background: #4292ff; color: #fff">Type</th><td class="p1" style="background: rgba(0,0,0,.12)">'.. type ..'</td></tr><tr><th class="p-1" style="background: #f5ff42; border-radius: 0 0 0 .5rem">Source/author</th><td class="p1">'.. source ..'</td></tr></table></div>')
	return table.concat(result, "")
end

return f