Module:User:Kai/sandbox: Difference between revisions

No edit summary
No edit summary
Line 20: Line 20:
     local parent = frame:getParent()
     local parent = frame:getParent()
     local args = parent and parent.args or frame.args
     local args = parent and parent.args or frame.args
     return p._main(frame, args)
     return p._main(args)
end
end


function p._main(frame, args)
function p._main(args)
     local feedback = args.feedback or "No feedback provided"
     local feedback = args.feedback or "No feedback provided"
     local user = args.user or "Anonymous"
     local user = args.user or "Anonymous"
Line 30: Line 30:
     local currentPage = mw.title.getCurrentTitle().fullText
     local currentPage = mw.title.getCurrentTitle().fullText


     -- Write to Bucket database
     -- Write directly to the Bucket database
     -- Syntax equivalent to: {{#bucket:Feedback|page=...|user=...|status=...|feedback=...}}
     if mw.ext and mw.ext.bucket then
    local bucketOutput = frame:callParserFunction('#bucket', {
        mw.ext.bucket('feedback').put({
        'Feedback',
            page = currentPage,
        'page=' .. currentPage,
            user = user,
        'user=' .. user,
            status = statusStr,
        'status=' .. statusStr,
            feedback = feedback
        'feedback=' .. feedback
        })
    })
    end


     -- HTML presentation
     -- Build HTML display
     local root = mw.html.create('div')
     local root = mw.html.create('div')
         :addClass('feedback-box')
         :addClass('feedback-box')
Line 73: Line 73:
     local category = resolved and '[[Category:Resolved Feedback]]' or '[[Category:Unresolved Feedback]]'
     local category = resolved and '[[Category:Resolved Feedback]]' or '[[Category:Unresolved Feedback]]'


     return bucketOutput .. tostring(root) .. category
     return tostring(root) .. category
end
end


return p
return p