Anonymous user
Module:UserLinks: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
fix bug where the username error wasn't showing up properly, add more comments
(add the rest of the link types, remove wiki-encoded username as I ended up not using it at all) |
(fix bug where the username error wasn't showing up properly, add more comments) |
||
Line 160:
local function generateUserDataStrings(args)
▲ -- Username helper strings --
-- 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▼
return '<span class="error">Error: No username detected by [[Module:UserLinks]].</span>[[Category:UserLinks transclusions without usernames]]'▼
else▼
▲ u.username = args.user or args.User
u.usernameHtml = mw.uri.encode(u.username) -- Html-encoded username. Spaces are encoded as pluses.
▲ -- Project helper strings --
▲ u.project = args.Project -- Get the project value.
u.projectColon = (u.project and (':' .. args.Project .. ':')) or '' -- Project value plus colons, for escaping interwiki links.
u.project = u.project or '' -- Control for nil values of args.Project.
Line 180 ⟶ 170:
local function getLinks(args)
▲ --
generateUserDataStrings(args)▼
▲ 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]]'
-- Generate the user data strings.
▲ generateUserDataStrings(args)
-- Build the template output.
local result = makeToolbar(args) -- Get the toolbar contents.
if result then
if args.sup then
Line 189 ⟶ 185:
result = ' ' .. result
else
result = '' -- If there are no links specified, don't return the toolbar at all.
end
result = '<span>' .. makeUserLink() .. result .. '</span>'
|