第8行: |
第8行: |
| local div = mw.html.create( 'div' ) | | local div = mw.html.create( 'div' ) |
| :attr( 'class', 'noteTA-title' ) | | :attr( 'class', 'noteTA-title' ) |
− | :attr( 'data-noteta-code', mw.uri.encode( args.T ) ) | + | :attr( 'data-noteta-code', args.T ) |
| :wikitext( WikitextLC.title( args.T ) ) | | :wikitext( WikitextLC.title( args.T ) ) |
| if args.dt ~= nil and args.dt ~= '' then | | if args.dt ~= nil and args.dt ~= '' then |
− | div:attr( 'data-noteta-desc', mw.uri.encode( args.dt ) ) | + | div:attr( 'data-noteta-desc', args.dt ) |
| end | | end |
| return tostring( div ) | | return tostring( div ) |
第20行: |
第20行: |
| return '' | | return '' |
| end | | end |
− | local title = mw.title.makeTitle( 'Template', 'CGroup/' .. name ) | + | local moduleTitle = mw.title.makeTitle( 'Module', 'CGroup/' .. name ) |
− | if title and title.exists then | + | if moduleTitle and moduleTitle.exists then |
− | return frame:expandTemplate{ title = title } | + | local data = mw.loadData( 'Module:CGroup/' .. name ) |
− | else
| + | local pieces = {} |
− | return tostring( mw.html.create( 'div' )
| + | if data.content then |
− | -- :attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
| + | for i, v in ipairs( data.content ) do |
− | :attr( 'class', 'noteTA-missing' ) | + | if v.type == 'item' and v.rule then |
− | :attr( 'data-noteta-group', name ) ) | + | table.insert( pieces, '-{H|' .. v.rule .. '}-' ) |
| + | end |
| + | end |
| + | return tostring( mw.html.create( 'div' ) |
| + | :attr( 'data-noteta-group-source', 'module' ) |
| + | :attr( 'data-noteta-group', data.name or name ) |
| + | :wikitext( table.concat( pieces ) ) ) |
| + | end |
| + | end |
| + | local templateTitle = mw.title.makeTitle( 'Template', 'CGroup/' .. name ) |
| + | if templateTitle and templateTitle.exists then |
| + | return frame:expandTemplate{ title = templateTitle } |
| end | | end |
| + | return tostring( mw.html.create( 'div' ) |
| + | -- :attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) ) |
| + | :attr( 'data-noteta-group-source', 'none' ) |
| + | :attr( 'data-noteta-group', name ) ) |
| end | | end |
| | | |
第54行: |
第69行: |
| local div = mw.html.create( 'div' ) | | local div = mw.html.create( 'div' ) |
| -- :attr( 'id', 'noteTA-local-' .. i ) | | -- :attr( 'id', 'noteTA-local-' .. i ) |
− | :attr( 'data-noteta-code', mw.uri.encode( code ) ) | + | :attr( 'data-noteta-code', code ) |
| :wikitext( WikitextLC.hidden( code ) ) | | :wikitext( WikitextLC.hidden( code ) ) |
| if desc ~= nil and desc ~= '' then | | if desc ~= nil and desc ~= '' then |
− | div:attr( 'data-noteta-desc', mw.uri.encode( desc ) ) | + | div:attr( 'data-noteta-desc', desc ) |
| end | | end |
| return tostring( div ) | | return tostring( div ) |
第80行: |
第95行: |
| | | |
| function z.main( frame ) | | function z.main( frame ) |
− | local args = frame:getParent().args | + | local args |
| + | if frame == mw.getCurrentFrame() then |
| + | -- Being called from {{noteTA}} |
| + | args = frame:getParent().args |
| + | else |
| + | -- Being called from another module |
| + | args = frame |
| + | frame = mw.getCurrentFrame() |
| + | end |
| local Tc = Tcode( args ) | | local Tc = Tcode( args ) |
| local Gc = Gcode( args, frame ) | | local Gc = Gcode( args, frame ) |
第86行: |
第109行: |
| local code = Tc .. Gc .. Lc | | local code = Tc .. Gc .. Lc |
| if code ~= '' then | | if code ~= '' then |
− | local hash = code:len() | + | local hash = require( 'Module:Crc32lua' ).crc32( mw.dumpObject( args ) ) |
− | code = frame:expandTemplate{ | + | code = frame:extensionTag{ |
− | title = 'topicon', | + | name = 'indicator', |
− | args = { | + | content = '[[File:Zh conversion icon m.svg|35px| 本页使用了标题或全文手工转换|link=]]', |
− | id = 'noteTA-topicon-' .. hash,
| + | args = { name = string.format( 'noteTA-%x', hash ) }, |
− | class = 'noteTA-topicon',
| |
− | image = 'Zh conversion icon m.svg',
| |
− | alt = ' 本页使用了标题或全文手工转换',
| |
− | title = '本页使用了标题或全文手工转换',
| |
− | link = '',
| |
− | size = '35px',
| |
− | },
| |
| } .. tostring( mw.html.create( 'div' ) | | } .. tostring( mw.html.create( 'div' ) |
− | :attr( 'id', 'noteTA-' .. hash ) | + | :attr( 'id', string.format( 'noteTA-%x', hash ) ) |
| :attr( 'class', 'noteTA' ) | | :attr( 'class', 'noteTA' ) |
| :wikitext( code ) ) | | :wikitext( code ) ) |