打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:SongPlayer:修订间差异

来自Rizline中文维基
第1行: 第1行:
local p = {}
local p = {}
local getArgs = require('Module:Arguments').getArgs


function p.player(frame)
function p.player(frame)
     local args = frame:getParent().args
     local args = getArgs(frame)
   
     local title = args.title
     local title = args.title
     local artist = args.artist
     local artist = args.artist
第12行: 第14行:
     local c4 = args.color4 or '#D5F3FE'
     local c4 = args.color4 or '#D5F3FE'


     if not title or title == '' or not imageName or imageName == '' then
     if not title or not imageName then
         return ''
         return ''
     end
     end
第18行: 第20行:
     local sanitizedTitle = title:gsub(' ', '_'):gsub('[\\/:*?"<>|]', '-')
     local sanitizedTitle = title:gsub(' ', '_'):gsub('[\\/:*?"<>|]', '-')
     local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH')
     local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH')
      
     local songUrl = 'https://pan.rizwiki.cn/d/song/' .. encodedTitle .. '.mp3'
 
     local rawImagePath = frame:preprocess('{{filepath:' .. imageName .. '}}')
     local rawImagePath = frame:preprocess('{{filepath:' .. imageName .. '}}')
     local imagePath = rawImagePath:gsub('^https?:', '')
     local imagePath = rawImagePath:gsub('^https?:', '')


    local songUrl = 'https://pan.rizwiki.cn/d/song/' .. encodedTitle .. '.mp3'
    -- 构建主容器
     local html = mw.html.create('div')
     local html = mw.html.create('div')
         :attr('id', 'riz-player')
         :attr('id', 'riz-player')
第41行: 第41行:


     local info = html:tag('div'):addClass('rp-info')
     local info = html:tag('div'):addClass('rp-info')
   
     info:tag('div'):addClass('rp-title'):wikitext(title)
     info:tag('div'):addClass('rp-title'):wikitext(title)
     info:tag('div'):addClass('rp-artist'):wikitext(artist or '')
     info:tag('div'):addClass('rp-artist'):wikitext(artist or '')