Content added Content deleted
(added bg artist) |
mNo edit summary Tag: Reverted |
||
Line 75: | Line 75: | ||
end |
end |
||
local function makeDate(date) |
|||
⚫ | |||
⚫ | |||
['background-color'] = color |
|||
⚫ | |||
local date = mw.html.create('div') |
|||
⚫ | |||
if date then |
|||
local is_yt = string.find(link, '^' .. ('[a-zA-Z0-9_-]'):rep(11) .. '$') ~= nil |
|||
local is_file = string.find(link, '.+\.mp4') ~= nil |
|||
if is_yt then |
|||
⚫ | |||
:css(infoHeaderCss) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:addClass('id') |
|||
⚫ | |||
⚫ | |||
elseif is_file then |
|||
info:tag('div') |
|||
:css(infoHeaderCss) |
|||
:addClass('ih') |
|||
:wikitext('Date added') |
|||
:done() |
|||
:tag('div') |
|||
:addClass('id') |
|||
:wikitext(utils.editIfNil(release_date)) |
|||
:done() |
|||
end |
|||
else |
|||
date:wikitext(utils.editIfNil(nil)) |
|||
end |
|||
return date |
|||
end |
|||
⚫ | |||
local infoHeaderCss = { |
local infoHeaderCss = { |
||
['background-color'] = color |
['background-color'] = color |
||
Line 83: | Line 123: | ||
:addClass('info') |
:addClass('info') |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if illustration and illustration ~= '' then |
if illustration and illustration ~= '' then |
||
info:tag('div') |
info:tag('div') |
||
Line 161: | Line 191: | ||
local video_type = args['type'] |
local video_type = args['type'] |
||
local link = args['link'] |
local link = args['link'] |
||
local |
local date = args['date'] |
||
local illustration = args['illustration'] or args['illustrator'] |
local illustration = args['illustration'] or args['illustrator'] |
||
local animation = args['animation'] or args['animator'] |
local animation = args['animation'] or args['animator'] |
||
Line 179: | Line 209: | ||
:addClass('content') |
:addClass('content') |
||
:node(makeVideo(frame, link)) |
:node(makeVideo(frame, link)) |
||
:node(makeDate(date)) |
|||
:node(makeInfo( |
:node(makeInfo(illustration, animation, video, director, bg_artist)) |
||
return mw.getCurrentFrame():extensionTag{ |
return mw.getCurrentFrame():extensionTag{ |
Revision as of 10:30, 23 June 2022
Documentation for this module may be created at Module:Song video/doc
local getArgs = require('Module:Arguments').getArgs
local utils = require('Module:Utilities')
local constants = require('Module:Constants')
local p = {}
local color = nil
local colors = {
['easy preview'] = constants.get_difficulty_color('easy'),
['normal preview'] = constants.get_difficulty_color('normal'),
['hard preview'] = constants.get_difficulty_color('hard'),
['expert preview'] = constants.get_difficulty_color('expert'),
['master preview'] = constants.get_difficulty_color('master'),
['original mv'] = '#66dd11',
['game 2d mv'] = '#66dd11',
['full 2d mv'] = nil,
['3d mv'] = '#66dd11',
['april fool\'s mv'] = nil
}
local function makeHeader(video_type)
local headers = {
['easy preview'] = 'Easy Preview',
['normal preview'] = 'Normal Preview',
['hard preview'] = 'Hard Preview',
['expert preview'] = 'Expert Preview',
['master preview'] = 'Master Preview',
['original mv'] = 'Original MV',
['game 2d mv'] = '2D MV (game version)',
['full 2d mv'] = '2D MV (full version)',
['3d mv'] = '3D MV',
['april fool\'s mv'] = 'April Fool\'s MV'
}
local header = mw.html.create('div')
:addClass('header')
:css({
['background-color'] = color,
})
:wikitext(utils.editIfNil(
video_type,
function()
return utils.editIfNil(headers[video_type:lower()])
end
))
:done()
return header
end
local function makeVideo(frame, link)
local video = mw.html.create('div')
:addClass('video')
if link then
local is_yt = string.find(link, '^' .. ('[a-zA-Z0-9_-]'):rep(11) .. '$') ~= nil
local is_file = string.find(link, '.+\.mp4') ~= nil
if is_yt then
video:wikitext(frame:extensionTag{
name = 'youtube',
args = { width = "320", height= "180" },
content = link
})
elseif is_file then
video:wikitext('[[File:' .. link .. '|320px]]')
else
video:wikitext(utils.editIfNil(nil))
end
else
video:wikitext(utils.editIfNil(nil))
end
return video
end
local function makeDate(date)
local infoHeaderCss = {
['background-color'] = color
}
local date = mw.html.create('div')
:addClass('date')
if date then
local is_yt = string.find(link, '^' .. ('[a-zA-Z0-9_-]'):rep(11) .. '$') ~= nil
local is_file = string.find(link, '.+\.mp4') ~= nil
if is_yt then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Release date')
:done()
:tag('div')
:addClass('id')
:wikitext(utils.editIfNil(release_date))
:done()
elseif is_file then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Date added')
:done()
:tag('div')
:addClass('id')
:wikitext(utils.editIfNil(release_date))
:done()
end
else
date:wikitext(utils.editIfNil(nil))
end
return date
end
local function makeInfo(illustration, animation, video, director, bg_artist)
local infoHeaderCss = {
['background-color'] = color
}
local info = mw.html.create('div')
:addClass('info')
if illustration and illustration ~= '' then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Illustrator')
:done()
:tag('div')
:addClass('id')
:wikitext(illustration)
:done()
end
if animation and animation ~= '' then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Animator')
:done()
:tag('div')
:addClass('id')
:wikitext(animation)
:done()
end
if video and video ~= '' then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Video')
:done()
:tag('div')
:addClass('id')
:wikitext(video)
:done()
end
if director and director ~= '' then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Director')
:done()
:tag('div')
:addClass('id')
:wikitext(director)
:done()
end
if bg_artist and bg_artist ~= '' then
info:tag('div')
:css(infoHeaderCss)
:addClass('ih')
:wikitext('Background artist')
:done()
:tag('div')
:addClass('id')
:wikitext(bg_artist)
:done()
end
return info
end
function p.main(frame)
local args = getArgs(frame)
local video_type = args['type']
local link = args['link']
local date = args['date']
local illustration = args['illustration'] or args['illustrator']
local animation = args['animation'] or args['animator']
local video = args['video']
local director = args['director']
local bg_artist = args['background artist']
local root = mw.html.create('div')
:addClass('song-video')
color = colors[video_type] or color
local header = makeHeader(video_type)
root:node(header)
local body = root:tag('div')
:addClass('content')
:node(makeVideo(frame, link))
:node(makeDate(date))
:node(makeInfo(illustration, animation, video, director, bg_artist))
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles',
args = { src = 'Template:Song video/styles.css' }
} .. tostring(root)
end
return p