Loading data/template/default/index.html +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ <body> <div id="header"> <!-- header image --> <img alt="headerimage" width="1280" height="150" id="banner" src="${LOGO_URL}" > <img alt="headerimage" width="${LOGO_WIDTH}" height="${LOGO_HEIGHT}" id="banner" src="${LOGO_URL}" > </div> <!-- Navbar--> <div id="headnav"> Loading src/theme.cpp +61 −1 Original line number Diff line number Diff line Loading @@ -216,10 +216,17 @@ void blogi::Theme::renderPage(const int tid,const char *name,libhtmlpp::HtmlPage auto pos=temp.end(),epos=temp.begin(); // Map of variables to replace in the HTML template std::string _lang = getLang(*_Config.TDatabase[tid]); // Logo dimensions std::string logoWidth = "1280"; try { getConfig(*_Config.TDatabase[tid], "THEME_LOGO_WIDTH", logoWidth); } catch (...) {} if (logoWidth.empty()) logoWidth = "1280"; std::map<std::string, std::string> variable_map = { {"PREFIX", _Config.config.getprefix()}, {"SITEURL", _Config.config.getsiteurl()}, {"LOGO_URL", getLogoUrl(tid)}, {"LOGO_WIDTH", logoWidth}, {"LOGO_HEIGHT", "auto"}, }; // Inline CSS content as template variables to eliminate render-blocking requests Loading Loading @@ -601,11 +608,51 @@ json_object* blogi::Theme::SettingsTheme(const int tid, libhttppp::HttpRequest & const char *suffixes[] = {"BG","SURFACE","SURFACE_A","TEXT","TEXT_MUTED","ACCENT","ACCENT_DARK","BORDER","BG_ALT","ERROR","ERROR_BG","ERROR_TEXT","SUCCESS_BG","SUCCESS_TEXT","NAV_ACTIVE","NAV_HOVER","NAV_BORDER"}; const char *profiles[] = {"dark", "light"}; // Check for reset / logo delete // Check for reset / logo delete / logo width for(const auto &cur : form.urlData()){ if(cur.key == "theme_reset" && cur.value == "1"){ reset = true; } if(cur.key == "logo_width" && !cur.value.empty()){ int w = std::atoi(cur.value.c_str()); if (w > 0 && w <= 4096) { setConfig(*_Config.TDatabase[tid], "THEME_LOGO_WIDTH", std::to_string(w)); // Register size in media preview allowed sizes table std::string sizesJson; try { getConfig(*_Config.TDatabase[tid], "MEDIA_ALLOWED_SIZES", sizesJson); } catch (...) {} json_object *arr = nullptr; if (!sizesJson.empty()) arr = json_tokener_parse(sizesJson.c_str()); if (!arr || !json_object_is_type(arr, json_type_array)) { if (arr) json_object_put(arr); arr = json_object_new_array(); } // Check if this width already exists (h=0 means auto) bool found = false; size_t alen = json_object_array_length(arr); for (size_t i = 0; i < alen; ++i) { json_object *item = json_object_array_get_idx(arr, i); json_object *jw = nullptr, *jh = nullptr; if (json_object_object_get_ex(item, "w", &jw) && json_object_object_get_ex(item, "h", &jh)) { if (json_object_get_int(jw) == w && json_object_get_int(jh) == 0) { found = true; break; } } } if (!found) { json_object *item = json_object_new_object(); json_object_object_add(item, "w", json_object_new_int(w)); json_object_object_add(item, "h", json_object_new_int(0)); json_object_array_add(arr, item); setConfig(*_Config.TDatabase[tid], "MEDIA_ALLOWED_SIZES", json_object_to_json_string_ext(arr, JSON_C_TO_STRING_NOSLASHESCAPE)); } json_object_put(arr); saved = true; } } if(cur.key == "delete_logo" && !cur.value.empty()){ // Delete logo from mediadb and clear config std::string oldMediaId; Loading Loading @@ -805,6 +852,19 @@ json_object* blogi::Theme::SettingsTheme(const int tid, libhttppp::HttpRequest & json_object_object_add(jf, "label", json_object_new_string("Upload Logo")); json_object_array_add(jfields, jf); } // Logo width { std::string curWidth = "1280"; try { getConfig(*_Config.TDatabase[tid], "THEME_LOGO_WIDTH", curWidth); } catch (...) {} if (curWidth.empty()) curWidth = "1280"; json_object *jf = json_object_new_object(); json_object_object_add(jf, "name", json_object_new_string("logo_width")); json_object_object_add(jf, "type", json_object_new_string("number")); json_object_object_add(jf, "label", json_object_new_string("Logo Width (px) — height auto-calculated")); json_object_object_add(jf, "value", json_object_new_string(curWidth.c_str())); json_object_array_add(jfields, jf); } // Delete logo checkbox (only if a logo is set) { std::string curMediaId; Loading Loading
data/template/default/index.html +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ <body> <div id="header"> <!-- header image --> <img alt="headerimage" width="1280" height="150" id="banner" src="${LOGO_URL}" > <img alt="headerimage" width="${LOGO_WIDTH}" height="${LOGO_HEIGHT}" id="banner" src="${LOGO_URL}" > </div> <!-- Navbar--> <div id="headnav"> Loading
src/theme.cpp +61 −1 Original line number Diff line number Diff line Loading @@ -216,10 +216,17 @@ void blogi::Theme::renderPage(const int tid,const char *name,libhtmlpp::HtmlPage auto pos=temp.end(),epos=temp.begin(); // Map of variables to replace in the HTML template std::string _lang = getLang(*_Config.TDatabase[tid]); // Logo dimensions std::string logoWidth = "1280"; try { getConfig(*_Config.TDatabase[tid], "THEME_LOGO_WIDTH", logoWidth); } catch (...) {} if (logoWidth.empty()) logoWidth = "1280"; std::map<std::string, std::string> variable_map = { {"PREFIX", _Config.config.getprefix()}, {"SITEURL", _Config.config.getsiteurl()}, {"LOGO_URL", getLogoUrl(tid)}, {"LOGO_WIDTH", logoWidth}, {"LOGO_HEIGHT", "auto"}, }; // Inline CSS content as template variables to eliminate render-blocking requests Loading Loading @@ -601,11 +608,51 @@ json_object* blogi::Theme::SettingsTheme(const int tid, libhttppp::HttpRequest & const char *suffixes[] = {"BG","SURFACE","SURFACE_A","TEXT","TEXT_MUTED","ACCENT","ACCENT_DARK","BORDER","BG_ALT","ERROR","ERROR_BG","ERROR_TEXT","SUCCESS_BG","SUCCESS_TEXT","NAV_ACTIVE","NAV_HOVER","NAV_BORDER"}; const char *profiles[] = {"dark", "light"}; // Check for reset / logo delete // Check for reset / logo delete / logo width for(const auto &cur : form.urlData()){ if(cur.key == "theme_reset" && cur.value == "1"){ reset = true; } if(cur.key == "logo_width" && !cur.value.empty()){ int w = std::atoi(cur.value.c_str()); if (w > 0 && w <= 4096) { setConfig(*_Config.TDatabase[tid], "THEME_LOGO_WIDTH", std::to_string(w)); // Register size in media preview allowed sizes table std::string sizesJson; try { getConfig(*_Config.TDatabase[tid], "MEDIA_ALLOWED_SIZES", sizesJson); } catch (...) {} json_object *arr = nullptr; if (!sizesJson.empty()) arr = json_tokener_parse(sizesJson.c_str()); if (!arr || !json_object_is_type(arr, json_type_array)) { if (arr) json_object_put(arr); arr = json_object_new_array(); } // Check if this width already exists (h=0 means auto) bool found = false; size_t alen = json_object_array_length(arr); for (size_t i = 0; i < alen; ++i) { json_object *item = json_object_array_get_idx(arr, i); json_object *jw = nullptr, *jh = nullptr; if (json_object_object_get_ex(item, "w", &jw) && json_object_object_get_ex(item, "h", &jh)) { if (json_object_get_int(jw) == w && json_object_get_int(jh) == 0) { found = true; break; } } } if (!found) { json_object *item = json_object_new_object(); json_object_object_add(item, "w", json_object_new_int(w)); json_object_object_add(item, "h", json_object_new_int(0)); json_object_array_add(arr, item); setConfig(*_Config.TDatabase[tid], "MEDIA_ALLOWED_SIZES", json_object_to_json_string_ext(arr, JSON_C_TO_STRING_NOSLASHESCAPE)); } json_object_put(arr); saved = true; } } if(cur.key == "delete_logo" && !cur.value.empty()){ // Delete logo from mediadb and clear config std::string oldMediaId; Loading Loading @@ -805,6 +852,19 @@ json_object* blogi::Theme::SettingsTheme(const int tid, libhttppp::HttpRequest & json_object_object_add(jf, "label", json_object_new_string("Upload Logo")); json_object_array_add(jfields, jf); } // Logo width { std::string curWidth = "1280"; try { getConfig(*_Config.TDatabase[tid], "THEME_LOGO_WIDTH", curWidth); } catch (...) {} if (curWidth.empty()) curWidth = "1280"; json_object *jf = json_object_new_object(); json_object_object_add(jf, "name", json_object_new_string("logo_width")); json_object_object_add(jf, "type", json_object_new_string("number")); json_object_object_add(jf, "label", json_object_new_string("Logo Width (px) — height auto-calculated")); json_object_object_add(jf, "value", json_object_new_string(curWidth.c_str())); json_object_array_add(jfields, jf); } // Delete logo checkbox (only if a logo is set) { std::string curMediaId; Loading