Module:UserLinks: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(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: | Line 30: | ||
-- u.projectCode If a valid project is specified, this is the code for that -- |
-- u.projectCode If a valid project is specified, this is the code for that -- |
||
-- project in [[Module:InterwikiTable]]. Otherwise this is nil. -- |
-- 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 -- |
-- If you want more strings, you can define them in the generateUserDataStrings -- |
||
Line 48: | Line 52: | ||
local function makeCountLink() |
local function makeCountLink() |
||
⚫ | |||
local lang = u.lang or 'en' |
|||
.. '&lang=' .. u.toolLang |
|||
⚫ | |||
.. '&wiki=' .. u.projectLong |
|||
if u.project then |
|||
.. ' count]' |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Line 93: | Line 92: | ||
local function makeEditSummariesLink() |
local function makeEditSummariesLink() |
||
return '[http://toolserver.org/~tparis/editsummary/index.php?name=' .. u.usernameHtml |
return '[http://toolserver.org/~tparis/editsummary/index.php?name=' .. u.usernameHtml |
||
.. '&lang=' .. u.toolLang |
|||
.. '&wiki=' .. u.projectLong |
|||
.. ' edit summaries]' |
|||
end |
end |
||
Line 242: | Line 244: | ||
u.lang = pref2 |
u.lang = pref2 |
||
u.projectCode = pref1ProjectCode |
u.projectCode = pref1ProjectCode |
||
table.insert( |
table.insert( |
||
trackingCategories, |
|||
'[[Category:UserLinks transclusions with project parameters containing language codes]]' |
|||
) |
|||
elseif pref2IsKnownProject |
elseif pref2IsKnownProject |
||
and mw.language.isKnownLanguageTag(pref1) |
and mw.language.isKnownLanguageTag(pref1) |
||
Line 249: | Line 254: | ||
u.lang = pref1 |
u.lang = pref1 |
||
u.projectCode = pref2ProjectCode |
u.projectCode = pref2ProjectCode |
||
table.insert( |
table.insert( |
||
trackingCategories, |
|||
'[[Category:UserLinks transclusions with project parameters containing language codes]]' |
|||
) |
|||
else |
else |
||
return err('"' .. u.project .. '" is not a valid interwiki prefix') |
return err('"' .. u.project .. '" is not a valid interwiki prefix') |
||
Line 276: | Line 284: | ||
-- Generate the other helper strings. |
-- Generate the other helper strings. |
||
u.usernameHtml = mw.uri.encode(u.username) -- Html-encoded username. Spaces are encoded as pluses. |
u.usernameHtml = mw.uri.encode(u.username) -- Html-encoded username. Spaces are encoded as pluses. |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
u.toolLang = u.lang or 'en' -- set the default language for tools on the toolserver or labs. |
|||
end |
end |
||