モジュール:サンドボックス/Triglav/test2

モジュールの解説[作成]
local p = {}

function p.list(frame)
    local s = frame.args['page']
    local step = frame.args['step']
    local offset = frame.args['offset']

    -- リストページを整理する
    s = string.gsub(s, "%[%[日本十進分類法%]%]", "日本十進分類法")
    s = string.gsub(s, "%]%].-%[%[", "]] - [[")
    s = string.gsub(s, "^.-%[%[(.*)%]%].-$", "%1]] - [[")

    -- 配列に抽出
    local tbl1 = {}
    text = ""
    i = 0
    while s ~= "" do 
        i = i + 1
        tbl1[i] = string.gsub(s, "^(.-)%]%].-%[%[.*", "%1")
        s = string.gsub(s, "^.-%]%].-%[%[", "")
--        text = text.."\n*"..tbl1[i]
    end

    -- 100刻みでシャッフル
--    text = text.."\n\n\n"
    local tbl2 = {}
    k = 0
    for i = 1, 100, 1 do
        j = 0
        while i + j * 100 <= #tbl1 do
            k = k + 1
            tbl2[k] = tbl1[i + j * 100]
--            text = text.."\n*"..tbl2[k]
            j = j + 1
        end
    end

    -- JSTの通算日を算出
    y = ( os.date("%s") + 32400 ) / 86400
    x = math.floor(y)

    -- 一日あたりstep分の枚数を表示
-- x = 16686
-- for x = 16686, 17000, 1 do
-- x = x + 1
-- offset = 0
    z = math.mod(x * step, #tbl2) + 1 + offset
--    text = text.."\n*"..y.."\n*"..x.."\n*"..z.."\n*"..tbl3[z]
    text = tbl2[z]
-- end

-- text = "荒川 (関東)"
if text == "ボストン" then
    text = "Wikipedia:良質ピックアップ/ボストン"
end
if text == "神奈川中央交通" then
    text = "Wikipedia:良質ピックアップ/神奈川中央交通"
end
if text == "法隆寺金堂釈迦三尊像光背銘" then
    text = "ゴート戦争"
end
if text == "法隆寺金堂薬師如来像光背銘" then
    text = "水晶の夜"
end
    return text
end
 
return p