💾 Archived View for gemini.conman.org › extensions › GLV-1 › handlers › size.lua captured on 2021-12-04 at 18:04:22.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
-- ************************************************************************ -- -- Generate X bytes of content. -- 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 handler -- luacheck: ignore 611 631 -- RFC-3875 local math = require "math" local tonumber = tonumber _ENV = {} local text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sodales eget nisi quis condimentum. Donec ipsum arcu, fermentum eu ullamcorper sit amet, facilisis id nunc. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam tempus nulla ut dolor luctus malesuada. Suspendisse orci sem, semper at maximus non, pharetra et justo. Quisque lectus arcu, viverra ac convallis eu, vulputate ut enim. Nulla aliquam, lacus consequat suscipit facilisis, nisl tortor facilisis nisi, vel mattis eros arcu sed tellus. Duis quis lectus pellentesque, posuere dolor ut, sodales massa. Proin vel blandit mauris.\n\n" function handler(_,_,_,match,ios) ios:write("20 text/gemini\r\n") local size = tonumber(match[1]) or 1024 if size < 0 then size = 1024 end while size > 0 do local len = math.min(size,#text) ios:write(text:sub(1,len)) size = size - len end ios:write("\r\n") return 20 end return _ENV