bsw/jbe@1309: slot.set_layout(nil, "text/css") bsw/jbe@1309: bsw/jbe@1309: local style = execute.chunk{ module = "style", chunk = "_style", params = { style = config.style } } bsw/jbe@1309: bsw/jbe@1309: local scss = [[ bsw/jbe@1309: @import "../style/mdl/color-definitions"; bsw/jbe@1309: $color-primary: ]] .. style.color.primary .. [[; bsw/jbe@1309: $color-primary-dark: ]] .. style.color.primary .. [[; bsw/jbe@1309: $color-primary-contrast: ]] .. style.color.primary_contrast .. [[; bsw/jbe@1309: $color-accent: ]] .. style.color.accent .. [[; bsw/jbe@1309: $color-accent-contrast: ]] .. style.color.accent_contrast .. [[; bsw/jbe@1309: $checkbox-image-path: "]] .. request.get_absolute_baseurl() .. "static/mdl" .. [["; bsw/jbe@1309: @import "../style/mdl/material-design-lite" bsw/jbe@1309: ]] bsw/jbe@1309: bsw/jbe@1309: local key = extos.crypt(json.export(style.color), "$1$12345678") -- TODO hash function bsw/jbe@1309: local filename_scss = encode.file_path(WEBMCP_BASE_PATH, 'tmp', "style-" .. key .. ".scss") bsw/jbe@1309: local filename_css = encode.file_path(WEBMCP_BASE_PATH, 'tmp', "style-" .. key .. ".css") bsw/jbe@1309: bsw/jbe@1309: local css_file = io.open(filename_css, "r") bsw/jbe@1309: bsw/jbe@1309: if not config.css then bsw/jbe@1309: config.css = {} bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: if not config.css[key] then bsw/jbe@1309: if css_file then bsw/jbe@1309: config.css[key] = css_file:read("*a") bsw/jbe@1309: else bsw/jbe@1309: local scss_file = assert(io.open(filename_scss, "w")) bsw/jbe@1309: scss_file:write(scss) bsw/jbe@1309: scss_file:write("\n") bsw/jbe@1309: scss_file:close() bsw/jbe@1309: bsw/jbe@1309: local output, err, status = extos.pfilter(nil, "sassc", filename_scss) bsw/jbe@1309: if status ~= 0 then bsw/jbe@1309: error(err) bsw/jbe@1309: end bsw/jbe@1309: config.css[key] = output bsw/jbe@1309: local css_file = assert(io.open(filename_css, "w")) bsw/jbe@1309: css_file:write(config.css[key]) bsw/jbe@1309: css_file:close() bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: slot.put_into("data", config.css[key]) bsw/jbe@1309: