diff options
author | alyx <alyx@aleteoryx.me> | 2024-04-06 18:18:35 -0400 |
---|---|---|
committer | alyx <alyx@aleteoryx.me> | 2024-04-06 18:18:35 -0400 |
commit | ff0d799cf0e5aaa23596cb27153738ce7add16ec (patch) | |
tree | 871c2923db787b3b30bedc4f42eb3c199de8f08f /src | |
parent | b2e4abd6c4d0e3a05437d33707df6d15ee3a41f9 (diff) | |
download | lfm_embed-ff0d799cf0e5aaa23596cb27153738ce7add16ec.tar.gz lfm_embed-ff0d799cf0e5aaa23596cb27153738ce7add16ec.tar.bz2 lfm_embed-ff0d799cf0e5aaa23596cb27153738ce7add16ec.zip |
Document lua, fix small theme bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/theming/hbs/plain.hbs | 4 | ||||
-rw-r--r-- | src/theming/lua.rs | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/theming/hbs/plain.hbs b/src/theming/hbs/plain.hbs index 975d6c5..b3c0abf 100644 --- a/src/theming/hbs/plain.hbs +++ b/src/theming/hbs/plain.hbs @@ -13,8 +13,8 @@ a { color: cyan; } {{/if}} * { font-size: {{#if font}}17px{{else}}{{#if font.scale}}calc(20px * {{font.scale}}){{else}}20px{{/if}}{{/if}}; } - {{#if (or font.name font.css)}} - * { font-family: '{{#if font.name}}{{font.name}}{{/if}}' } + {{#if font.name}} + * { font-family: '{{font.name}}' } {{/if}} p { margin: 0px; padding: 0px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } </style> diff --git a/src/theming/lua.rs b/src/theming/lua.rs index 0699f09..118762b 100644 --- a/src/theming/lua.rs +++ b/src/theming/lua.rs @@ -4,7 +4,7 @@ use std::path::Path; use std::fs; use std::sync::Mutex; -use mlua::{Lua, LuaSerdeExt, Compiler, StdLib, Value, LuaOptions, Table}; +use mlua::{Lua, LuaSerdeExt, Compiler, StdLib, Value, LuaOptions, Table, SerializeOptions}; use http::StatusCode; use crate::CONFIG; @@ -115,7 +115,12 @@ pub fn render_theme(name: &str, ctx: &crate::ctx::Ctx) -> Option<Result<String, Err(e) => { log::error!("Error loading `{name}`: {e}"); return Some(Err(StatusCode::INTERNAL_SERVER_ERROR)); }, //TODO: gate behind flag } - let ctx = match lua.to_value(ctx) { + let opts = SerializeOptions::new() + .serialize_none_to_null(false) + .serialize_unit_to_null(false) + .set_array_metatable(false); + + let ctx = match lua.to_value_with(ctx, opts) { Ok(ok) => ok, Err(e) => { log::error!("Lua context serialization error: {e}"); |