Module:PageLinks:修订间差异
删除的内容 添加的内容
enwiki>Axolitl Make search exact per talk page (ping: @User:Myceteae and User:Scyrme) 标签:已被回退 |
CaelLab-import(留言 | 贡献) huifu bei enwiki daoru dingti de banben (shangyiban zhwiki>EqJjgOa8rVvsRmZL) 标签:手工回退 |
||
第1行:
local ToolbarBuilder = require('Module:Toolbar')
local mLan = require('Module:Lan')
local p = {} -- Page object
第7行 ⟶ 第8行:
-- Define a custom error message for this module.
local function err(msg, section)
return '<strong class="error">[[模块:PageLinks|' .. mLan._main({['zh-hans']='模块', ['zh-hant']='模組'}, mw.getCurrentFrame()) .. ':PageLinks]]錯誤:' .. msg .. '。</strong>[[Category:有错误的PageLinks嵌入]]'
end
第26行 ⟶ 第14行:
-- To add more link types, write a function that produces an individual link, and put --
-- it at the bottom of the list below. Then, add a link code for your function to the --
-- "linktypes" table. Try and make the code three letters or less.
--
-- If you want more helper strings, you can define them in the generatePageDataStrings --
第41行 ⟶ 第29行:
local function makeTalkLink()
return '[[' .. tostring(p.talkPageTitle) .. '|
end
local function
return '[[Special:WhatLinksHere/' .. p.fullText .. '|' .. mLan._main({['zh-hans']='链接', ['zh-hant']='連結'}, mw.getCurrentFrame()) .. ']]'
end
local function
return '[[Special:WhatLinksHere/' .. p.fullText .. '|
end
local function makeRelatedChangesLink()
return '[[Special:RelatedChanges/' .. p.fullText .. '|
end
local function makeEditLink()
local url = p:fullUrl( 'action=edit' );
return '[' .. url .. ' 编辑]'
end
local function makeHistoryLink()
return '[' .. url .. ' 历史]'
end
local function makeWatchLink()
return '[' .. url .. ' 监视]'
end
local function makeTargetLogsLink()
local url = mw.uri.fullUrl( 'Special:Log', 'page=' .. mw.uri.encode(p.fullText) )
return '[' .. tostring(url) .. '
end
local function makeEditFilterLogLink()
local url = mw.uri.fullUrl( 'Special:AbuseLog', 'wpSearchTitle=' .. mw.uri.encode(p.fullText) )
return '[' .. tostring(url) .. '
end
local function
local url = 'http://stats.grok.se/' .. lang .. '/' .. year .. string.format("%0.2d",month) .. '/' .. mw.uri.encode( p.fullText )
return url
end
local function monthsago(months)
if rv.month < months + 1 then
rv.month = 12 + (rv.month - months)
rv.year = rv.year - 1
else
end
return rv
end
local function
local
return '[' ..
end
第118行 ⟶ 第97行:
local linktypes = {
{'t'
{'wlh' , makeWhatLinksHereLink},
{'wlh2' , makeWhatLinksHereLink2},
{'rc'
{'edit
{'h'
{'w'
{'tl'
{'efl'
}
local function getLink(linktype
local linkNumber
for i, value in ipairs(linktypes) do
if value[1] == linktype then
linkNumber = i
break
end
if not linkNumber then
return err('“' .. linktype .. '”不是有效的链接代码', '非有效链接代码')
end
local result = linktypes[linkNumber][2]()
if type(result) ~= 'string' then
return err(
'代码“' .. linktype .. '”的函数没有返回字符串值',
'函数未返回字符串值'
)
end
return result
end
第148行 ⟶ 第136行:
if type(k) == 'number' and p then
numArgsExist = true
targs[k] = getLink(v
end
end
targs.style = args.small and 'font-size: 90%;'
targs.separator = args.separator or 'dot'
if numArgsExist == false then
return nil -- Don't return a toolbar if no numeric arguments exist. -- this bit looks odd
第165行 ⟶ 第152行:
-- If the page name is absent or blank, return an error and a tracking category.
if args.page == '' or not args.page then
return err('
end
local noError
noError, p = pcall(mw.title.new, args.page)
if not noError then
return err('pcall mw.title
end
if args.exists and (not p or p['id'] == 0) then
return err('
end
end
第188行 ⟶ 第175行:
-- It is used in the module documentation.
local function getLinkTable(args)
-- Build a table of all of the links.
local result = '<table class="wikitable plainlinks sortable">'
.. '\n<tr><th>代码</th><th>预览</th></tr>'
for i, value in ipairs(linktypes) do
local code = value[1]
result = result .. "\n<tr><td>'''" .. code .. "'''</td><td>" .. getLink(code) .. '</td></tr>'
end
result = result .. '\n</table>'
return result
end
第217行 ⟶ 第201行:
return dataStringError
end
local linktype = args[1]
if not linktype then
return err('
end
local result = getLink(linktype
result = result .. generateTrackingCategories()
return result
第233行 ⟶ 第217行:
if dataStringError then
return dataStringError
end
-- Build the template output.
local result = makeToolbar(args) -- Get the toolbar contents.
第287行 ⟶ 第271行:
origArgs = frame
end
-- Strip whitespace, and treat blank arguments as nil.
-- 'page', and 'separator' have different behaviour depending on
第298行 ⟶ 第282行:
end
end
return func(args)
end
| |||