Anonymous user
Module:UserLinks: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
add support for different projects in the edit summary link, reduce some long lines of code
(add support for different projects in the edit count link) |
(add support for different projects in the edit summary link, reduce some long lines of code) |
||
Line 30:
-- u.projectCode If a valid project is specified, this is the code for that --
-- project in [[Module:InterwikiTable]]. Otherwise this is nil. --
-- u.projectLong The long project name, e.g. "wikipedia" or "wikibooks". If --
-- not specified the default is "wikipedia". --
-- u.toolLang The language code for use with toolserver or labs tools. The --
-- default is "en". --
-- --
-- If you want more strings, you can define them in the generateUserDataStrings --
Line 48 ⟶ 52:
local function makeCountLink()
return '[//tools.wmflabs.org/xtools/pcount/index.php?name=' .. u.usernameHtml
.. '&lang=' .. u.toolLang
local project▼
.. '&wiki=' .. u.projectLong
.. ' count]'
local prefixes = interwikiTable[u.projectCode].iw_prefix▼
project = prefixes[2] or prefixes[1] -- A bit of a hack, but should find the long prefix name most of the time.▼
else▼
project = 'wikipedia'▼
end▼
▲ return '[//tools.wmflabs.org/xtools/pcount/index.php?name=' .. u.usernameHtml .. '&lang=' .. lang .. '&wiki=' .. project .. ' count]'
end
Line 93 ⟶ 92:
local function makeEditSummariesLink()
return '[http://toolserver.org/~tparis/editsummary/index.php?name=' .. u.usernameHtml
.. '&lang=' .. u.toolLang
.. '&wiki=' .. u.projectLong
.. ' edit summaries]'
end
Line 242 ⟶ 244:
u.lang = pref2
u.projectCode = pref1ProjectCode
table.insert(
trackingCategories,
'[[Category:UserLinks transclusions with project parameters containing language codes]]'
)
elseif pref2IsKnownProject
and mw.language.isKnownLanguageTag(pref1)
Line 249 ⟶ 254:
u.lang = pref1
u.projectCode = pref2ProjectCode
table.insert(
trackingCategories,
'[[Category:UserLinks transclusions with project parameters containing language codes]]'
)
else
return err('"' .. u.project .. '" is not a valid interwiki prefix')
Line 276 ⟶ 284:
-- Generate the other helper strings.
u.usernameHtml = mw.uri.encode(u.username) -- Html-encoded username. Spaces are encoded as pluses.
▲ local prefixes = interwikiTable[u.projectCode].iw_prefix
▲
▲ else
▲ end
u.toolLang = u.lang or 'en' -- set the default language for tools on the toolserver or labs.
end
|