Module:YouTube Preview: Difference between revisions
Appearance
Cherrykano (talk | contribs) Created page with "local p = {} local seriesClasses = { ['sunshine'] = llss, ['nijigasaki'] = lln, ['superstar'] = llst, ['hasunosora'] = llll, ['sim'] = llsim, ['gny'] = gny, ['bluebird'] = llbb } local possibleRows = { 'Channel', 'Release', 'Illustration', 'Video', 'Production' } local function buildRow(title, content, style) local row = mw.html.create('div') :addClass('videobox-row') row :tag('div') :addClass('videobox-title') :addClass(style) :wikitext(titl..." |
Cherrykano (talk | contribs) mNo edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 38: | Line 38: | ||
function p.main(frame) | function p.main(frame) | ||
local style = 'cat-ll' | local style = 'cat-ll' | ||
if frame.args['Series'] then | if frame.args['Series'] and seriesClasses[frame.args['Series']] then | ||
style = 'cat-' .. frame.args['Series'] | style = 'cat-' .. seriesClasses[frame.args['Series']] | ||
end | end | ||
| Line 45: | Line 45: | ||
local header = root:tag('div') | local header = root:tag('div') | ||
:addClass(videobox-header) | :addClass('videobox-header') | ||
:addClass(style) | :addClass(style) | ||
:wikitext(frame.args['Title']) | :wikitext(frame.args['Title']) | ||
local video = root:tag('div') | local video = root:tag('div') | ||
:addClass(videobox-video) | :addClass('videobox-video') | ||
:wikitext(string.format('<youtube width="300">%s</youtube>', frame.args['URL'])) | :wikitext(string.format('<youtube width="300">%s</youtube>', frame.args['URL'])) | ||
Latest revision as of 21:46, 9 April 2026
Documentation for this module may be created at Module:YouTube Preview/doc
local p = {}
local seriesClasses = {
['sunshine'] = llss,
['nijigasaki'] = lln,
['superstar'] = llst,
['hasunosora'] = llll,
['sim'] = llsim,
['gny'] = gny,
['bluebird'] = llbb
}
local possibleRows = {
'Channel',
'Release',
'Illustration',
'Video',
'Production'
}
local function buildRow(title, content, style)
local row = mw.html.create('div')
:addClass('videobox-row')
row
:tag('div')
:addClass('videobox-title')
:addClass(style)
:wikitext(title)
row
:tag('div')
:wikitext(content)
return row
end
function p.main(frame)
local style = 'cat-ll'
if frame.args['Series'] and seriesClasses[frame.args['Series']] then
style = 'cat-' .. seriesClasses[frame.args['Series']]
end
local root = mw.html.create('div')
local header = root:tag('div')
:addClass('videobox-header')
:addClass(style)
:wikitext(frame.args['Title'])
local video = root:tag('div')
:addClass('videobox-video')
:wikitext(string.format('<youtube width="300">%s</youtube>', frame.args['URL']))
for v in pairs(possibleRows) do
if frame.args[v] then
root:node(buildRow(v, frame.args[v], style))
end
end
return frame:extensionTag{
name = 'templatestyles',
args = { src = 'Module:YouTube Preview/styles.css' }
} .. tostring(root)
end
return p