Module:GetShortDescription/sandbox: Difference between revisions

Content deleted Content added
lua is -_-
fix returning empty explicits + identify fellback
Line 23:
end
 
local function getWikidataDescription( title, args, fallback )
local wikidata_id = mw.wikibase.getEntityIdForTitle( title )
if isEmpty( wikidata_id ) then return nil end
Line 41:
}
end
result.fellback = fallback
return result
end
 
local function getShortDescription( title_table, args_name, fallback )
local page_content = title_table:getContent()
-- Assume no content is a nonexistent title because it's cheaper than testing if it exists.
Line 106 ⟶ 107:
-- Let previewWarning() work out if these numbers are bad.
previewWarning( args_name, quantity_of_things )
if #short_descriptions >= 1 then
local return { explicitshort_description = short_descriptions[ #short_descriptions ].description } end
if notEmpty( short_description ) then return { explicit = short_description, fellback = fallback } end
end
return nil
end
Line 166 ⟶ 170:
if short_description.redlink or ( not isNone( short_description.explicit ) or args.none_is_valid ) then return short_description end
end
return getWikidataDescription( title, args, true ) end
if prefer == 'wikidata' then return getWikidataDescription( title, args ) or getShortDescription( title_table, args_name, true ) end
return { alarm = 'accepts either "explicit" or "wikidata" as the value of |prefer=' }
end
Line 196 ⟶ 200:
--[[ DON'T FORGET THIS ]]
--local result = main( args )
--mw.logObject( result )
return main( args )result
--[[ DON'T FORGET THIS ]]