Module:Awajie:修订间差异

来自有兽档案馆
无编辑摘要
无编辑摘要
标签手工回退
 
(未显示同一用户的34个中间版本)
第1行: 第1行:
local randoms = mw.loadData 'Module:Featured picture list/randoms'
local p = {}
local dates = mw.loadData 'Module:Featured picture list/dates'


local p = {}
function p.test(frame)
function p.main(frame)
local args = frame.args
local order = args[1]
local lang = mw.language.getContentLanguage()
local name = args[2]
local year = lang:formatDate('Y', nil, true)
local some = args[3]
local month = lang:formatDate('n', nil, true)
local day = lang:formatDate('j', nil, true)
local function contains(t, value)
for _, v in ipairs(t) do
if v == value then
return true
end
end
return false
end
if dates[year] and dates[year][month] and dates[year][month][day] then
local function custom_sort(a, b)
return frame:preprocess(dates[year][month][day])
return tonumber(a) > tonumber(b)
elseif dates['any'] and dates['any'][month] and dates['any'][month][day] then
return frame:preprocess(dates['any'][month][day])
end
end
local edits = mw.site.stats.edits
if name == nil or name == "" then
local title = randoms[edits % randoms.length + 1]
return "文本为空,请在|name=填入要查询的角色名"
return frame:expandTemplate {title = title}
end
local pattern = "第(%d+)话"
local extracted_numbers = {}
for match in (some..pattern):gmatch(pattern) do
if not contains(extracted_numbers, match) then
table.insert(extracted_numbers, match)
end
end
local sorted_t = {}
for i, x in ipairs(extracted_numbers) do
table.insert(sorted_t, tonumber(x))
end
if order == 'asc' then
table.sort(sorted_t)
elseif order == 'desc' then
table.sort(sorted_t, custom_sort)
end
local huashu = {}
for i, num in ipairs(sorted_t) do
local new_value = "[[第" .. num .. "话]]"
table.insert(huashu, new_value)
end
local plainlinks = "plainlinks"
local namelur = "<span class=" ..plainlinks.. ">[https://youshou.wiki/wiki/Special:%E8%AF%A2%E9%97%AE/-5B-5BOnCamera:character-20name::" ..name.. "-5D-5D/limit%3D50/format%3Dplainlist 查询更多]</span>"
table.insert(huashu, namelur)

local result = {}
local counter = 0
for _, val in ipairs(huashu) do
table.insert(result, val)
counter = counter + 1
if counter % 14 == 0 and counter ~= #huashu then
table.insert(result, "<br>")
end
if counter % 14 ~= 0 then
table.insert(result, " · ")
end
end
local lastElement = table.remove(result)
if lastElement ~= " · " then
table.insert(result, lastElement)
end
local output = table.concat(result, "")
return output
end

function p.listl( framel )
local orderl = framel.args[1]
local queryResult = mw.smw.ask( orderl )
local output = table.concat(queryResult, "")
return output
end
end

return p
return p

2024年4月18日 (四) 10:44的最新版本

文档图示 模块文档[创建] [跳转到代码]

本模块还没有文档页面。

您可以创建文档以让编者更好地理解本模块的用途。
编者可以在本模块的沙盒创建 | 镜像和测试样例创建页面进行实验。
请将模块自身所属的分类添加在文档中。本模块的子页面
local randoms = mw.loadData 'Module:Featured picture list/randoms'
local dates = mw.loadData 'Module:Featured picture list/dates'

local p = {}
function p.main(frame)
	local lang = mw.language.getContentLanguage()
	local year = lang:formatDate('Y', nil, true)
	local month = lang:formatDate('n', nil, true)
	local day = lang:formatDate('j', nil, true)
	
	if dates[year] and dates[year][month] and dates[year][month][day] then
		return frame:preprocess(dates[year][month][day])
	elseif dates['any'] and dates['any'][month] and dates['any'][month][day] then
		return frame:preprocess(dates['any'][month][day])
	end
	
	local edits = mw.site.stats.edits
	local title = randoms[edits % randoms.length + 1]
	return frame:expandTemplate {title = title}
end
return p