Module:Freeze/same page link: Difference between revisions
Appearance
Content deleted Content added
PleaseStand (talk | contribs) fix silly mistake |
PleaseStand (talk | contribs) move code back from Module:Freeze |
||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
function p. |
function p.main(frame) |
||
⚫ | |||
local query = string.format('action=history&offset=%s&limit=2', offset) |
|||
local url = tostring(mw.uri.fullUrl(page, query)) |
|||
⚫ | |||
end |
end |
||
function p. |
function p._main(args) |
||
local page = mw.text.trim(args[1] or '') |
|||
⚫ | |||
local pageId = mw.text.trim(args[2] or '') |
|||
local revTimestamp = mw.text.trim(args[3] or '') |
|||
local text = args[4] or '' |
|||
local title = page ~= '' and mw.title.new(page) or mw.title.getCurrentTitle() |
|||
title.fragment = '' |
|||
local queryParts = {'action=history'} |
|||
if pageId ~= '' then |
|||
table.insert(queryParts, 'curid=' .. pageId) |
|||
end |
|||
if revTimestamp ~= '' then |
|||
table.insert(queryParts, 'offset=' .. revTimestamp) |
|||
end |
|||
table.insert(queryParts, 'limit=2') |
|||
local url = title:fullUrl(table.concat(queryParts, '&')) |
|||
⚫ | |||
end |
end |
||
Latest revision as of 00:41, 7 February 2024
local p = {}
function p.main(frame)
return p._main(frame:getParent().args)
end
function p._main(args)
local page = mw.text.trim(args[1] or '')
local pageId = mw.text.trim(args[2] or '')
local revTimestamp = mw.text.trim(args[3] or '')
local text = args[4] or ''
local title = page ~= '' and mw.title.new(page) or mw.title.getCurrentTitle()
title.fragment = ''
local queryParts = {'action=history'}
if pageId ~= '' then
table.insert(queryParts, 'curid=' .. pageId)
end
if revTimestamp ~= '' then
table.insert(queryParts, 'offset=' .. revTimestamp)
end
table.insert(queryParts, 'limit=2')
local url = title:fullUrl(table.concat(queryParts, '&'))
return string.format('<span class="plainlinks">[%s %s]</span>', url, text)
end
return p