ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 3d831cc1199d1eee2ec640dd1b5d5e4dd13dd2e0
parent 91ef49131ef720880e0ec56814cfe81080553d40
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Fri, 19 Jan 2018 19:37:05 -0500

Start a url shortener funciton.

Diffstat:
Mfunctions/ferron-utils.lua | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/functions/ferron-utils.lua b/functions/ferron-utils.lua @@ -9,4 +9,36 @@ function ferronutils.sethtmlpath(folder) return Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML .. folder end +function ferronutils.shorturl() + -- ShortURL <https://github.com/delight-im/ShortURL/blob/master/JavaScript/ShortURL.js> + local alphabet = "23456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ-_" + local base = alphabet:len() + + local function encode(num) + local str = "" + + while num > 0 do + str = string.char(num % base) + str; + num = math.floor(num / base); + end + + print(str) + + return str + end + + + local function decode() + print("Decode!!", base) + end + + if f == "encode" then + return encode(p) + elseif f == "decode" then + return decode(p) + else + return encode(p) + end +end + return ferronutils