Skip to content

Commit

Permalink
Merge branch 'main' into Kanopedia-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz authored Oct 10, 2024
2 parents 7d7d8c2 + fa16b43 commit 4b44613
Show file tree
Hide file tree
Showing 458 changed files with 9,711 additions and 16,277 deletions.
111 changes: 111 additions & 0 deletions components/auto_inline_icon/commons/auto_inline_icon.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
-- @Liquipedia
-- wiki=commons
-- page=Module:AutoInlineIcon
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute

local Class = require('Module:Class')
local Lua = require('Module:Lua')
local InlineIconAndText = require('Module:Widget/InlineIconAndText')
local ManualData = Lua.requireIfExists('Module:InlineIcon/ManualData', {loadData = true})

local AutoInlineIcon = {}

---@param _ table
---@param category string
---@param lookup string
---@param extraInfo string?
---@return string
function AutoInlineIcon.display(_, category, lookup, extraInfo)
assert(category, 'Category parameter is required.')
assert(lookup, 'Lookup parameter is required.')

local data = AutoInlineIcon._getDataRetrevalFunction(category)(lookup)
assert(data, 'Data not found.')

local icon = AutoInlineIcon._iconCreator(data)

if not data.text then
return tostring(icon)
end

return tostring(InlineIconAndText{
icon = icon,
text = data.text,
link = data.link,
})
end

---@param category string
---@return fun(name: string): table
function AutoInlineIcon._getDataRetrevalFunction(category)
local categoryMapper = {
H = AutoInlineIcon._queryHeroData,
A = function(name)
error('Abilities not yet implemented.')
end,
I = AutoInlineIcon._queryItemData,
M = function(name)
return ManualData[name]
end,
}
assert(categoryMapper[category], 'Invalid category parameter.')
return categoryMapper[category]
end

---@param data table
---@return IconWidget
function AutoInlineIcon._iconCreator(data)
if data.iconType == 'image' then
local IconImage = require('Module:Widget/Icon/Image')
return IconImage{
imageLight = data.iconLight,
imageDark = data.iconDark,
link = data.link,
}
elseif data.iconType == 'fa' then
local IconFa = require('Module:Widget/Icon/Fontawesome')
return IconFa{
iconName = data.icon,
link = data.link,
}
end
error('Invalid iconType.')
end

---@param name string
---@return table
function AutoInlineIcon._queryItemData(name)
local data = mw.ext.LiquipediaDB.lpdb('datapoint', {
conditions = '[[type::item]] AND [[name::'.. name ..']]',
})[1]
assert(data, 'Item not found.')

return {
iconType = 'image',
link = data.pagename,
text = data.name,
iconLight = data.image,
iconDark = data.imagedark,
}
end

---@param name string
---@return table
function AutoInlineIcon._queryHeroData(name)
local data = mw.ext.LiquipediaDB.lpdb('datapoint', {
conditions = '[[type::character]] AND [[name::'.. name ..']]',
})[1]
assert(data, 'Hero not found.')

return {
iconType = 'image',
link = data.pagename,
text = data.name,
iconLight = data.extradata.icon or data.image,
iconDark = data.extradata.icon or data.imagedark,
}
end

return Class.export(AutoInlineIcon)
2 changes: 1 addition & 1 deletion components/character_icon/commons/character_icon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function CharacterIcon.Icon(args)

return CharacterIcon._makeImage(iconInfo, args.size, args.class)
.. (Logic.readBool(args.addTextLink)
and (' ' .. Page.makeInternalLink(args.character, iconInfo.link or args.character))
and (' ' .. Page.makeInternalLink(iconInfo.display or args.character, iconInfo.link or args.character))
or '')
end

Expand Down
1 change: 1 addition & 0 deletions components/external_media_links/external_media_link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ function ExternalMediaLink.wrapper(args)
language = args.language,
translation = args.translation,
translator = args.translator,
trans_title = args.trans_title,
}

if args.authors then
Expand Down
2 changes: 1 addition & 1 deletion components/external_media_links/external_media_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function MediaList._row(item, args)
row:node(MediaList._displayTitle(item))

if String.isNotEmpty(item.translatedtitle) then
row:wikitext(mw.text.nowiki('[') .. '[' .. item.translatedtitle .. ']' .. mw.text.nowiki(']'))
row:wikitext(' ' .. mw.text.nowiki('[') .. item.translatedtitle .. mw.text.nowiki(']'))
end

local authors = {}
Expand Down
59 changes: 39 additions & 20 deletions components/faction/wikis/ageofempires/faction_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -621,108 +621,113 @@ local factionPropsAoM = {
pageName = 'Egyptians' .. AOM_SUFFIX,
faction = 'egyptians',
},
norse = {
freyr = {
index = 5,
name = 'Freyr',
faction = 'freyr',
},
norse = {
index = 6,
name = 'Norse',
pageName = 'Norse' .. AOM_SUFFIX,
faction = 'norse',
},
fuxi = {
index = 6,
index = 7,
name = 'Fu Xi',
faction = 'fuxi',
},
gaia = {
index = 7,
index = 8,
name = 'Gaia',
pageName = 'Gaia',
faction = 'gaia',
},
hades = {
index = 8,
index = 9,
name = 'Hades',
faction = 'hades',
},
isis = {
index = 9,
index = 10,
name = 'Isis',
faction = 'isis',
},
kronos = {
index = 10,
index = 11,
name = 'Kronos',
faction = 'kronos',
},
loki = {
index = 11,
index = 12,
name = 'Loki',
faction = 'loki',
},
nuwa = {
index = 12,
index = 13,
name = 'Nü Wa',
faction = 'nuwa',
},
odin = {
index = 13,
index = 14,
name = 'Odin',
faction = 'odin',
},
oranos = {
index = 14,
index = 15,
name = 'Oranos',
faction = 'oranos',
},
poseidon = {
index = 15,
index = 16,
name = 'Poseidon',
pageName = 'Poseidon (god)',
faction = 'poseidon',
},
ra = {
index = 16,
index = 17,
name = 'Ra',
pageName = 'Ra (god)',
faction = 'ra',
},
set = {
index = 17,
index = 18,
name = 'Set',
faction = 'set',
},
shennong = {
index = 18,
index = 19,
name = 'Shennong',
faction = 'shennong',
},
thor = {
index = 19,
index = 20,
name = 'Thor',
faction = 'thor',
},
zeus = {
index = 20,
index = 21,
name = 'Zeus',
faction = 'zeus',
},
quetzalcoatl = {
index = 21,
index = 22,
name = 'Quetzalcoatl',
faction = 'quetzalcoatl',
},
huitzilopochtli = {
index = 22,
index = 23,
name = 'Huitzilopochtli',
faction = 'huitzilopochtli',
},
tezcatlipoca = {
index = 23,
index = 24,
name = 'Tezcatlipoca',
faction = 'tezcatlipoca',
},

unknown = {
index = 24,
index = 25,
name = 'Unknown',
faction = 'unknown',
},
Expand Down Expand Up @@ -935,9 +940,23 @@ return {
atl = 'atlanteans',
chi = 'chinese',
egy = 'egyptians',
fre = 'freyr',
fux = 'fuxi',
gai = 'gaia',
gre = 'greeks',
had = 'hades',
isi = 'isis',
kro = 'kronos',
lok = 'loki',
nor = 'norse',
['nu wa'] = 'nuwa',
nuw = 'nuwa',
odi = 'odin',
ora = 'oranos',
pos = 'poseidon',
she = 'shennong',
tho = 'thor',
zeu = 'zeus',
que = 'quetzalcoatl',
hui = 'huitzilopochtli',
tez = 'tezcatlipoca',
Expand Down
35 changes: 19 additions & 16 deletions components/faction/wikis/ageofempires/faction_icon_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -345,61 +345,64 @@ local byFactionAoM = {
icon = 'File:Chinese AoM icon.png',
},
greeks = {
icon = 'File:Greek AoM icon.png',
icon = 'File:Greek AoM R icon.png',
},
atlanteans = {
icon = 'File:Atlantean AoM icon.png',
icon = 'File:Atlantean AoM R icon.png',
},
egyptians = {
icon = 'File:Egyptian AoM icon.png',
icon = 'File:Egyptian AoM R icon.png',
},
norse = {
icon = 'File:Norse AoM icon.png',
icon = 'File:Norse AoM R icon.png',
},
fuxi = {
icon = 'File:Fu Xi AoM icon.png',
},
freyr = {
icon = 'File:Freyr AoM R icon.png',
},
gaia = {
icon = 'File:Gaia AoM icon.png',
icon = 'File:Gaia AoM R icon.png',
},
hades = {
icon = 'File:Hades AoM icon.png',
icon = 'File:Hades AoM R icon.png',
},
isis = {
icon = 'File:Isis AoM icon.png',
icon = 'File:Isis AoM R icon.png',
},
kronos = {
icon = 'File:Kronos AoM icon.png',
icon = 'File:Kronos AoM R icon.png',
},
loki = {
icon = 'File:Loki AoM icon.png',
icon = 'File:Loki AoM R icon.png',
},
nuwa = {
icon = 'File:Nu Wa AoM icon.png',
},
odin = {
icon = 'File:Odin AoM icon.png',
icon = 'File:Odin AoM R icon.png',
},
oranos = {
icon = 'File:Oranos AoM icon.png',
icon = 'File:Oranos AoM R icon.png',
},
poseidon = {
icon = 'File:Poseidon AoM icon.png',
icon = 'File:Poseidon AoM R icon.png',
},
ra = {
icon = 'File:Ra AoM icon.png',
icon = 'File:Ra AoM R icon.png',
},
set = {
icon = 'File:Set AoM icon.png',
icon = 'File:Set AoM R icon.png',
},
shennong = {
icon = 'File:Shennong AoM icon.png',
},
thor = {
icon = 'File:Thor AoM icon.png',
icon = 'File:Thor AoM R icon.png',
},
zeus = {
icon = 'File:Zeus AoM icon.png',
icon = 'File:Zeus AoM R icon.png',
},
quetzalcoatl = {
icon = 'File:Quetzalcoatl AoM icon.png',
Expand Down
Loading

0 comments on commit 4b44613

Please sign in to comment.