익명
×
새 문서 만들기
여기에 문서 제목을 쓰세요:
We currently have 900 articles on 루리위키. Type your article name above or click on one of the titles below and start writing!



900Articles

모듈:푸른 저편의 포리듬/ 캐릭터 프로필: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
1번째 줄: 1번째 줄:
local p = {}
local p = {}
local mw = mw
local tt = mw.text


-- 안전 문자열 트림
function p.main(frame)
local function trim(s)
    local args = frame:getParent().args
     if not s then return '' end
 
     return tt.trim(tostring(s))
    local color = args["색상"] or "#444"
end
 
    local html = mw.html.create("div")
    html:addClass("profile-card")
     html:css({
        ["border"] = "2px solid "..color,
        ["border-radius"] = "10px",
        ["padding"] = "12px",
        ["width"] = "100%",
        ["box-sizing"] = "border-box",
        ["background"] = "#fafafa",
        ["font-family"] = "'Noto Sans KR', sans-serif"
     })
 
    -- 이름 영역
    local nameBlock = mw.html.create("div")
    nameBlock:css({["text-align"] = "center", ["margin-bottom"] = "10px"})
 
    nameBlock:tag("div"):css({["font-size"] = "20px", ["font-weight"] = "bold", ["color"] = color})
        :wikitext(args["이름"] or "")
 
    nameBlock:tag("div"):css({["font-size"] = "13px", ["color"] = "#555"})
        :wikitext((args["이름_일어"] or "").." / "..(args["이름_영어"] or ""))


-- 시그니처 기술 수집 (시그니처기술1..10)
     html:node(nameBlock)
local function gather_techs(args)
     local techs = {}
    for i = 1, 10 do
        local k = '시그니처기술' .. i
        if args[k] and args[k] ~= '' then
            table.insert(techs, trim(args[k]))
        end
    end
    return techs
end


-- 이미지 블록 (기능을 표준 위키텍스트로 반환)
    -- 이미지 +
local function build_image_block(args)
     local images = {}
     local images = {}
     if args['이미지_VN'] and args['이미지_VN'] ~= '' then
     if args["이미지_VN"] and args["이미지_VN"]~="" then
         table.insert(images, { title = "VN", file = trim(args['이미지_VN']) })
         table.insert(images,'|비주얼 노벨=[[File:'..args["이미지_VN"]..'|200px]]')
     end
     end
     if args['이미지_애니'] and args['이미지_애니'] ~= '' then
     if args["이미지_애니"] and args["이미지_애니"]~="" then
         table.insert(images, { title = "애니", file = trim(args['이미지_애니']) })
         table.insert(images,'|애니메이션=[[File:'..args["이미지_애니"]..'|200px]]')
     end
     end
    -- 추가 이미지는 생략 (탭 충돌 방지)
     if args["이미지_추가"] and args["이미지_추가"]~="" then
   
         table.insert(images,'|추가='..args["이미지_추가"])
     if #images == 0 then
        return '[[파일:NoImage.png|250px|center]]'
    elseif #images == 1 then
         return string.format('[[파일:%s|250px|center]]', mw.text.encode(images[1].file))
    else
        -- 탭 대신 간단한 이미지 갤러리 또는 첫 번째 이미지 사용 (가장 안전)
        return string.format('[[파일:%s|250px|center]]<div style="font-size:80%%;text-align:center;">(VN/애니 버전 전환은 갤러리/탭 구현 필요)</div>', mw.text.encode(images[1].file))
     end
     end
end


-- 이름 블록 (표 셀용으로 간단히 변환)
     if #images > 0 then
local function build_name_block(args)
        html:wikitext('<div style="text-align:center; margin:10px 0;"><tabber>'..table.concat(images,"\n")..'</tabber></div>')
     local kr = trim(args['이름'] or '')
    end
    local jp = trim(args['이름_일어'] or '')
 
    local en = trim(args['이름_영어'] or '')
     -- 테이블 생성 함수
    local parts = {}
    local function addRow(tbl, label, value)
    if kr ~= '' then table.insert(parts, string.format('<strong>%s</strong>', mw.text.escape(kr))) end
         if value and value ~= "" then
     if jp ~= '' or en ~= '' then
             tbl:tag("tr")
        local second = ''
                :tag("th"):wikitext(label).done()
         if jp ~= '' and en ~= '' then
                :tag("td"):wikitext(value)
             second = mw.text.escape(jp) .. ' / ' .. mw.text.escape(en)
        else
            second = mw.text.escape((jp ~= '' and jp) or en)
         end
         end
        table.insert(parts, string.format('<br/><span style="font-size:90%%;">(%s)</span>', second))
     end
     end
    return table.concat(parts, '\n')
end


-- 라벨+값 행 생성 (표의 행)
    -- ▶ 기본정보 영역
local function table_row(label, value, is_header)
    local infoTable = mw.html.create("table")
     if not value or value == '' then return '' end
     infoTable:css({
    local tag = is_header and '!' or '|'
        ["width"]="100%",
    return string.format('|- \n|%s style="width: 30%%; background-color: #f2f2f2; padding: 5px;" | %s \n|%s style="padding: 5px;" | %s', tag, mw.text.escape(label), tag, mw.text.escape(value))
        ["border-collapse"]="collapse",
end
        ["font-size"]="13px"
    })


-- 나이 출력 규칙 (표의 행)
     addRow(infoTable,"성별",args["성별"])
local function build_age_row(args)
     addRow(infoTable,"나이", (args["나이_VN"]~="" and "VN: "..args["나이_VN"] or "").." / "..(args["나이_애니"]~="" and "애니: "..args["나이_애니"] or ""))  
     local nv = trim(args['나이_VN'])
     addRow(infoTable,"생일",args["생일"])
     local na = trim(args['나이_애니'])
    addRow(infoTable,"신장",args["신장"])
    if nv ~= '' and na ~= '' then
     addRow(infoTable,"체중",args["체중"])
        return table_row('나이', 'VN ' .. nv .. ' / 애니 ' .. na)
    addRow(infoTable,"머리색",args["머리색"])
     elseif nv ~= '' then
     addRow(infoTable,"눈색",args["눈색"])
        return table_row('나이', 'VN ' .. nv)
     addRow(infoTable,"학교",args["학교"])
     elseif na ~= '' then
        return table_row('나이', '애니 ' .. na)
     else
        return ''
     end
end


-- 메인 생성 함수 (순수 위키텍스트 반환)
     -- ▶ FC 프로필
function p.main(frame)
     addRow(infoTable,"소속 팀",args["소속_팀"])
    local parent = frame:getParent() or frame
     addRow(infoTable,"포지션",args["포지션"])
    local args = parent.args or {}
   
    for k, v in pairs(args) do args[k] = trim(v) end
   
    local theme_color = args['색상'] and args['색상'] ~= '' and args['색상'] or '#007bff'
   
     -- ********** 위키 테이블 문자열 구성 시작 **********
    local wiki_table = {}
   
    -- 외부 테이블 시작 (표준 인포박스 스타일)
     table.insert(wiki_table, string.format('{| class="infobox" style="width: 300px; margin: 0 0 1em 1em; border: 1px solid #aaa; border-collapse: collapse; background-color: #f9f9f9; float: right; font-size: 90%%;"'))
   
    -- 1. 제목 및 이미지
    table.insert(wiki_table, string.format('! colspan="2" style="background-color: %s; color: white; padding: 5px; text-align: center; font-size: 110%%;" | %s 프로필', theme_color, args['이름'] or ''))
    table.insert(wiki_table, '|-')
     table.insert(wiki_table, string.format('| colspan="2" style="padding: 10px; text-align: center;" | %s', build_image_block(args)))
   
    -- 2. 이름 정보 (이름 블록을 하나의 셀로 처리)
    table.insert(wiki_table, '|-')
    table.insert(wiki_table, string.format('| colspan="2" style="text-align: center; padding: 5px;" | %s', build_name_block(args)))


      
     for i=1,5 do
    -- 3. 기본 정보
        addRow(infoTable,"시그니처 기술 "..i,args["시그니처기술"..i])
    table.insert(wiki_table, '|-')
    table.insert(wiki_table, string.format('! colspan="2" style="background-color: #e0e0e0; padding: 5px; text-align: center;" | 기본 정보'))
   
    table.insert(wiki_table, build_age_row(args))
    table.insert(wiki_table, table_row('성별', args['성별']))
    table.insert(wiki_table, table_row('생일', args['생일']))
    table.insert(wiki_table, table_row('신장', args['신장']))
    table.insert(wiki_table, table_row('체중', args['체중']))
    table.insert(wiki_table, table_row('머리색', args['머리색']))
    table.insert(wiki_table, table_row('눈색', args['눈색']))
    table.insert(wiki_table, table_row('학교', args['학교']))
    table.insert(wiki_table, table_row('거주지', args['거주지']))
   
    -- 4. FC 프로필
    local fc_content = table_row('포지션', args['포지션']) .. table_row('소속 팀', args['소속_팀'])
    local techs = gather_techs(args)
    if #techs > 0 then
        fc_content = fc_content .. table_row('시그니처 기술', table.concat(techs, '<br/>'))
     end
     end


     if trim(args['포지션']) ~= '' or trim(args['소속_팀']) ~= '' or #techs > 0 then
     -- ▶ 기타
        table.insert(wiki_table, '|-')
    addRow(infoTable,"거주지",args["거주지"])
        table.insert(wiki_table, string.format('! colspan="2" style="background-color: #a0d0ff; padding: 5px; text-align: center;" | FC 프로필'))
    addRow(infoTable,"취미",args["취미"])
        table.insert(wiki_table, fc_content)
    addRow(infoTable,"좋아하는 음식",args["좋아하는음식"])
    end
 
   
     -- 성우 및 출연
     -- 5. 성우 및 데뷔
     addRow(infoTable,"성우(JP)",args["성우_JP"])
     if trim(args['성우_JP']) ~= '' or trim(args['성우_EN']) ~= '' then
    addRow(infoTable,"성우(EN)",args["성우_EN"])
        table.insert(wiki_table, '|-')
    addRow(infoTable,"애니 데뷔",args["애니_데뷔"])
        table.insert(wiki_table, string.format('! colspan="2" style="background-color: #e0e0e0; padding: 5px; text-align: center;" | 성우 정보'))
    addRow(infoTable,"게임 데뷔",args["게임_데뷔"])
        table.insert(wiki_table, table_row('일본어', args['성우_JP']))
    addRow(infoTable,"만화 데뷔",args["만화_데뷔"])
        table.insert(wiki_table, table_row('영어', args['성우_EN']))
    end


     table.insert(wiki_table, '|}') -- 테이블 닫기
     html:node(infoTable)


    -- 최종 출력: 스타일 태그가 없으므로 Lua 모듈은 순수한 위키텍스트를 반환함.
     return tostring(html)
     return table.concat(wiki_table, '\n')
end
end


return p
return p

2025년 12월 5일 (금) 03:12 판

이 모듈에 대한 설명문서는 모듈:푸른 저편의 포리듬/ 캐릭터 프로필/설명문서에서 만들 수 있습니다

local p = {}

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

    local color = args["색상"] or "#444"

    local html = mw.html.create("div")
    html:addClass("profile-card")
    html:css({
        ["border"] = "2px solid "..color,
        ["border-radius"] = "10px",
        ["padding"] = "12px",
        ["width"] = "100%",
        ["box-sizing"] = "border-box",
        ["background"] = "#fafafa",
        ["font-family"] = "'Noto Sans KR', sans-serif"
    })

    -- 이름 영역
    local nameBlock = mw.html.create("div")
    nameBlock:css({["text-align"] = "center", ["margin-bottom"] = "10px"})

    nameBlock:tag("div"):css({["font-size"] = "20px", ["font-weight"] = "bold", ["color"] = color})
        :wikitext(args["이름"] or "")

    nameBlock:tag("div"):css({["font-size"] = "13px", ["color"] = "#555"})
        :wikitext((args["이름_일어"] or "").." / "..(args["이름_영어"] or ""))

    html:node(nameBlock)

    -- 이미지 + 탭
    local images = {}
    if args["이미지_VN"] and args["이미지_VN"]~="" then
        table.insert(images,'|비주얼 노벨=[[File:'..args["이미지_VN"]..'|200px]]')
    end
    if args["이미지_애니"] and args["이미지_애니"]~="" then
        table.insert(images,'|애니메이션=[[File:'..args["이미지_애니"]..'|200px]]')
    end
    if args["이미지_추가"] and args["이미지_추가"]~="" then
        table.insert(images,'|추가='..args["이미지_추가"])
    end

    if #images > 0 then
        html:wikitext('<div style="text-align:center; margin:10px 0;"><tabber>'..table.concat(images,"\n")..'</tabber></div>')
    end

    -- 테이블 생성 함수
    local function addRow(tbl, label, value)
        if value and value ~= "" then
            tbl:tag("tr")
                :tag("th"):wikitext(label).done()
                :tag("td"):wikitext(value)
        end
    end

    -- ▶ 기본정보 영역
    local infoTable = mw.html.create("table")
    infoTable:css({
        ["width"]="100%",
        ["border-collapse"]="collapse",
        ["font-size"]="13px"
    })

    addRow(infoTable,"성별",args["성별"])
    addRow(infoTable,"나이", (args["나이_VN"]~="" and "VN: "..args["나이_VN"] or "").." / "..(args["나이_애니"]~="" and "애니: "..args["나이_애니"] or ""))    
    addRow(infoTable,"생일",args["생일"])
    addRow(infoTable,"신장",args["신장"])
    addRow(infoTable,"체중",args["체중"])
    addRow(infoTable,"머리색",args["머리색"])
    addRow(infoTable,"눈색",args["눈색"])
    addRow(infoTable,"학교",args["학교"])

    -- ▶ FC 프로필
    addRow(infoTable,"소속 팀",args["소속_팀"])
    addRow(infoTable,"포지션",args["포지션"])

    for i=1,5 do
        addRow(infoTable,"시그니처 기술 "..i,args["시그니처기술"..i])
    end

    -- ▶ 기타
    addRow(infoTable,"거주지",args["거주지"])
    addRow(infoTable,"취미",args["취미"])
    addRow(infoTable,"좋아하는 음식",args["좋아하는음식"])

    -- ▶ 성우 및 출연
    addRow(infoTable,"성우(JP)",args["성우_JP"])
    addRow(infoTable,"성우(EN)",args["성우_EN"])
    addRow(infoTable,"애니 데뷔",args["애니_데뷔"])
    addRow(infoTable,"게임 데뷔",args["게임_데뷔"])
    addRow(infoTable,"만화 데뷔",args["만화_데뷔"])

    html:node(infoTable)

    return tostring(html)
end

return p