메뉴 여닫기
436
320
90
23K
이터널 리턴 이스포츠 위키
환경 설정 메뉴 여닫기
개인 메뉴 여닫기
로그인하지 않음
지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

이 모듈에 대한 설명문서는 모듈:Infobox/Tournament/설명문서에서 만들 수 있습니다

-- Module:Infobox/Tournament
-- 대회 인포박스 + SEO 메타태그 통합 모듈
-- 사용법: {{#invoke:Infobox/Tournament|main|series=Masters|season=10|phase=1}}

local p = {}
local InfoboxNeue = require( 'Module:InfoboxNeue' )

--- 영→한 매핑
local translationMap = {
	['Eternal Return'] = '이터널리턴',
	['Masters'] = '마스터즈',
	['Invitational'] = '인비테이셔널',
	['Open'] = '오픈',
	['Championship'] = '챔피언십',
	['Final'] = '파이널',
	['Qualifier'] = '예선',
	['Playoffs'] = '플레이오프',
	['Group Stage'] = '조별리그',
	['Season'] = '시즌',
	['Phase'] = '페이즈',
}

--- 약칭 매핑
local abbrMap = {
	['Masters'] = 'ERM',
	['Open'] = 'ERO',
	['Invitational'] = 'ERI',
}

local function translateSeries( name )
	if not name or name == '' then return '' end
	local result = name
	for en, ko in pairs( translationMap ) do
		result = mw.ustring.gsub( result, en, ko )
	end
	return mw.text.trim( result )
end

local function getArg( args, ... )
	for _, key in ipairs( { ... } ) do
		local val = args[key]
		if val and val ~= '' then
			return mw.text.trim( val )
		end
	end
	return nil
end

function p.main( frame )
	local args = frame:getParent().args

	-- 파라미터 추출
	local series    = getArg( args, 'series', '시리즈' )
	local season    = getArg( args, 'season', '시즌' )
	local phase     = getArg( args, 'phase', '페이즈' )
	local stage     = getArg( args, 'stage', '스테이지' )
	local startDate = getArg( args, 'start', '시작일' )
	local endDate   = getArg( args, 'end', '종료일' )
	local prizepool = getArg( args, 'prizepool', '상금' )
	local teams     = getArg( args, 'teams', '참가팀수' )
	local venue     = getArg( args, 'venue', '장소' )
	local image     = getArg( args, 'image', '이미지' )
	local organizer = getArg( args, 'organizer', '주최' )

	-- 한국어 시리즈명
	local seriesKo = series and translateSeries( series ) or ''
	local seriesEn = series or ''

	-- 대회 풀네임 생성
	local titleParts = { '이터널리턴' }
	if seriesKo ~= '' then table.insert( titleParts, seriesKo ) end
	if season then table.insert( titleParts, '시즌' .. season ) end
	if phase then table.insert( titleParts, '페이즈' .. phase ) end
	if stage then table.insert( titleParts, stage ) end
	local fullTitle = table.concat( titleParts, ' ' )

	-- ===== 인포박스 렌더링 =====
	local infobox = InfoboxNeue:new()

	if image then
		infobox:renderImage( image )
	end

	-- 헤더
	infobox:renderHeader( {
		title = fullTitle,
		subtitle = seriesEn ~= seriesKo and seriesEn or nil,
	} )

	-- 대회 정보 섹션
	local infoItems = {}

	table.insert( infoItems, infobox:renderItem( '주최', organizer ) )
	table.insert( infoItems, infobox:renderItem( '장소', venue ) )

	-- 일정
	local dateStr
	if startDate and endDate then
		dateStr = startDate .. ' ~ ' .. endDate
	elseif startDate then
		dateStr = startDate
	end
	table.insert( infoItems, infobox:renderItem( {
		label = '일정',
		data = dateStr,
		colspan = 2,
	} ) )

	table.insert( infoItems, infobox:renderItem( '상금', prizepool ) )
	table.insert( infoItems, infobox:renderItem( '참가팀', teams ) )

	infobox:renderSection( {
		title = '대회 정보',
		col = 2,
		content = infoItems,
	} )

	local infoboxHtml = infobox:renderInfobox( nil, fullTitle )

	-- ===== SEO 설정 =====
	local kwItems = { '이터널리턴', 'Eternal Return' }
	if seriesKo ~= '' then table.insert( kwItems, seriesKo ) end
	if seriesEn ~= '' and seriesEn ~= seriesKo then
		table.insert( kwItems, seriesEn )
	end
	table.insert( kwItems, '대회' )
	if season then
		table.insert( kwItems, '시즌' .. season )
		table.insert( kwItems, 'S' .. season )
	end
	if phase then
		table.insert( kwItems, '페이즈' .. phase )
		table.insert( kwItems, 'P' .. phase )
	end
	if stage then table.insert( kwItems, stage ) end
	table.insert( kwItems, '이스포츠' )

	-- 약칭 (ERM S10P1 등)
	local abbr = abbrMap[seriesEn]
	if abbr and season then
		local abbrFull = abbr .. ' S' .. season
		if phase then abbrFull = abbrFull .. 'P' .. phase end
		table.insert( kwItems, abbr )
		table.insert( kwItems, abbrFull )
	end

	-- 중복 제거
	local seen = {}
	local keywords = {}
	for _, item in ipairs( kwItems ) do
		if item ~= '' and not seen[item] then
			seen[item] = true
			table.insert( keywords, item )
		end
	end

	local desc = fullTitle .. ' 대회 정보, 일정, 결과, 순위, 통계.'

	mw.ext.seo.set( {
		title = fullTitle,
		title_mode = 'replace',
		keywords = table.concat( keywords, ', ' ),
		description = desc,
		locale = 'ko_KR',
		type = 'article',
	} )

	return infoboxHtml
end

return p