From e2cec10466338b78e1b180096026eb265bf981dc Mon Sep 17 00:00:00 2001 From: Annwan Date: Thu, 15 Aug 2024 01:55:44 +0200 Subject: [PATCH] [YQTemplate] Properly hydrate form --- utils.lua | 4 ++++ yqtemplate.lua | 58 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/utils.lua b/utils.lua index 61f1bb6..7359afa 100644 --- a/utils.lua +++ b/utils.lua @@ -63,5 +63,9 @@ _m.tobase64 = function(data) return table.concat(out) end +_m.parse_form_entry = function(data) + + +end return _m diff --git a/yqtemplate.lua b/yqtemplate.lua index 950a24f..b3d289e 100644 --- a/yqtemplate.lua +++ b/yqtemplate.lua @@ -6,21 +6,47 @@ local yqtemplateform = utils.readfile("yqform.etlua") local form = etlua.compile(yqtemplateform) return { - desc = "Creates Yokoka’s quest-style personal status page", - run = function(fcgi) - fcgi.print("Content-Type: text/html; charset=utf-8\r\n\r\n") - local data = "" - if fcgi.getenv("REQUEST_METHOD") == "POST" then - local content_type = fcgi.getenv("CONTENT_TYPE") - local boundary = content_type:match("; boundary=(.*)$") - local post_data = fcgi.post() - data = "Content type:" .. content_type .. "\n Boundary: "..boundary.."\n" - local args = {} - for w in string.gmatch(post_data, "(.-)"..boundary) do - args[#args+1] = w - end - data = table.concat(args, "\n\n") + desc = "Creates Yokoka’s quest-style personal status page", + run = function(fcgi) + fcgi.print("Content-Type: text/html; charset=utf-8\r\n\r\n") + local data = "" + --[[if fcgi.getenv("REQUEST_METHOD") == "POST" then + local content_type = fcgi.getenv("CONTENT_TYPE") + local boundary = content_type:match("; boundary=(.*)$") + local post_data = fcgi.post() + data = "Content type:" .. content_type .. "\n Boundary: " .. boundary .. "\n" + local args = {} + for w in string.gmatch(post_data, "(.-)" .. boundary) do + local dataheaders, _ = utils.parse_form_entry(w) + args[#args + 1] = dataheaders + end + data = table.concat(args, "\n\n") + end ]] + fcgi.print( + form { + data = data, + classes = { + "Beast", + "Swordsman", + "Spirit Bird", + "Twin Blades", + "Healer", + "Summoner", + "Tamer", + "Pugilist", + "Mounted Fighter", + "Fruit Animal", + "Spellcaster" + }, + elements = { + "Fire", "Water", "Earth", "Air", + "Wood", "Electricity", "Metals", "Dreams", + "Light", "Darkness", "Sun", "Moon", + "Smoke", "Ice", "Crystal", "Sound", + "Poison", "Lightning", "Weapons", "Fortune", + "Healing", "Curses", "Day", "Night" + } + } + ) end - fcgi.print(form{data = data}) - end }