Module:Feedback
Jump to navigation
Jump to search
-- Taken from https://oldschool.runescape.wiki/w/Module:Feedback, version 14834384 saved by BigDiesel2m. Full list of authors available on https://oldschool.runescape.wiki/w/Module:Feedback?action=history. CC BY-NC-SA 3.0 - https://creativecommons.org/licenses/by-nc-sa/3.0/.
local pt = require('Module:Paramtest')
local yn = require('Module:Yesno')
local p = {}
p.yn = yn
function p.main(frame)
return p._main(frame:getParent().args)
end
function p._main(args)
local isResolved = false
if pt.has_content(args.resolved) then
isResolved = yn(args.resolved)
end
local comment = pt.default_to(args.feedback, "''No comment provided''")
local id = pt.default_to(args.id, '')
local fbdate = nil
if pt.has_content(args.date) then
fbdate = args.date
end
local lang = mw.getContentLanguage()
local signature = ' --[[User:FeedbackBot|FeedbackBot]] ' .. lang:formatDate('H:i, j xg Y (e)', '@'..string.sub(fbdate,0,-4))
comment = comment:gsub('%s*%-%-%[%[User:FeedbackBot|FeedbackBot%]%] %(%[%[User talk:FeedbackBot|talk%]%]%) %d%d:%d%d, %d%d? [A-Z][a-z]+ %d%d%d%d %(UTC%)$', '')
local outDiv = mw.html.create('div')
outDiv:addClass('tile gloop-feedback-wrapper')
:attr('id', 'gloop-feedback-scrollto-'..id)
:attr('data-id', id)
:css({
['margin-bottom'] = '0.75em'
})
local toggleDiv = outDiv:tag('div')
toggleDiv:css({
['float'] = 'right',
['padding'] = '0.25em 0.5em',
['border-radius'] = '5px',
['font-size'] = '0.85em',
['font-weight'] = '800',
['margin'] = '0 0 10px 10px'
})
if isResolved then
toggleDiv:addClass('tc-yes gloop-feedback-resolve-toggle')
:tag('span'):wikitext('Resolved[[Category:Pages with resolved feedback]]')
else
toggleDiv:addClass('tc-no gloop-feedback-resolve-toggle')
:tag('span'):wikitext('Unresolved[[Category:Pages with unresolved feedback]]')
end
outDiv:newline():newline()
outDiv:tag('div')
:addClass('gloop-feedback-comment')
:wikitext(comment .. signature)
-- 1 => talk
if mw.title.getCurrentTitle().namespace == 1 then
mw.smw.subobject({
['Feedback resolved'] = tostring(isResolved),
['Feedback comment'] = mw.text.nowiki(comment),
['Feedback ID'] = id,
['Feedback timestamp'] = fbdate
})
end
return tostring(outDiv)
end
function p.list(frame)
return p._list(frame:getParent().args)
end
function p._list(args)
local query = {
'[[Feedback ID::+]]',
'?Feedback ID',
'?Feedback comment',
'?Feedback resolved',
'?Feedback timestamp',
'?#-=',
sort='Feedback timestamp',
order='desc',
limit = 5000
}
if pt.has_content(args.page) then
table.insert(query, 2, '[[Talk:'..args.page..']]')
end
local resolvedfilter = '[[Feedback resolved::false]]'
if pt.has_content(args.show) then
if string.lower(args.show) == 'resolved' then
resolvedfilter = '[[Feedback resolved::true]]'
elseif string.lower(args.show) == 'all' then
resolvedfilter = '[[Feedback resolved::+]]'
end
end
table.insert(query, 2, resolvedfilter)
local data = mw.smw.ask(query)
if data == nil then
return tostring('No feedback to display.')
end
local lang = mw.getContentLanguage()
local outT = mw.html.create('table')
local header = outT:addClass('wikitable sortable sticky-header align-center-2')
:tag('tr')
:tag('th')
:wikitext('Page')
:css({ ['width'] = '300px' })
:done()
:tag('th')
:wikitext('Date')
:css({ ['width'] = '115px' })
:done()
:tag('th')
:wikitext('Feedback')
:done()
if pt.has_content(args.show) and string.lower(args.show) == 'all' then
header:tag('th'):wikitext('Resolved'):done()
end
for i,v in ipairs(data) do
local tr = outT:newline():tag('tr')
local pagename = string.gsub(v[1], '^Talk:(.*)#.*$', '%1')
local fbdate = v['Feedback timestamp']
local fbsort = 0
if fbdate then
fbsort = fbdate
fbdate = lang:formatDate('Y-m-d', '@'..string.sub(fbdate,0,-4))
else
fbdate = ''
end
tr :tag('td')
:wikitext('[['..pagename..']]' .. ' ([[Talk:'..pagename..'#gloop-feedback-scrollto-'..v['Feedback ID']..'|talk]])'):done()
:tag('td')
:attr('data-sort-value', fbsort):wikitext(fbdate):done()
:tag('td')
:wikitext(v['Feedback comment']):done()
if pt.has_content(args.show) and string.lower(args.show) == 'all' then
if yn(v['Feedback resolved']) then
tr:tag('td'):wikitext('[[File:BlockSprite test-block-accept.png|15px|class=pixel-image|link=]]')
else
tr:tag('td'):wikitext('[[File:BlockSprite test-block-accept.png|15px|class=pixel-image|link=]]')
end
end
end
return tostring(outT)
end
return p