「モジュール:SignalinstWiki」の版間の差分

修正
モジュール調整
74行目: 74行目:
     return finalOutput
     return finalOutput
end
end


function p.categoriesToTemplate(frame)
function p.categoriesToTemplate(frame)
-- 返すべき内容を保持する
    local output = "{{ナビゲーションボックス"
local output = "{{ナビゲーションボックス|title=カテゴリ別ページ一覧|opened=False|"
        .. "|title=カテゴリ別ページ一覧"
        .. "|opened=False|"
-- パーサーを呼び出し、Semantec MediaWikiからカテゴリ一覧を取得
 
local result = frame:callParserFunction("#ask", "[[TopCategory::true]]|?PAGENAME|format=plainlist")
    -- TopCategory=true なカテゴリページ一覧を取得
    local categories = frame:callParserFunction(
-- 中身を正規化したうえで分割し、各カテゴリごとに回す
        "#ask",
local i = 1
        "[[TopCategory::true]]"
for line in mw.text.gsplit(result, "\n", true) do
        .."|?PAGENAME"
if line ~= '' then
        .."|format=list"
-- line = 名前空間を除いたタイトル => カテゴリ名称
        .."|sep=\n"
-- このカテゴリに対して意味的検索を用いてさらにページ一覧を取得
    )
local result = frame:callParserFunction("#ask", "[[カテゴリ:"..line.."]]|?PAGENAME|format=list|sep=,")
 
    local i = 1
-- カンマ区切りで出力されるのでこれをテンプレートに埋め込む
    for category in mw.text.gsplit(categories or "", "\n", true) do
output = output .. "header"..i.."="..line.."|content"..i.."="..result.."|"
        if category ~= "" then
            -- Category 名前空間を除去
-- iのインクリメント
            local categoryName = category:gsub("^カテゴリ:", "")
i = i + 1
 
end
            -- Concept を使ってページ取得
end
            local pages = frame:callParserFunction(
                "#ask",
-- 閉じて返す
                "[[Concept:" .. categoryName .. "]]"
output = output .. "}}"
                .."|?PAGENAME"
                .."|format=list"
return output
                .."|sep=, "
            )
 
            output = output
                .. "header" .. i .. "=" .. categoryName .. "|"
                .. "content" .. i .. "=" .. (pages or "") .. "|"
 
            i = i + 1
        end
    end
 
    output = output .. "}}"
    return output
end
end


return p
return p