Module:GetShortDescription/sandbox: Difference between revisions

Content deleted Content added
sync
correction for redirect title conversion; will properly test later; so tired
Line 54:
end
 
local function getExplicitDescription( name, new_title )
local new_title = mw.title.new( name )
new_title = new_title.redirectTarget or new_title
local page_content = new_title:getContent()
if isEmpty( page_content ) then
Line 156 ⟶ 154:
objectify_alarm = args.objectify_alarm
report_redlinks = args.report_redlinks
local nameargs_name = args.name
if isEmpty( nameargs_name ) then return alarmingMessage( 'requires a page name (including namespace)' ) end
local new_title = mw.title.new( nameargs_name )
new_title = new_title.redirectTarget or new_title
local name = new_title.prefixedText
local fallback = args.fallback
if isSisterProjectLink( name ) then return fallback end
Line 172 ⟶ 175:
local result
if only == 'explicit' then result = getExplicitDescription( nameargs_name, new_title )
elseif only == 'wikidata' then result = getWikidataDescription( name, lang )
elseif prefer == 'explicit' then
result = getExplicitDescription( nameargs_name, new_title )
if isEmpty( result ) then result = getWikidataDescription( name, lang, true )
elseif isNone( result ) then
Line 184 ⟶ 187:
end
end
elseif prefer == 'wikidata' then result = getWikidataDescription( name, lang ) or getExplicitDescription( nameargs_name, new_title ) end
if isNone( result ) then result = nil end