Content added Content deleted
mNo edit summary |
(autocheck if youtube or not) |
||
Line 4: | Line 4: | ||
local p = {} |
local p = {} |
||
local function makeVideo(frame |
local function makeVideo(frame, link) |
||
⚫ | |||
local video = mw.html.create('div') |
local video = mw.html.create('div') |
||
:css({ |
:css({ |
||
Line 12: | Line 13: | ||
}) |
}) |
||
if |
if link then |
||
local is_yt = string.find(link, '.*\.mp4') == nil |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
video:wikitext(frame:extensionTag{ |
video:wikitext(frame:extensionTag{ |
||
name = 'youtube', |
name = 'youtube', |
||
Line 21: | Line 22: | ||
content = link |
content = link |
||
}) |
}) |
||
⚫ | |||
⚫ | |||
end |
end |
||
else |
else |
||
Line 29: | Line 32: | ||
end |
end |
||
local function makeInfo(release_date, illustrator, animator) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local infoHeaderCss = { |
local infoHeaderCss = { |
||
['border-radius'] = '6px', |
['border-radius'] = '6px', |
||
Line 101: | Line 73: | ||
:wikitext('Lye') |
:wikitext('Lye') |
||
:done() |
:done() |
||
return info |
|||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
local video_type = args['type'] |
|||
local link = args['link'] |
|||
local release_date = args['date'] |
|||
local illustrator = args['illustrator'] |
|||
local animator = args['animator'] |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
}) |
|||
⚫ | |||
local info = makeInfo(release_date, illustrator, animator) |
|||
body:node(video) |
body:node(video) |
||
body:node(info) |
body:node(info) |
Revision as of 04:40, 30 October 2021
Documentation for this module may be created at Module:Song video/doc
local getArgs = require('Module:Arguments').getArgs
local utils = require('Module:Utilities')
local p = {}
local function makeVideo(frame, link)
local video = mw.html.create('div')
:css({
['flex'] = '1 1 320px',
['text-align'] = 'center',
['min-width'] = '320px'
})
if link then
local is_yt = string.find(link, '.*\.mp4') == nil
if is_yt then
video:wikitext(frame:extensionTag{
name = 'youtube',
args = { width = "320", height= "180" },
content = link
})
else
video:wikitext('[[File:' .. link .. '|320px]]')
end
else
video:wikitext(utils.editIfNil(nil))
end
return video
end
local function makeInfo(release_date, illustrator, animator)
local infoHeaderCss = {
['border-radius'] = '6px',
['background-color'] = '#a7ee75',
['padding'] = '5px 10px'
}
local infoCellCss = {
['padding'] = '5px'
}
local info = mw.html.create('div')
:css({
['display'] = 'grid',
['grid-template-columns'] = '1fr 1fr',
['grid-auto-rows'] = 'min-content',
['gap'] = '5px'
})
:tag('div')
:css(infoHeaderCss)
:wikitext('Release Date')
:done()
:tag('div')
:css(infoCellCss)
:wikitext('2021/08/18')
:done()
:tag('div')
:css(infoHeaderCss)
:wikitext('Illustrator')
:done()
:tag('div')
:css(infoCellCss)
:wikitext('Sidu')
:done()
:tag('div')
:css(infoHeaderCss)
:wikitext('Movie')
:done()
:tag('div')
:css(infoCellCss)
:wikitext('Lye')
:done()
return info
end
function p.main(frame)
local args = getArgs(frame)
local video_type = args['type']
local link = args['link']
local release_date = args['date']
local illustrator = args['illustrator']
local animator = args['animator']
local root = mw.html.create('div')
:css({
['display'] = 'inline-grid',
['margin-right'] = '10px',
['margin-bottom'] = '10px'
})
local header = root:tag('div')
:css({
['border-radius'] = '6px',
['background-color'] = '#FFA900',
['font-weight'] = 'bold',
['text-align'] = 'center',
['margin-bottom'] = '5px',
['padding'] = '5px'
})
:wikitext('Hard Preview')
:done()
local body = root:tag('div')
:css({
['display'] = 'flex',
['flex-wrap'] = 'wrap',
['gap'] = '5px'
})
local video = makeVideo(frame, link)
local info = makeInfo(release_date, illustrator, animator)
body:node(video)
body:node(info)
return tostring(root)
end
return p