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

Содержимое удалено Содержимое добавлено
Отмена правки 106166, сделанной участником RLuts (обс.)
Строка 7:
function p.links(frame)
local lang = 'ru'
iflocal content = string.lower(mw.title.exists thengetCurrentTitle():getContent())
local hasWikiLink, hasCommLink
local content = string.lower(mw.title.getCurrentTitle():getContent())
local hasWikiLink, hasCommLink
if string.find(content, "%[%[wikipedia:.*]]") or string.find(content, "{{[Ff]ooter%s*|.*wikipedia%s*=.+}}") then
hasWikiLink = true
end
if string.find(content, "%[%[commons:.*]]") or string.find(content, "{{[Ff]ooter%s*|.*commons%s*=.+}}") then
hasComLink = true
end
entity = mw.wikibase.getEntity()
if not entity then
return nil
end
if (entity.sitelinks[lang .. "wiki"] and not hasWikiLink) then
wlinks = "[[wikipedia:" .. lang .. ":" .. entity.sitelinks[lang .. "wiki"].title .. "]]\n"
end
if (entity.claims and entity.claims.p373 and not hasComLink and wlinks) then
wlinks = wlinks .. "[[commons:Category:" .. entity.claims.p373[0].mainsnak.datavalue.value .. "]]"
elseif (entity.claims and entity.claims.p373 and not hasComLink and not wlinks) then
wlinks = "[[commons:Category:" .. entity.claims.p373[0].mainsnak.datavalue.value .. "]]"
end
return wlinks
else
return nil
end
end