6,571
个编辑
小 (update) |
小 (update) |
||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
function split(input, delimiter) | function split(input, delimiter) | ||
第130行: | 第68行: | ||
return len | return len | ||
end | end | ||
function time_style(time) | function time_style(time) | ||
第144行: | 第78行: | ||
if string.format("%02d", t_time.month)~="00" then return | if string.format("%02d", t_time.month)~="00" then return [[background-color: #bbb;]] end | ||
if tonumber(string.format("%02d", t_time.day))>= | if tonumber(string.format("%02d", t_time.day))>=7 then return [[background-color: #ddd;]] end | ||
if tonumber(string.format("%02d", t_time.day))>= | if tonumber(string.format("%02d", t_time.day))>=1 then return [[]] end | ||
return | return [[background-color: #efe;]] | ||
end | end | ||
第162行: | 第96行: | ||
end | end | ||
return diff | return diff | ||
end | |||
function close(text,timestyle) | |||
local yes=string.match(text, "closed%-topic%-yes") | |||
local no=string.match(text, "closed%-topic%-no") | |||
if yes then return [[background-color: #efe;]] end | |||
if no then return [[background-color: #fee;]] end | |||
return timestyle | |||
end | |||
function cov(talk) | |||
--关键词替换 | |||
--如有字符导致生成错误,请在这里添加转换 | |||
talk=string.gsub(talk, "===(.-)===", "%1") | |||
talk=string.gsub(talk, "用户", "User") | |||
talk=string.gsub(talk, "user", "User") | |||
return talk | |||
end | |||
function link(text) | |||
--此处添加导致链接工作不正常的文本 | |||
text=trim(trim(text)) | |||
text=string.gsub(text, " (.*)", "%1") | |||
text=LuaReomve(text,"%[") | |||
text=LuaReomve(text,"%]") | |||
return text | |||
end | |||
function user_link(text) | |||
--输入用户名以及带有ip:前缀的ip用户。 | |||
local ipuser=string.match(text,"ip:(.*)") | |||
if ipuser then | |||
return "[[Special:用户贡献/"..ipuser.."|"..ipuser.."]]" | |||
else | |||
return "[[User:"..text.."|"..text.."]]" | |||
end | |||
end | end | ||
第202行: | 第172行: | ||
function talk_time(talk) | function talk_time(talk) | ||
local result=string.match(talk,"[%s%S]*(%d%d%d%d.*) %( | local result=string.match(talk,"[%s%S]*(%d%d%d%d.*) %(UTC%)") | ||
return result | return result | ||
end | end | ||
第209行: | 第179行: | ||
--输入讨论的文本,输出和User有关的转换部分table | --输入讨论的文本,输出和User有关的转换部分table | ||
--1-4分别为发言条数,发言人数,发起人,最后发言的人。 | --1-4分别为发言条数,发言人数,发起人,最后发言的人。 | ||
local match=string.gmatch (text," | text=string.gsub(text, "Special:用户贡献/", "User:ip:") | ||
local match=string.gmatch (text,"User:([^\n]-)%|[^\n]-UTC") | |||
local userlist={} | local userlist={} | ||
local user,firstuser,lastuser="","","" | local user,firstuser,lastuser="","","" | ||
第230行: | 第201行: | ||
function get_table(talktitle,talktext) | function get_table(talktitle,talktext) | ||
local result=[[<table class="wikitable sortable mw-collapsible" style="text-align:center"><tr><th>#</td><th>话题</td><th>发言</td><th>参与</td><th>发起者</td><th>最近发言</td><th>最后发言时间( | local result=[[<table class="wikitable sortable mw-collapsible" style="text-align:center"><tr><th>#</td><th>话题</td><th>发言</td><th>参与</td><th>发起者</td><th>最近发言</td><th>最后发言时间(UTC)</td></tr>]] | ||
local tableend=[[</table>]] | local tableend=[[</table>]] | ||
local part="" | local part="" | ||
第239行: | 第210行: | ||
do | do | ||
time,userinf=talk_time(talktext[i]),user_manage(talktext[i]) | time,userinf=talk_time(talktext[i]),user_manage(talktext[i]) | ||
if userinf[1] | if userinf[1]==1 then userstyle=[[background-color: #fcc;"]] else userstyle=[[]] end | ||
if userinf[2] | if userinf[2]==1 then userstyleind=[[background-color: #fcc;"]] else userstyleind=[[]] end | ||
timestyle=close(talktext[i],time_style(time)) | timestyle=close(talktext[i],time_style(time)) | ||
part=[[<tr><th>]]..i..[[</td><td>]]..link(talktitle[i])..[[</td><td style="]]..userstyle..[[">]]..userinf[1]..[[</td><td style="]]..userstyleind..[[">]]..userinf[2]..[[</td><td>]].. | part=[[<tr><th>]]..i..[[</td><td>]]..link(talktitle[i])..[[</td><td style="]]..userstyle..[[">]]..userinf[1]..[[</td><td style="]]..userstyleind..[[">]]..userinf[2]..[[</td><td>]]..user_link(userinf[3])..[[</td><td style="]]..timestyle..[[">]]..user_link(userinf[4])..[[</td><td style="]]..timestyle..[[">]]..tostring(time) | ||
result=result..part | result=result..part | ||
end | end |