今天是2024年6月29日 第26周 星期六

代人,时大变了。

我们生活在大地上,但我们的梦想超越天空。

“模块:NoteTA”的版本间的差异

来自Akarin
跳到导航 跳到搜索
(导入41个版本)
 
(未显示5个用户的22个中间版本)
第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 ) )

2022年7月11日 (一) 18:56的最新版本

50px 模块文档[查看] [编辑] [历史] [清除缓存]

本模块用于执行{{NoteTA}}模板,请到模板页阅读具体用法。

local z = {}
local WikitextLC = require( 'Module:WikitextLC' )

function Tcode( args )
	if args.T == nil or args.T == '' then
		return ''
	end
	local div = mw.html.create( 'div' )
		:attr( 'class', 'noteTA-title' )
		:attr( 'data-noteta-code', args.T )
		:wikitext( WikitextLC.title( args.T ) )
	if args.dt ~= nil and args.dt ~= '' then
		div:attr( 'data-noteta-desc', args.dt )
	end
	return tostring( div )
end

function group( name, frame )
	if name == nil or name == '' then
		return ''
	end
	local moduleTitle = mw.title.makeTitle( 'Module', 'CGroup/' .. name )
	if moduleTitle and moduleTitle.exists then
		local data = mw.loadData( 'Module:CGroup/' .. name )
		local pieces = {}
		if data.content then
			for i, v in ipairs( data.content ) do
				if v.type == 'item' and v.rule then
					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
	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

function Gcode( args, frame )
	local code = {}
	for i = 1, 30 do
		table.insert( code, group( args['G' .. i], frame ) )
	end
	code = table.concat( code )
	if code ~= '' then
		code = tostring( mw.html.create( 'div' )
				:attr( 'class', 'noteTA-group' )
				:wikitext( code ) )
		if args.G31 ~= nil then
			code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|G]]'
		end
	end
	return code
end

function local_( i, code, desc )
	if code == nil or code == '' then
		return ''
	end
	local div = mw.html.create( 'div' )
		-- :attr( 'id', 'noteTA-local-' .. i )
		:attr( 'data-noteta-code', code )
		:wikitext( WikitextLC.hidden( code ) )
	if desc ~= nil and desc ~= '' then
		div:attr( 'data-noteta-desc', desc )
	end
	return tostring( div )
end

function Lcode( args )
	local code = {}
	for i = 1, 30 do
		table.insert( code, local_( i, args[i], args['d' .. i] ) )
	end
	code = table.concat( code )
	if code ~= '' then
		code = tostring( mw.html.create( 'div' )
				:attr( 'class', 'noteTA-local' )
				:wikitext( code ) )
		if args[31] ~= nil then
			code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|L]]'
		end
	end
	return code
end

function z.main( frame )
	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 Gc = Gcode( args, frame )
	local Lc = Lcode( args )
	local code = Tc .. Gc .. Lc
	if code ~= '' then
		local hash = require( 'Module:Crc32lua' ).crc32( mw.dumpObject( args ) )
		code = frame:extensionTag{
			name = 'indicator',
			content = '[[File:Zh conversion icon m.svg|35px|本页使用了标题或全文手工转换|link=]]',
			args = { name = string.format( 'noteTA-%x', hash ) },
		} .. tostring( mw.html.create( 'div' )
				:attr( 'id', string.format( 'noteTA-%x', hash ) )
				:attr( 'class', 'noteTA' )
				:wikitext( code ) )
		if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
			code = code .. '[[Category:放置于模板的noteTA]]'
		end
	end
	return code
end

return z