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

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