Изменения
попытка оптимизации, не знаю, сработает ли
-- получение страницы, чтобы знать, существует ли она и является ли она перенаправлением
-- получение страницы, чтобы знать, существует ли она и является ли она перенаправлением
local ru_page = mw.title.new(title)
local ru_page = mw.title.new(title)
local leave = ru_page.exists and not leave_always and not (ru_page.isRedirect and leave_if_redirect)
local ru_page_exists = ru_page.exists -- потому что это expensive function
local ru_page_isRedirect = ru_page.isRedirect -- потому что это expensive function
local leave = ru_page_exists and not leave_always and not (ru_page_isRedirect and leave_if_redirect)
-- проверка правильности обработанных параметров
-- проверка правильности обработанных параметров
end
end
if ru_page.isRedirect and leave_if_redirect then -- TODO: почему не на все перенаправления?
if ru_page_isRedirect and leave_if_redirect then -- TODO: почему не на все перенаправления?
table.insert(categories_list, 'redirect')
table.insert(categories_list, 'redirect')
end
end
if leave then
if leave then
if mode == 5 and ru_page.isRedirect then
if mode == 5 and ru_page_isRedirect then
table.insert(categories_list, 'redirect')
table.insert(categories_list, 'redirect')
else
else
local main_text
local main_text
if leave or mode == 1 or mode == 2 or mode == 5 then
if leave or mode == 1 or mode == 2 or mode == 5 then
if lang == 'd' and not ru_page.exists then
if lang == 'd' and not ru_page_exists then
local moduleRedLink = require( 'Module:Wikidata/redLink' )
local moduleRedLink = require( 'Module:Wikidata/redLink' )
main_text = moduleRedLink.formatRedLink(title, text, iw_title)
main_text = moduleRedLink.formatRedLink(title, text, iw_title)
else
else
main_text = wikilink(title, text, nil, nil, nil, ru_page.isRedirect)
main_text = wikilink(title, text, nil, nil, nil, ru_page_isRedirect)
end
end
else
else
-- формирование второй части - языковой метки
-- формирование второй части - языковой метки
local post_text = ''
local post_text = ''
if not leave or mode == 2 or (mode == 5 and ru_page.isRedirect) then
if not leave or mode == 2 or (mode == 5 and ru_page_isRedirect) then
-- для шаблона "не переведено"
-- для шаблона "не переведено"
if mode == 1 then
if mode == 1 then
local exist_message_link
local exist_message_link
if mode == 5 then
if mode == 5 then
if ru_page.isRedirect then
if ru_page_isRedirect then
exist_message_link = 'Шаблон:' .. template_name .. '#Если существует перенаправление'
exist_message_link = 'Шаблон:' .. template_name .. '#Если существует перенаправление'
else
else
end
end
if mode == 5 and ru_page.isRedirect then
if mode == 5 and ru_page_isRedirect then
exist_message = string.format(
exist_message = string.format(
'<sup class="noprint" style="margin:0 0 0 1px;">%s</sup>',
'<sup class="noprint" style="margin:0 0 0 1px;">%s</sup>',