Module:GetShortDescription/sandbox: Difference between revisions

Content deleted Content added
create sandbox from Special:PermaLink/1135215889
 
add some logs and a new entry point
Line 10:
 
local function getWikidataDescription( name, lang )
mw.log("Getting Wikidata description: " .. name)
local wikidata_id = mw.wikibase.getEntityIdForTitle( name )
if not wikidata_id then
Line 47 ⟶ 48:
 
local function getExplicitDescription( name )
mw.log("Getting explicit description: " .. name)
local short_description_template = getTransclusion( name .. '#', { only = 'templates', templates = '[Ss]hort description' } )
if not short_description_template then
return nil
end
mw.log(short_description_template)
local current_frame = mw.getCurrentFrame()
if not current_frame then
Line 56 ⟶ 59:
end
local preprocessed_short_description_template = current_frame:preprocess( short_description_template )
mw.log(preprocessed_short_description_template)
if not preprocessed_short_description_template then
return errorMessage( 'could not preprocess short_description_template' )
Line 62 ⟶ 66:
end
 
local function getShortDescriptionp._main( args )
local name = args.name
if not name then
Line 86 ⟶ 90:
result = getWikidataDescription( name, lang ) or getExplicitDescription( name )
end
return result or args.fallback or ''
end
 
Line 94 ⟶ 98:
return errorMessage( 'could not getArgs' )
end
return getShortDescriptionp._main( args ) or ''
end