diff options
author | sanine <sanine.not@pm.me> | 2023-09-19 00:40:39 +0000 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-09-19 00:40:39 +0000 |
commit | ebf33ac8f69d636eea0e4ff50d8a516223484631 (patch) | |
tree | f2f22727f3b718b2e5cdd9842ab2469f812ca7dd /yarrow-ui.cgi | |
parent | ef8fcc0889fe217c3170f45644e108ff61e666a0 (diff) |
add ui bugfixesmain
Diffstat (limited to 'yarrow-ui.cgi')
-rwxr-xr-x | yarrow-ui.cgi | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/yarrow-ui.cgi b/yarrow-ui.cgi index 2cbcb6a..c9906ff 100755 --- a/yarrow-ui.cgi +++ b/yarrow-ui.cgi @@ -40,21 +40,21 @@ local stat = { languages = (query.stat_languages ~= '' and query.stat_languages) or '', cr = (query.stat_cr ~= '' and query.stat_cr) or '', - traits = (query.stat_traits ~= '' and query.stat_traits) or [[@New Trait + traits = query.stat_traits or [[@New Trait Add a named trait with an at sign. All lines following until the next at sign will be part of the trait description! @Second Trait This is a different trait. ]], - actions = (query.stat_actions ~= '' and query.stat_actions) or [[ + actions = query.stat_actions or [[ @New Action Actions (and reactions and legendary actions) use the same syntax as traits. As well, in all of them you can add *italics* and **bold** text! ]], - reactions = (query.stat_reactions ~= '' and query.stat_reactions) or '', - legendary_description = (query.stat_legendary_description ~= '' and query.stat_legendary_description) or '', - legendary = (query.stat_legendary ~= '' and query.stat_legendary) or '', + reactions = query.stat_reactions or '', + legendary_description = query.stat_legendary_description or '', + legendary = query.stat_legendary or '', } @@ -70,6 +70,7 @@ local function parse_traits(str) for name, value in string.gmatch(str, '@([^@]-)\n([^@]+)') do table.insert(tbl, {name=clean(name), value=clean(value)}) end + if #tbl == 0 then return nil end return tbl end local function convert(stats) @@ -79,9 +80,15 @@ local function convert(stats) tbl[k] = v end end - tbl.traits = parse_traits(stats.traits) - tbl.actions = parse_traits(stats.actions) - tbl.reactions = parse_traits(stats.reactions) + if tbl.traits ~= '' then + tbl.traits = parse_traits(stats.traits) + else tbl.traits = nil end + if tbl.traits ~= '' then + tbl.actions = parse_traits(stats.actions) + else tbl.actions = nil end + if tbl.reactions ~= '' then + tbl.reactions = parse_traits(stats.reactions) + else tbl.reactions = nil end if stats.legendary ~= '' then tbl.legendary = {} tbl.legendary.description = stats.legendary_description @@ -187,11 +194,6 @@ local head = h('head', { }) -local traits = parse_traits(stat.traits) -local traits_elements = {} -for _, t in ipairs(traits) do - table.insert(traits_elements, h('p', string.format('%s -> %s', t.name, t.value))) -end local body = h('body', { form_basic, img, |