编辑“Module:Topic list”
跳到导航
跳到搜索
该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
第14行: | 第11行: | ||
:gsub('Special:Contributions/(%d+%.%d+%.%d+%.%d+)', 'User:ip:%1') | :gsub('Special:Contributions/(%d+%.%d+%.%d+%.%d+)', 'User:ip:%1') | ||
:gsub('Special:Contribs/(%d+%.%d+%.%d+%.%d+)', 'User:ip:%1') | :gsub('Special:Contribs/(%d+%.%d+%.%d+%.%d+)', 'User:ip:%1') | ||
:gsub('用户', 'User') | :gsub('[[ 用户', 'User') | ||
:gsub('user', 'User | :gsub('[[user', 'User') | ||
return talk | return talk | ||
end | end | ||
function | function titleConv(talk) | ||
-- 论题转换 | -- 论题转换 | ||
talk = talk | talk = talk | ||
:gsub(' | :gsub('<.->', '') | ||
:gsub('%[%[', '') | |||
:gsub('|.-%]%]', '') | |||
:gsub('%]%]', '') | |||
:gsub('^%s', '') | |||
:gsub('%s$', '') | |||
return talk | return talk | ||
end | end | ||
第55行: | 第47行: | ||
function getTimeStyle(time) | function getTimeStyle(time) | ||
if time == ' | if time == ' 未知日期' then | ||
return 'background-color: #fee;' | return 'background-color: #fee;' | ||
end | end | ||
第87行: | 第79行: | ||
function trim(text) | function trim(text) | ||
-- remove special strip markers and spaces | -- remove special strip markers and spaces | ||
text = mw.text.killMarkers(text):gsub('^[ | text = mw.text.killMarkers(text):gsub('^[\t\r\n\f]*(.-)[\t\r\n\f]*$', '%1') | ||
return text | return text | ||
end | end | ||
第117行: | 第109行: | ||
function getTitleList(pageName) | function getTitleList(pageName) | ||
local talk = | local talk = conv(mw.getCurrentFrame():expandTemplate {title = ':' .. pageName}) | ||
local titleList = {} | local titleList = {} | ||
for title in talk:gmatch '==(.-)==' do | for title in talk:gmatch '==(.-)==' do | ||
titleList[#titleList + 1] = | titleList[#titleList + 1] = title | ||
end | end | ||
第127行: | 第119行: | ||
function getTalkTime(talk) | function getTalkTime(talk) | ||
local result = talk:match '[%s%S]*(%d%d%d%d.*) %(CST%)' or ' | local result = talk:match '[%s%S]*(%d%d%d%d.*) %(CST%)' or ' 未知日期' | ||
return result | return result | ||
第136行: | 第128行: | ||
local userList = {} | local userList = {} | ||
if text:match '[^\n]*User:([^\n]-)%|[^\n]-CST' == nil then | if text:match '[^\n]*User:([^\n]-)%|[^\n]-CST' == nil then | ||
return {userNum = ' | return {userNum = '?', uniqueUserNum = '?', firstUser = '?', lastUser = '?'} | ||
end | end | ||
for user in text:gmatch '[^\n]*User:([^\n]-)%|[^\n]-CST' do | for user in text:gmatch '[^\n]*User:([^\n]-)%|[^\n]-CST' do | ||
第150行: | 第142行: | ||
function generateTable(pageName, talkTitle, talkText) | function generateTable(pageName, talkTitle, talkText) | ||
local body = { | local body = { | ||
'{| class="wikitable sortable | '{| class="wikitable sortable collapsible talktable" style="text-align: center;"', | ||
'|-', | '|-', | ||
'! # !! 话题 !! 发言条 | '! # !! 话题 !! 发言条数 ', | ||
'! class="talkpage-topic-list-author" | 发起者', | '! class="talkpage-topic-list-author" | 发起者', | ||
'! class="talkpage-topic-list-last-editor" | 最后发言者', | '! class="talkpage-topic-list-last-editor" | 最后发言者', | ||
第175行: | 第167行: | ||
'|-', | '|-', | ||
'! style="' .. serialStyle .. '" | ' .. i, | '! style="' .. serialStyle .. '" | ' .. i, | ||
'| [[' .. pageName .. '#' .. talkTitle[i] .. '|' .. talkTitle[i].. ']]', | '| [[' .. pageName .. '#' .. titleConv(trim(talkTitle[i])) .. '|' .. titleConv(trim(talkTitle[i])) .. ']]', | ||
'| style="' .. userStyle .. '" | ' .. userInfo.userNum, | '| style="' .. userStyle .. '" | ' .. userInfo.userNum, | ||
'| class="talkpage-topic-list-author" |' .. makeUserLink(userInfo.firstUser), | |||
'| class="talkpage-topic-list-author" | ' .. makeUserLink(userInfo.firstUser), | |||
'| class="talkpage-topic-list-last-editor" style="' .. timeStyle .. '" | ' .. makeUserLink(userInfo.lastUser), | '| class="talkpage-topic-list-last-editor" style="' .. timeStyle .. '" | ' .. makeUserLink(userInfo.lastUser), | ||
'| class="talkpage-topic-list-time" style="' .. timeStyle .. '" | ' .. time | '| class="talkpage-topic-list-time" style="' .. timeStyle .. '" | ' .. time | ||
第196行: | 第187行: | ||
local talkTitle, talkText = getTitleList(args[1]), getTalkList(args[1]) | local talkTitle, talkText = getTitleList(args[1]), getTalkList(args[1]) | ||
for i = 1, #talkTitle do | for i = 1, #talkTitle do | ||
talkTitle[i] = f:preprocess(talkTitle[i]) | talkTitle[i] = f:preprocess(talkTitle[i]) | ||
end | end | ||
local result = generateTable(args[1], talkTitle, talkText) | |||
if #talkTitle == #talkText then | |||
return result | |||
else | |||
return error 'Topic list获取错误。' | |||
end | |||
end | end | ||
return p | return p |