|
|
| (3 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| local p = {}
| | This page is protected from editing. Please see [[Deadlock:User pages]]. |
| | |
| local function isTruthy(v)
| |
| if v == nil then
| |
| return false
| |
| end
| |
| v = mw.text.trim(tostring(v)):lower()
| |
| return v ~= '' and v ~= '0' and v ~= 'false' and v ~= 'no' and v ~= 'off'
| |
| end
| |
| | |
| local function formatUser(user)
| |
| user = mw.text.trim(tostring(user or ''))
| |
| | |
| if user == '' or user:lower() == 'anonymous' then
| |
| return 'Anonymous'
| |
| end
| |
| | |
| return string.format('[[User:%s|%s]]', user, user)
| |
| end
| |
| | |
| function p.main(frame)
| |
| local parent = frame:getParent()
| |
| local args = parent and parent.args or frame.args
| |
| return p._main(args)
| |
| end
| |
| | |
| function p._main(args)
| |
| local feedback = args.feedback or "No feedback provided"
| |
| local user = args.user or "Anonymous"
| |
| local resolved = isTruthy(args.resolved)
| |
| | |
| local root = mw.html.create('div')
| |
| :addClass('feedback-box')
| |
| :addClass(resolved and 'feedback-box--resolved' or 'feedback-box--unresolved')
| |
| | |
| local meta = root:tag('div')
| |
| :addClass('feedback-meta')
| |
| | |
| meta:tag('span')
| |
| :addClass('feedback-user')
| |
| :wikitext(formatUser(user))
| |
| | |
| meta:tag('span')
| |
| :addClass('feedback-separator')
| |
| :wikitext(' • ')
| |
| | |
| meta:tag('span')
| |
| :addClass('feedback-status')
| |
| :addClass(resolved and 'feedback-status--resolved' or 'feedback-status--unresolved')
| |
| :wikitext(resolved and 'Resolved' or 'Unresolved')
| |
| | |
| root:tag('div')
| |
| :addClass('feedback-body')
| |
| :wikitext(feedback) -- Removed mw.text.encode so it stops breaking text
| |
| | |
| -- If it is NOT resolved, build the message and category directly in Lua
| |
| if not resolved then
| |
| root:tag('div')
| |
| :css('font-size', '13px')
| |
| :css('display', 'block')
| |
| :css('opacity', '0.7')
| |
| :css('margin-bottom', '10px')
| |
| :wikitext('If this feedback has been resolved, edit this page and change <code>|resolved=false</code> to <code>|resolved=true</code>.')
| |
| end
| |
| | |
| local output = tostring(root)
| |
|
| |
| -- Add category if not resolved
| |
| if not resolved then
| |
| output = output .. '[[Category:Unresolved Feedback]]'
| |
| end
| |
| | |
| return output
| |
| end
| |
| | |
| return p
| |
This page is protected from editing. Please see Deadlock:User pages.