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 count link
(bug fix in error function) |
(add support for different projects in the edit count link) |
||
Line 28:
-- values, separated by colons, e.g. ":wikt:es:". If no project --
-- or language values are found, this is the blank string, "". --
-- u.projectCode If a valid project is specified, this is the code for that --
-- project in [[Module:InterwikiTable]]. Otherwise this is nil. --
-- --
-- If you want more strings, you can define them in the generateUserDataStrings --
Line 46 ⟶ 48:
local function makeCountLink()
local lang = u.lang or 'en'
return '[//tools.wmflabs.org/xtools/pcount/index.php?name=' .. u.usernameHtml .. '&lang=en&wiki=wikipedia count]'▼
local project
if u.project then
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=
end
Line 211 ⟶ 221:
table.insert( trackingCategories, '[[Category:UserLinks transclusions with project parameters]]' )
-- If u.project is a known project, we
-- isn't known, first check whether it is a valid language code, and if not then see if it's
-- an interwiki code separated by colons, e.g. "wikt:es".
if uprojectIsKnownProject then
u.projectCode = uprojectProjectCode
else
if mw.language.isKnownLanguageTag(u.project) then
u.lang = u.project
Line 228 ⟶ 241:
u.project = pref1
u.lang = pref2
u.projectCode = pref1ProjectCode
table.insert( trackingCategories, '[[Category:UserLinks transclusions with project parameters containing language codes]]' )
elseif pref2IsKnownProject
Line 234 ⟶ 248:
u.project = pref2
u.lang = pref1
u.projectCode = pref2ProjectCode
table.insert( trackingCategories, '[[Category:UserLinks transclusions with project parameters containing language codes]]' )
else
|