Index: stand/lua/drawer.lua =================================================================== --- stand/lua/drawer.lua +++ stand/lua/drawer.lua @@ -61,6 +61,61 @@ return entry.name end +-- loadDrawerfile will load the file in question and return the environment, +-- or nil and an error. +local function loadDrawerFile(filename) + local env = {} + local chunk, err, filepath, res + + filepath, err = package.searchpath(filename, package.path) + if filepath == nil then + return nil, "Failed to load " .. filename .. ": " .. err + end + + chunk, err = loadfile(filepath, "t", env) + if chunk == nil then + return nil, "Failed to load " .. filename .. ": " .. err + end + + res, err = pcall(chunk) + if not res then + return nil, "Failed to execute " .. filename .. ": " .. err + end + + return env +end + +local function processBrandFile(filename) + if filename == nil then + return 0, "Missing filename" + end + + local env, err = loadDrawerFile(filename) + if env == nil then + return 0, err + end + + for brandname, def in pairs(env) do + drawer.addBrand(brandname, def) + end +end + +local function processLogoFile(filename) + if filename == nil then + return 0, "Missing filename" + end + + local env, err = loadDrawerFile(filename) + if env == nil then + print(err) + return 0, err + end + + for logoname, def in pairs(env) do + drawer.addLogo(logoname, def) + end +end + local function getBranddef(brand) if brand == nil then return nil @@ -70,7 +125,7 @@ -- Try to pull it in if branddef == nil then - try_include('brand-' .. brand) + processBrandFile('brand-' .. brand) branddef = branddefs[brand] end @@ -86,7 +141,7 @@ -- Try to pull it in if logodef == nil then - try_include('logo-' .. logo) + processLogoFile('logo-' .. logo) logodef = logodefs[logo] end Index: stand/lua/logo-beastie.lua =================================================================== --- stand/lua/logo-beastie.lua +++ stand/lua/logo-beastie.lua @@ -27,33 +27,27 @@ -- $FreeBSD$ -- -local drawer = require("drawer") - -local beastie_color = { -" \027[31m, ,", -" /( )`", -" \\ \\___ / |", -" /- \027[37m_\027[31m `-/ '", -" (\027[37m/\\/ \\\027[31m \\ /\\", -" \027[37m/ / |\027[31m ` \\", -" \027[34mO O \027[37m) \027[31m/ |", -" \027[37m`-^--'\027[31m`< '", -" (_.) _ ) /", -" `.___/` /", -" `-----' /", -" \027[33m<----.\027[31m __ / __ \\", -" \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", -" \027[33m<----'\027[31m `--' `.__,' \\", -" | |", -" \\ / /\\", -" \027[36m______\027[31m( (_ / \\______/", -" \027[36m,' ,-----' |", -" `--{__________)\027[m" -} - -drawer.addLogo("beastie", { +beastie = { + graphic = { + " \027[31m, ,", + " /( )`", + " \\ \\___ / |", + " /- \027[37m_\027[31m `-/ '", + " (\027[37m/\\/ \\\027[31m \\ /\\", + " \027[37m/ / |\027[31m ` \\", + " \027[34mO O \027[37m) \027[31m/ |", + " \027[37m`-^--'\027[31m`< '", + " (_.) _ ) /", + " `.___/` /", + " `-----' /", + " \027[33m<----.\027[31m __ / __ \\", + " \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", + " \027[33m<----'\027[31m `--' `.__,' \\", + " | |", + " \\ / /\\", + " \027[36m______\027[31m( (_ / \\______/", + " \027[36m,' ,-----' |", + " `--{__________)\027[m", + }, requires_color = true, - graphic = beastie_color, -}) - -return true +} Index: stand/lua/logo-beastiebw.lua =================================================================== --- stand/lua/logo-beastiebw.lua +++ stand/lua/logo-beastiebw.lua @@ -27,32 +27,26 @@ -- $FreeBSD$ -- -local drawer = require("drawer") - -local beastiebw = { -" , ,", -" /( )`", -" \\ \\___ / |", -" /- _ `-/ '", -" (/\\/ \\ \\ /\\", -" / / | ` \\", -" O O ) / |", -" `-^--'`< '", -" (_.) _ ) /", -" `.___/` /", -" `-----' /", -" <----. __ / __ \\", -" <----|====O)))==) \\) /====|", -" <----' `--' `.__,' \\", -" | |", -" \\ / /\\", -" ______( (_ / \\______/", -" ,' ,-----' |", -" `--{__________)" +beastiebw = { + graphic = { + " , ,", + " /( )`", + " \\ \\___ / |", + " /- _ `-/ '", + " (/\\/ \\ \\ /\\", + " / / | ` \\", + " O O ) / |", + " `-^--'`< '", + " (_.) _ ) /", + " `.___/` /", + " `-----' /", + " <----. __ / __ \\", + " <----|====O)))==) \\) /====|", + " <----' `--' `.__,' \\", + " | |", + " \\ / /\\", + " ______( (_ / \\______/", + " ,' ,-----' |", + " `--{__________)", + }, } - -drawer.addLogo("beastiebw", { - graphic = beastiebw, -}) - -return true Index: stand/lua/logo-fbsdbw.lua =================================================================== --- stand/lua/logo-fbsdbw.lua +++ stand/lua/logo-fbsdbw.lua @@ -27,27 +27,21 @@ -- $FreeBSD$ -- -local drawer = require("drawer") - -local fbsd_logo = { -" ______", -" | ____| __ ___ ___ ", -" | |__ | '__/ _ \\/ _ \\", -" | __|| | | __/ __/", -" | | | | | | |", -" |_| |_| \\___|\\___|", -" ____ _____ _____", -" | _ \\ / ____| __ \\", -" | |_) | (___ | | | |", -" | _ < \\___ \\| | | |", -" | |_) |____) | |__| |", -" | | | |", -" |____/|_____/|_____/" -} - -drawer.addLogo("fbsdbw", { - graphic = fbsd_logo, +fbsdbw = { + graphic = { + " ______", + " | ____| __ ___ ___ ", + " | |__ | '__/ _ \\/ _ \\", + " | __|| | | __/ __/", + " | | | | | | |", + " |_| |_| \\___|\\___|", + " ____ _____ _____", + " | _ \\ / ____| __ \\", + " | |_) | (___ | | | |", + " | _ < \\___ \\| | | |", + " | |_) |____) | |__| |", + " | | | |", + " |____/|_____/|_____/", + }, shift = {x = 5, y = 4}, -}) - -return true +} Index: stand/lua/logo-orb.lua =================================================================== --- stand/lua/logo-orb.lua +++ stand/lua/logo-orb.lua @@ -27,30 +27,24 @@ -- $FreeBSD$ -- -local drawer = require("drawer") - -local orb_color = { -" \027[31m``` \027[31;1m`\027[31m", -" s` `.....---...\027[31;1m....--.``` -/\027[31m", -" +o .--` \027[31;1m/y:` +.\027[31m", -" yo`:. \027[31;1m:o `+-\027[31m", -" y/ \027[31;1m-/` -o/\027[31m", -" .- \027[31;1m::/sy+:.\027[31m", -" / \027[31;1m`-- /\027[31m", -" `: \027[31;1m:`\027[31m", -" `: \027[31;1m:`\027[31m", -" / \027[31;1m/\027[31m", -" .- \027[31;1m-.\027[31m", -" -- \027[31;1m-.\027[31m", -" `:` \027[31;1m`:`", -" \027[31;1m.-- `--.", -" .---.....----.\027[m" -} - -drawer.addLogo("orb", { +orb = { + graphic = { + " \027[31m``` \027[31;1m`\027[31m", + " s` `.....---...\027[31;1m....--.``` -/\027[31m", + " +o .--` \027[31;1m/y:` +.\027[31m", + " yo`:. \027[31;1m:o `+-\027[31m", + " y/ \027[31;1m-/` -o/\027[31m", + " .- \027[31;1m::/sy+:.\027[31m", + " / \027[31;1m`-- /\027[31m", + " `: \027[31;1m:`\027[31m", + " `: \027[31;1m:`\027[31m", + " / \027[31;1m/\027[31m", + " .- \027[31;1m-.\027[31m", + " -- \027[31;1m-.\027[31m", + " `:` \027[31;1m`:`", + " \027[31;1m.-- `--.", + " .---.....----.\027[m", + }, requires_color = true, - graphic = orb_color, shift = {x = 2, y = 4}, -}) - -return true +} Index: stand/lua/logo-orbbw.lua =================================================================== --- stand/lua/logo-orbbw.lua +++ stand/lua/logo-orbbw.lua @@ -27,29 +27,23 @@ -- $FreeBSD$ -- -local drawer = require("drawer") - -local orbbw = { -" ``` `", -" s` `.....---.......--.``` -/", -" +o .--` /y:` +.", -" yo`:. :o `+-", -" y/ -/` -o/", -" .- ::/sy+:.", -" / `-- /", -" `: :`", -" `: :`", -" / /", -" .- -.", -" -- -.", -" `:` `:`", -" .-- `--.", -" .---.....----." -} - -drawer.addLogo("orbbw", { - graphic = orbbw, +orbbw = { + graphic = { + " ``` `", + " s` `.....---.......--.``` -/", + " +o .--` /y:` +.", + " yo`:. :o `+-", + " y/ -/` -o/", + " .- ::/sy+:.", + " / `-- /", + " `: :`", + " `: :`", + " / /", + " .- -.", + " -- -.", + " `:` `:`", + " .-- `--.", + " .---.....----.", + }, shift = {x = 2, y = 4}, -}) - -return true +}