Module:UserLinks/shared:修订间差异
删除的内容 添加的内容
enwiki>Mr. Stradivarius set up a local blacklist system so that we don't categorise sandboxes or test case pages |
来源:求闻编者,https://www.qiuwenbaike.cn/wiki/Module:UserLinks/shared,许可证:CC BY-SA 4.0(https://creativecommons.org/licenses/by-sa/4.0/) |
||
第1行:
-- This module stores functions that are shared between [[Module:UserLinks]]
-- and [[Module:UserLinks/extra]].
-- Load data and define often-used variables
local cfg = mw.loadData('Module:UserLinks/config')
local namespaces = mw.site.namespaces
-- Lazily initialise modules that we may or may not need
local mCategoryHandler
-- Define namespaces for which links need to be escaped with the colon trick.
-- See [[w:en:Help:Colon trick]].
第15行:
[14] = true, -- Category
}
local p = {}
function p.maybeLoadModule(s)
-- Attempts to load the module s. If it succeeds, returns the module;
第28行:
end
end
function p.raiseError(message, section, level)
-- Raises an error using the Lua error function. The error message is
第44行:
error(message, level)
end
function p.makeWikitextError(encodedMessage, demo)
local errorMessage, section = mw.ustring.match(encodedMessage, '^(.-)|(.*)$')
errorMessage = errorMessage or encodedMessage
-- If not a demo, get the error category link and pass it through
-- [[Module:Category handler]]'s blacklist.
第79行 ⟶ 第62行:
-- Categorise all namespaces, but not blacklisted pages.
category = mCategoryHandler.main{all = category}
end
end
category = category or ''
-- Format the error message and the section link.
local formattedError
第100行 ⟶ 第80行:
)
end
-- Return the error message and the category inside html error tags.
return string.format(
第108行 ⟶ 第88行:
)
end
local function formatPage(interwiki, namespace, page)
-- Formats an interwiki, a namespace and a page into a wikilink-ready
第136行 ⟶ 第116行:
return table.concat(ret)
end
local function formatDisplay(s)
-- Replaces spaces in a string with " " to make sure they don't wrap.
第147行 ⟶ 第127行:
end
end
function p.makeWikilink(interwiki, namespace, page, display)
-- Creates a wikilink. The interwiki, namespace and display parameters are
第160行 ⟶ 第140行:
end
end
local function formatUrlLink(url, display)
-- Formats a URL link with an optional display parameter.
第170行 ⟶ 第150行:
end
end
function p.makeUrlLink(s, display)
local url = tostring(mw.uri.new(s))▼
▲ local url = mw.uri.new(s)
▲ return formatUrlLink(url, display)
end
function p.makeFullUrlLink(interwiki, namespace, page, query, display)
local formattedPage = formatPage(interwiki, namespace, page)
end
function p.message(key, ...)
-- Returns the message with the given key from [[Module:UserLinks/config]].
第209行 ⟶ 第180行:
end
end
return p
| |||