Interested Article - Shortcut
![](/images/004/936/4936669/1.jpg?rand=881069)
![](https://cdn.wafarin.com/avatars/6a9eefbaf125c6defe001275ae752476.gif)
- 2020-01-12
- 1
Реализация проверки для шаблона {{ shortcut }} .
local p = {}
function p.main (frame)
local title = mw.ustring.gsub(mw.ustring.gsub(mw.text.trim(frame.args[1]),"%[%[",""),"%]%]","")
local currentTitle = mw.title.getCurrentTitle().prefixedText
if title ~= '' then
local res
local page = mw.title.makeTitle('', title)
if not page or (page.prefixedText ~= currentTitle and (not page.redirectTarget or page.redirectTarget.prefixedText ~= currentTitle)) then
res = '[[' .. title .. ']][[Категория:Википедия:Страницы с неправильно заполненным шаблоном Shortcut]]'
else
res = '<span class="ts-shortcut-visible">' .. title .. '</span><span style="display:none;" class="ts-shortcut-invisible">[[' .. title .. '|<span style="color:black;>' .. title .. '</span>]]</span>'
end
return res -- .. ' => ' .. page.redirectTarget.prefixedText .. ' vs. ' .. currentTitle
end
end
return p
![](https://cdn.wafarin.com/avatars/6a9eefbaf125c6defe001275ae752476.gif)
- 2020-01-12
- 1