Module:UserLinks: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(save initial version - user talk links only for the moment) |
(output user links) |
||
Line 1: | Line 1: | ||
p = {} |
p = {} |
||
local |
local ToolbarBuilder = require('Module:Toolbar') |
||
local project, username |
local project, username |
||
local function makeUserLink() |
|||
⚫ | |||
end |
|||
local function makeTalkLink() |
local function makeTalkLink() |
||
return '[[' .. project .. 'User talk:' .. username .. '|talk]]' |
|||
⚫ | |||
end |
end |
||
Line 18: | Line 21: | ||
local function makeToolbar(args) |
local function makeToolbar(args) |
||
local targs = {} |
local targs = {} |
||
local numArgsExist = false |
|||
for k, v in pairs(args) do |
for k, v in pairs(args) do |
||
if type(k) == 'number' then |
if type(k) == 'number' then |
||
numArgsExist = true |
|||
targs[k] = getLink(v) |
targs[k] = getLink(v) |
||
end |
end |
||
Line 25: | Line 30: | ||
targs.style = args.small and 'font-size: 90%;' |
targs.style = args.small and 'font-size: 90%;' |
||
targs.separator = args.separator or 'dot' |
targs.separator = args.separator or 'dot' |
||
⚫ | |||
if numArgsExist == false then |
|||
return -- Don't return a toolbar if no numeric arguments exist. |
|||
else |
|||
⚫ | |||
end |
|||
end |
end |
||
local function getLinks(args) |
local function getLinks(args) |
||
-- |
-- Get the username value. If it is absent or blank, return an html error and a tracking category. |
||
if args.user == '' or (not args.user and (not args.User or args.User == '')) then |
if args.user == '' or (not args.user and (not args.User or args.User == '')) then |
||
return '<span class="error">Error: No username detected by [[Module:UserLinks]].</span>[[Category:UserLinks transclusions without usernames]]' |
return '<span class="error">Error: No username detected by [[Module:UserLinks]].</span>[[Category:UserLinks transclusions without usernames]]' |
||
Line 35: | Line 45: | ||
username = args.user or args.User |
username = args.user or args.User |
||
end |
end |
||
-- Get the |
-- Get the project value. |
||
if args.Project then |
|||
project = ':' .. args.Project .. ':' |
|||
else |
|||
separator = args.separator |
|||
project = '' |
|||
end |
|||
⚫ | |||
⚫ | |||
if result then |
|||
if args.sup then |
|||
result = '<sup>' .. result .. '</sup>' |
|||
end |
|||
result = ' ' .. result |
|||
else |
|||
result = '' |
|||
end |
|||
result = '<span>' .. makeUserLink() .. result .. '</span>' |
|||
return result |
|||
end |
end |
||