function output_filter()

in config/attic_filter.lua [33:105]


function output_filter(r)
    
    if not r.content_type:match("text/html") then return end

    
    local host = r.hostname:match("^([^.]+)")

    
    if host == 'localhost'
    then
        host = os.getenv('VAR_NAME') or 'unknown'
    end

    
    local divstyle = 'font-size:x-large;padding:15px;color:white;background:red;z-index:99;' ;
    local astyle = 'color:white;text-decoration:underline' ;
    local div = ([[
      <div style='%s'>
        This project has retired. For details please refer to its
        <a style='%s' href="https://attic.apache.org/projects/%s.html">
        Attic page</a>.
      </div>]]):format(divstyle, astyle, host)

    
    local divnew = ([[
      <div style='%s'>
        This project has retired. For details please refer to its
        <a style='%s' href="https://attic.apache.org/projects/%s.html" target="_blank">
        Attic page</a>.
      </div>]]):format(divstyle, astyle, host)

    
    
    if host == 'predictionio' or host == 'eagle' or host == 'metamodel' or host == 'mxnet' or host == 'twill'
    then
        coroutine.yield('')
    else
        coroutine.yield(div)
    end

    
    while bucket ~= nil do
        
        if host == 'predictionio'
        then
            local output = bucket:gsub('<header>', '<header>'..div, 1)
            coroutine.yield(output)
        elseif host == 'mxnet'
        then
            local output = bucket:gsub('</header>', div..'</header>', 1)
            coroutine.yield(output)
        elseif host == 'twill'
        then
            
            
            local output = bucket:gsub('</header>', div..'</header>', 1):gsub('<div class="topNav">', divnew..'<div class="topNav">', 1)
            coroutine.yield(output)
        elseif host == 'eagle'
        then
            local output = bucket:gsub('</nav>', '</nav>'..div, 1)
            coroutine.yield(output)
        elseif host == 'metamodel'
        then
            local output = bucket:gsub('</nav>', div..'</nav>', 1):gsub('<div class="topNav">', divnew..'<div class="topNav">', 1)
            coroutine.yield(output)
        else
            coroutine.yield(bucket)
        end
    end

    

end