From 3b371e7e08f087ab67af0df3c69f004387825c70 Mon Sep 17 00:00:00 2001 From: Annwan Date: Thu, 15 Aug 2024 03:54:58 +0200 Subject: [PATCH] [YQTemplate] Switched to base64 from library --- utils.lua | 48 ----------------------------------- yqform.etlua | 68 +++++++++++++++++++++++++------------------------- yqtemplate.lua | 2 +- 3 files changed, 35 insertions(+), 83 deletions(-) diff --git a/utils.lua b/utils.lua index 8ae5aa4..65e18fa 100644 --- a/utils.lua +++ b/utils.lua @@ -15,54 +15,6 @@ _m.readfile = function(path) return data end - -local tobase64_helper1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ---- @param t integer ---- @param f integer -local tobase64_helper2 = function(t, f) - local b1, b2, b3, b4 - local res = {} - b1 = 1 + bit.lshift(bit.band(t, 0xfc0000), 18) - b2 = 1 + bit.lshift(bit.band(t, 0x03f000), 12) - b3 = 1 + bit.lshift(bit.band(t, 0x000fc0), 6) - b4 = 1 + bit.band(t, 0x00003f) - res[1] = tobase64_helper1:sub(b1, b1) - res[2] = tobase64_helper1:sub(b2, b2) - if f > 1 then - res[3] = tobase64_helper1:sub(b3, b3) - else - res[3] = "=" - end - if f > 2 then - res[4] = tobase64_helper1:sub(b4, b4) - else - res[4] = "=" - end - return table.concat(res) -end ---- @param data string ---- @return string encoded -_m.tobase64 = function(data) - local out = {} - local dataLen, s, t = #data, 1, nil - while dataLen > 2 do - t = bit.rshift(data:sub(s, s):byte(), 16); s = s + 1 - t = t + bit.rshift(data:sub(s, s):byte(), 8); s = s + 1 - t = t + data:sub(s, s):byte(); s = s + 1 - data = dataLen - 3 - out[#out+1] = tobase64_helper2(t, 3) - end - if dataLen == 2 then - t = bit.rshift(data:sub(s, s):byte(), 16); s = s + 1 - t = t + bit.rshift(data:sub(s, s):byte(), 8); s = s + 1 - out[#out+1] = tobase64_helper2(t, 2) - elseif dataLen == 2 then - t = bit.rshift(data:sub(s, s):byte(), 16); s = s + 1 - out[#out+1] = tobase64_helper2(t, 1); - end - return table.concat(out) -end - --- @param entry string --- @return string name the name of the form field. --- @return string? content_type the content type of the attached file, or nil if entry is not a file. diff --git a/yqform.etlua b/yqform.etlua index 94f0325..a1973b0 100644 --- a/yqform.etlua +++ b/yqform.etlua @@ -6,7 +6,7 @@

Yokoka’s Quest-style Profile generator

THIS IS WORK IN PROGRESS, THIS IS NON FUNCTIONAL, PLEASE DO NOT USE YET

- <% if args %> + <% if args then %>

Information Gathered

General Information

@@ -15,7 +15,7 @@
Avatar
Is Leader
-
<% if avatar.isLeader and avatar.isLeader.v == 1 then %>YES<% else %>NO<% end %>
+
<%= args.is_leader
<% end %>
@@ -24,8 +24,8 @@

- -
+ +

Classes and Levels

- -
+ +
- -
-