Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a22c8cf7efbe1709

Jump to content

Module:Sandbox/Matroc/Misc

From Wikipedia, the free encyclopedia
local p = {}
 
function p.reverse( frame )
    astring = frame.args[1] or ""
    return astring:reverse()
end

function p.padleft( frame )
    astring = frame.args[1] or ""
    char = frame.args[2] or "."
    len = frame.args[3] or #astring
    astring = astring .. string.rep(char, len - #astring)
    return astring
end
function p.padright( frame)
    astring = frame.args[1] or ""
    char = frame.args[2] or "."
    len = frame.args[3] or #astring
    astring = string.rep(char, len - #astring) .. astring
    return astring    
 end
 
function p.trimleft ( frame )
     astring = frame.args[1] or ""
     astring = astring:match'^%s*(.*)'
     return astring
 end
 function p.trimright ( frame )
     astring = frame.args[1] or ""
     astring = astring:match'^(.*%S)'
     return astring
 end
 
 function p.trimboth ( frame )
    astring = frame.args[1] or ""
    astring = astring:match'^%s*(.*%S)'
    return astring
end
function p.getname(frame)
	local name=mw.wikibase.getEntityIdForTitle(frame.args[1])
	if name == "" or name == nil then return "" end
	return name
end

 function p.getdisplay(frame)
 	local page=frame.args['page']

        local title = mw.title.new(page)
        if title == nil then return end

        if title.id == 0 then
            return "Page does not exist!"
        end

        local data = title:getContent()

        if string.find(data,'.*\{\{DISPLAYTITLE:') == 1 then
             data = string.gsub(data,'.*\{\{DISPLAYTITLE:',"",1)
             data = string.gsub(data,'\}\}.*','',1)
             data = string.gsub(data,'\|.*','') -- incase | noerror or |noreplace
        else
        	data = "No Display Title"
        end
        
        
    	return data
end

return p