💾 Archived View for gemini.conman.org › extensions › GLV-1 › handlers › foo.lua captured on 2021-12-04 at 18:04:22.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

➡️ Next capture (2022-06-04)

-=-=-=-=-=-=-

-- ************************************************************************
--
--    A Foo module to make a pedantic point.
--    Copyright 2019 by Sean Conner.  All Rights Reserved.
--
--    This program is free software: you can redistribute it and/or modify
--    it under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    This program is distributed in the hope that it will be useful,
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--    GNU General Public License for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
--    Comments, questions and criticisms can be sent to: sean@conman.org
--
-- ************************************************************************
-- luacheck: globals init fini handler
-- luacheck: ignore 611

local string = require "string"

_ENV = {}

-- ************************************************************************

function handler(_,_,_,match,ios)
  if (match[2] == "") then
    ios:write(
        "20 text/plain\r\n",
        string.format([[
        
This is a resource that *looks* like a directory, but isn't.  It's fooling
you and you don't like it!

]]))
  else
    ios:write("20 text/temini\r\n",
    string.format([[
    
Guess what?  There *is* an index file here, but there's no file that really
has a name of "%s%s".  Too bad.

=> /    Top Level
=> %s   What might be here?
=> %s%s This page.

]],match[1],match[2],
           match[1],
           match[1],match[2]))
  end
  return 20
end

-- ************************************************************************

return _ENV