Module:File: Difference between revisions

From Fanon Wiki
m (I'll let it go this way for the moment)
m (Let's see if it works)
Line 62: Line 62:
type = t[type] or "No type specified. [[Category:Unspecified 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 class="table-responsive"><tr><th class="p-2" style="background: #ff4242; color: #fff; border-radius: .5rem 0 0 0">Description</th><td class="p-2">'.. description ..'</td></tr><tr><th class="p-2" style="background: #4292ff; color: #fff">Type</th><td class="p-2" style="background: rgba(0,0,0,.12)">'.. type ..'</td></tr><tr><th class="p-2" style="background: #f5ff42; border-radius: 0 0 0 .5rem">Source/author</th><td class="p-2">'.. source ..'</td></tr></table></div>')
local license = mw.title.getCurrentTitle():getContent()
if license:find('data%-license="true"') then license = "[[Category:Files without licenses]]" else license = "" end
table.insert(result, '<div class="panel" style="--panel-color: #c5c5c5"><div class="mb-2 panel-title">File information</div><table class="table-responsive"><tr><th class="p-2" style="background: #ff4242; color: #fff; border-radius: .5rem 0 0 0">Description</th><td class="p-2">'.. description ..'</td></tr><tr><th class="p-2" style="background: #4292ff; color: #fff">Type</th><td class="p-2" style="background: rgba(0,0,0,.12)">'.. type ..'</td></tr><tr><th class="p-2" style="background: #f5ff42; border-radius: 0 0 0 .5rem">Source/author</th><td class="p-2">'.. source ..'</td></tr></table></div>'.. license ..'')
return table.concat(result, "")
return table.concat(result, "")
end
end


return f
return f

Revision as of 23:49, 22 May 2022

This module is intended to be used on File info pages. It eases the addition of types and categorizes it accordingly, with multiple fallbacks.

This module is intended to be used only on File pages.

How to use

{{#invoke:file|main
|description = <Description of the file>
|type = <Type of file>
|source = <Source, origin, and/or author>
}}

All parameters are technically mandatory, but if any is not set (or empty), the file will be categorized under specific maintenance categories, where files without description, type or source can be tracked more easily.

  • mainthe first parameter will always need to be main, otherwise the module invokation will fail.
  • description — a summary of what the file is about.
  • type — which type the file is about (it is not case sensitive):
    • Official artwork: art, artwork, official artwork, official art
    • Audio: audio, music, song, sound
    • Box art: boxart, box art
    • Chart or diagram: chart, diagram
    • Fan Art: fanart
    • Flag: flag
    • Logo: logo, logotype, logomark, wordmark
    • Map: map
    • Photograph: photograph, photography, photo
    • Scan: scan, magazine
    • Screenshot: screenshot, printscreen, prtscr
    • Sprite: sprite, spritesheet
    • User images: user, user image, user img
    • Vector: vector, svg
    • Video: video, movie, film, short
    • Wiki image: wiki
  • source — the source, origin, and/or author of the file.
File information
Description This file is about butterflies or something.
Type Scan
Source/author Danny DeVito

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]]",
	    ['official artwork'] = "Official artwork [[Category:Official artworks]]",
	    ['official art'] = "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'] = "Fan art [[Category:Fanarts]]",
	    ['fan art'] = "Fan art [[Category:Fanarts]]",
	    ['fanartwork'] = "Fan art [[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]]",
	    
	    ['wiki'] = "Wiki image [[Category:Wiki images]]"
	 }
	 
	type = t[type] or "No type specified. [[Category:Unspecified files]]"
	
	local license = mw.title.getCurrentTitle():getContent()
	if license:find('data%-license="true"') then license = "[[Category:Files without licenses]]" else license = "" end
	
	table.insert(result, '<div class="panel" style="--panel-color: #c5c5c5"><div class="mb-2 panel-title">File information</div><table class="table-responsive"><tr><th class="p-2" style="background: #ff4242; color: #fff; border-radius: .5rem 0 0 0">Description</th><td class="p-2">'.. description ..'</td></tr><tr><th class="p-2" style="background: #4292ff; color: #fff">Type</th><td class="p-2" style="background: rgba(0,0,0,.12)">'.. type ..'</td></tr><tr><th class="p-2" style="background: #f5ff42; border-radius: 0 0 0 .5rem">Source/author</th><td class="p-2">'.. source ..'</td></tr></table></div>'.. license ..'')
	return table.concat(result, "")
end

return f