mNo edit summary |
m (load directly from url [F_______ ugly]) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 23: | Line 23: | ||
end | end | ||
return r | return r | ||
end | |||
local members = mw.loadData [[Module:Sandbox/data]] | |||
members = mw.text.jsonDecode( | |||
(mw.ext.externaldata.getWebData({ | |||
url = "https://tildeverse.org/members.json", | |||
data = "data=data", | |||
regex = "/(?'data'[\\s\\S]*)/", | |||
format = 'text' | |||
}))[1]['data']).members | |||
local function as_date(d) | |||
local year, month, day = string.match(d, | |||
[[(%d+)-(%d+)-(%d+)T]]) | |||
local t = os.time{ year = year, month = month, day = day} | |||
return os.date("%B %e, %Y", t) | |||
end | |||
local function admins(a) | |||
local t = {} | |||
for _, v in ipairs(a) do | |||
table.insert(t, '[' .. v[2] .. ' ' .. v[1] .. ']') | |||
end | |||
return table.concat(t, ', ') | |||
end | |||
M.list = function() | |||
local tbl = [=[ | |||
{|class="wikitable"| | |||
! Name | |||
! Description | |||
! Created | |||
! Sysadmins | |||
! OS | |||
! [[tilde.chat]] channel | |||
! Link]=] | |||
for _, v in ipairs(members) do | |||
local s = "|-\n| " .. table.concat({ | |||
v.name, | |||
v.description, | |||
as_date(v.created), | |||
admins(v.sysadmins), | |||
v.os, | |||
v.channel, | |||
v.link | |||
}, "\n| ") | |||
tbl = tbl .. "\n" .. s | |||
end | |||
tbl = tbl .. "\n|}" | |||
return tbl | |||
end | end | ||
return M | return M |
Latest revision as of 05:36, 7 June 2021
Documentation for this module may be created at Module:Sandbox/doc
local M = {}
function M.hello(F)
local whom = F.args[1]
if whom == nil then return 'Hi!' end
return [[Hello, ]] .. whom .. '!'
end
function M:fizzbuzz()
local r = ''
for i = 1, 100 do
local s = ''
if i % 3 == 0 then
s = s .. 'Fizz'
end
if i % 5 == 0 then
s = s .. 'Buzz'
end
if s == '' then
s = s .. i
end
r = r .. s .. "\n"
end
return r
end
local members = mw.loadData [[Module:Sandbox/data]]
members = mw.text.jsonDecode(
(mw.ext.externaldata.getWebData({
url = "https://tildeverse.org/members.json",
data = "data=data",
regex = "/(?'data'[\\s\\S]*)/",
format = 'text'
}))[1]['data']).members
local function as_date(d)
local year, month, day = string.match(d,
[[(%d+)-(%d+)-(%d+)T]])
local t = os.time{ year = year, month = month, day = day}
return os.date("%B %e, %Y", t)
end
local function admins(a)
local t = {}
for _, v in ipairs(a) do
table.insert(t, '[' .. v[2] .. ' ' .. v[1] .. ']')
end
return table.concat(t, ', ')
end
M.list = function()
local tbl = [=[
{|class="wikitable"|
! Name
! Description
! Created
! Sysadmins
! OS
! [[tilde.chat]] channel
! Link]=]
for _, v in ipairs(members) do
local s = "|-\n| " .. table.concat({
v.name,
v.description,
as_date(v.created),
admins(v.sysadmins),
v.os,
v.channel,
v.link
}, "\n| ")
tbl = tbl .. "\n" .. s
end
tbl = tbl .. "\n|}"
return tbl
end
return M