Модуль:AIMeta: различия между версиями

Материал из Поле цифровой дидактики
Нет описания правки
Нет описания правки
 
Строка 13: Строка 13:


function p.render(frame)
function p.render(frame)
local parent = frame:getParent()
local args = frame.args
local args = parent and parent.args or frame.args
 
local aiSystem = trim(args['AI system used'] or args[1])
local aiSystem = trim(args['AI system used'] or args[1])
local prompt = trim(args['AI prompt'] or args[2])


local out = {}
if not aiSystem then
 
return ''
if aiSystem or prompt then
local setParts = {}
if aiSystem then
table.insert(setParts, 'AI system used=' .. aiSystem)
end
if prompt then
table.insert(setParts, 'AI prompt=' .. prompt)
end
table.insert(out, '{{#set:' .. table.concat(setParts, '|') .. '}}')
end
end


if aiSystem then
local root = mw.html.create('div')
local root = mw.html.create('div')
root
root
:css('clear', 'both')
:css('clear', 'both')
:css('margin-top', '1em')
:css('margin-top', '1em')
:css('padding', '0.45em 0.7em')
:css('padding', '0.45em 0.7em')
:css('font-size', '0.82em')
:css('font-size', '0.82em')
:css('line-height', '1.35')
:css('line-height', '1.35')
:css('color', '#777')
:css('color', '#777')
:css('background', '#fafafa')
:css('background', '#fafafa')
:css('border-top', '1px solid #e8e8e8')
:css('border-top', '1px solid #e8e8e8')


root:tag('span'):wikitext('AI: [[' .. aiSystem .. ']]')
root:tag('span'):wikitext('AI: [[' .. aiSystem .. ']]')
table.insert(out, tostring(root))
end


return table.concat(out)
return tostring(root)
end
end


return p
return p

Текущая версия от 10:33, 3 апреля 2026

Для документации этого модуля может быть создана страница Модуль:AIMeta/doc

local p = {}

local function trim(s)
	if s == nil then
		return nil
	end
	s = mw.text.trim(tostring(s))
	if s == '' then
		return nil
	end
	return s
end

function p.render(frame)
	local args = frame.args
	local aiSystem = trim(args['AI system used'] or args[1])

	if not aiSystem then
		return ''
	end

	local root = mw.html.create('div')
	root
		:css('clear', 'both')
		:css('margin-top', '1em')
		:css('padding', '0.45em 0.7em')
		:css('font-size', '0.82em')
		:css('line-height', '1.35')
		:css('color', '#777')
		:css('background', '#fafafa')
		:css('border-top', '1px solid #e8e8e8')

	root:tag('span'):wikitext('AI: [[' .. aiSystem .. ']]')

	return tostring(root)
end

return p