Module:Freeze

local p = {}

function p.main(frame) return p._main(frame, frame:getParent.args) end

function p._main(frame, args) local curTitle = mw.title.getCurrentTitle local page = mw.text.trim(args[1] or '') local text = args[2] or ''

if page == '' or string.sub(page, 1, 1) == '#' then page = curTitle.subjectPageTitle.prefixedText .. page end

if text == '' then text = page .. ' (as of now)' end

local title = mw.title.new(page) if mw.title.equals(title, curTitle) then local pageId = frame:callParserFunction('PAGEID', title.prefixedText) local revTimestamp = frame:callParserFunction('REVISIONTIMESTAMP', title.prefixedText)

pageId = pageId ~= '0' and pageId or '' if mw.isSubsting then return string.format('',				title.fullText, pageId, revTimestamp, text) else local samePageLink = require('Module:Freeze/same page link')._main return samePageLink{title.fullText, pageId, revTimestamp, text} end else local revId = frame:callParserFunction('REVISIONID', title.prefixedText) if revId == '' then return string.format(' Unable to get latest revision ID for "%s". ', title.prefixedText) end if mw.isSubsting then return string.format('', title.fullText, revId, text) else return frame:expandTemplate{title='oldid', args={title.fullText, revId, text}} end end end

return p