Commit 8a350a66 authored by jan.koester's avatar jan.koester
Browse files

test

parent 7840f9e7
Loading
Loading
Loading
Loading
+129 −0
Changes for data/template/default/editor.html: 129 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -359,6 +359,39 @@
        }
        .tpl-modal input:focus, .tpl-modal textarea:focus { outline: none; border-color: #3b82f6; }
        .tpl-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

        /* Theme color swatches */
        .theme-swatch {
            width: 32px; height: 32px;
            border-radius: 6px;
            border: 2px solid #4b5563;
            cursor: pointer;
            transition: transform 0.12s, border-color 0.15s;
            position: relative;
        }
        .theme-swatch:hover {
            transform: scale(1.15);
            border-color: #93c5fd;
            z-index: 1;
        }
        .theme-swatch[title]::after {
            content: '';
        }
        .theme-swatch-label {
            font-size: 9px;
            text-align: center;
            color: #9ca3af;
            max-width: 40px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .swatch-wrap {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 2px;
        }
    </style>
</head>
<body class="bg-gray-800 text-gray-100">
@@ -456,6 +489,13 @@
                    <p class="text-sm italic text-gray-500">Select a widget to edit its properties.</p>
                </div>
            </div>

            <!-- Theme Color Palette ("Farbwahl") -->
            <div id="theme-palette" class="bg-gray-800 p-4 rounded-lg shadow-inner mt-4">
                <h3 class="font-bold text-purple-300 mb-2">Farbwahl</h3>
                <p class="text-xs text-gray-500 mb-2">Theme-Farben &ndash; klicken um in aktives Farbfeld zu &uuml;bernehmen.</p>
                <div id="theme-swatches" style="display:flex; flex-wrap:wrap; gap:6px;"></div>
            </div>
        </div>

        <!-- Preview Area (Right Panel) -->
@@ -2111,6 +2151,94 @@
            }
        });

        // --- Theme Color Palette ("Farbwahl") ---
        // Active color input that will receive the swatch value
        let _activeColorInput = null;

        // Track which color input was last focused
        document.addEventListener('focusin', function(e) {
            if (e.target && e.target.type === 'color' && e.target.classList.contains('prop-input')) {
                _activeColorInput = e.target;
            }
        });

        /**
         * Reads CSS custom properties from :root and builds clickable swatches.
         */
        function initThemeSwatches() {
            const container = document.getElementById('theme-swatches');
            if (!container) return;

            const themeVars = [
                { var: '--blogi-bg',         label: 'BG' },
                { var: '--blogi-surface',    label: 'Surface' },
                { var: '--blogi-text',       label: 'Text' },
                { var: '--blogi-accent',     label: 'Accent' },
                { var: '--blogi-nav-active', label: 'Nav' },
                { var: '--blogi-nav-hover',  label: 'Hover' },
                { var: '--blogi-nav-border', label: 'Border' },
            ];

            const rootStyles = getComputedStyle(document.documentElement);
            let html = '';

            for (const tv of themeVars) {
                const raw = rootStyles.getPropertyValue(tv.var).trim();
                if (!raw) continue;
                html += '<div class="swatch-wrap">';
                html += `<div class="theme-swatch" style="background:${raw};" title="${tv.label}: ${raw}" data-color="${raw}" onclick="applySwatchColor(this)"></div>`;
                html += `<span class="theme-swatch-label">${tv.label}</span>`;
                html += '</div>';
            }

            container.innerHTML = html || '<p class="text-xs text-gray-600 italic">Keine Theme-Farben gefunden.</p>';
        }

        /**
         * Called when a swatch is clicked.
         * Applies the color to the last-focused color input, or opens a copy prompt.
         */
        function applySwatchColor(el) {
            const raw = el.dataset.color;
            if (!raw) return;

            // Try to convert to hex for <input type="color">
            const hex = colorToHex(raw);

            if (_activeColorInput && !_activeColorInput.disabled) {
                _activeColorInput.value = hex || raw;
                _activeColorInput.dispatchEvent(new Event('input', { bubbles: true }));
                _activeColorInput.dispatchEvent(new Event('change', { bubbles: true }));
                // Uncheck the "none" checkbox if present
                const noneBox = document.getElementById(_activeColorInput.id + '-none');
                if (noneBox && noneBox.checked) {
                    noneBox.checked = false;
                    _activeColorInput.disabled = false;
                    _activeColorInput.style.opacity = '1';
                    delete _activeColorInput.dataset.noneVal;
                }
            } else {
                // No active color input, copy to clipboard
                navigator.clipboard.writeText(raw).then(() => {
                    el.style.borderColor = '#22c55e';
                    setTimeout(() => { el.style.borderColor = ''; }, 600);
                });
            }
        }

        /**
         * Convert any CSS color string to hex #RRGGBB using a canvas.
         */
        function colorToHex(color) {
            try {
                const ctx = document.createElement('canvas').getContext('2d');
                ctx.fillStyle = color;
                return ctx.fillStyle; // Returns #rrggbb
            } catch (e) {
                return null;
            }
        }

        // Initial setup - Direct initialization
        window.onload = () => {
            setView(false); // Default to desktop view on load
@@ -2118,6 +2246,7 @@
            initDocumentTree(); // Load the document structure tree
            handleElementSelection(currentSelectedElementId); // Initial selection state
            loadTemplateList(); // Auto-load templates on startup
            initThemeSwatches(); // Populate theme color palette
        };
    </script>
</body>
+33 −66
Changes for data/template/default/public/mstyle.css: 33 added lines, 66 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ body {
}

#searchresult li {
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  margin:2em 1em;
}

@@ -17,7 +17,7 @@ body {
}

#searchbar {
   background: rgb(255,255,255);
   background: var(--blogi-text);
   border-radius:5px;
   display:inline-block;
   padding:1vh 0;
@@ -38,7 +38,7 @@ body {

#header {
   width:100%;
   background: rgb(49, 54, 59);
   background: var(--blogi-surface);
   position:fixed;
   top: 0px;
}
@@ -53,7 +53,7 @@ body {
     top:3.5em;
     text-align:left;
     position:fixed;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
}
 
#headnav a{
@@ -95,7 +95,7 @@ body {
    display:block;
    text-align:center;
    bottom:0px;
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    width:100%;
}

@@ -113,20 +113,20 @@ body {
}

#headnav li:hover {
    background:rgb(35, 38, 41);
    background:var(--blogi-nav-hover);
    border-top: solid 1px transparent;
    border-bottom: solid 1px transparent;
}

#headnav li.active {
    border-top: solid 1px rgb(61, 174, 233);
    background:rgb(35, 38, 39);
    border-right:solid 1px rgb(34, 37, 41);
    border-top: solid 1px var(--blogi-nav-active);
    background:var(--blogi-bg);
    border-right:solid 1px var(--blogi-nav-border);
    border-bottom: solid 1px transparent;
}

#headnav li.inactive {
    border-top:solid 1px rgb(35, 38, 39);
    border-top:solid 1px var(--blogi-bg);
    border-bottom: solid 1px transparent;    
}

@@ -135,18 +135,18 @@ body {
}

#headnav a:link {
    color:rgb(238, 238, 238);
    color:var(--blogi-text);
    text-decoration: none;
}

#headnav a:visited {
    color:rgb(238, 238, 238);
    color:var(--blogi-text);
    text-decoration: none;
}

body {
    color: rgb(238, 238, 238);
    background: rgb(35, 38, 39);
    color: var(--blogi-text);
    background: var(--blogi-bg);
    margin:0;
    padding:0;
    font-size:min(1.0em);
@@ -155,7 +155,7 @@ body {

a {
    text-decoration: none;
    color: rgb(58,212, 58);
    color: var(--blogi-accent);
    font-size:min(1.5em);
}

@@ -164,12 +164,12 @@ a {
}

.blog_adminmenu {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    margin:20px 0px;
}

.blog_entry {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    margin:20px 0px;
}

@@ -188,7 +188,7 @@ a {

#idxtags {
    text-align:center;
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    width:100%;
}

@@ -206,68 +206,35 @@ a {

#idxtags a{
    text-decoration:none;
    color:rgb(255, 255, 255);
    color:var(--blogi-text);
}

.staticpage {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
}

.gameserver {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    margin:20px 0;
}

.kinfo {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    width:100%;
}

.projects {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    width:100%;
    margin:20px 0;
}

#pager {
  background: #31363B;
  background: var(--blogi-surface);
  text-align: center;
}

#settings {
    background: rgb(49, 54, 59);
    margin:20px 0;
}
 
#settings table{
    width: 100%; 
    background: rgb(49, 54, 59); 
    margin:0;
}
 
#setnav {
    font-size: 1.5em;
    width:15%;
    padding:0;
    margin:0;
}

#setnav ul{
   list-style: none;
   padding: 0;
   margin: 0;
}

#setnav li {
        list-style: none;
        background: rgb(35, 38, 39);
        height: 1.5em;
        border-top: solid rgb(49, 54, 59) 0.5em;
        border-bottom: solid rgb(49, 54, 59) 0.5em;
        width: 90%;
        text-align: center;
        font-size: 1.0em;
}
/* settings styles are now inline in the modal */

.upreview{
    display: flex;
@@ -311,25 +278,25 @@ a {
  left: 0%;
  right: 0%;
  z-index: 100;
  color: rgb(58,212, 58);
  color: var(--blogi-accent);
  opacity: 1;
  background: rgb(0,0,0);
  padding: 20px;
  border-top: solid rgb(49, 54, 59) 1em;
  border-left: solid rgb(49, 54, 59) 1em;
  border-right: solid rgb(49, 54, 59) 1em;
  border-top: solid var(--blogi-surface) 1em;
  border-left: solid var(--blogi-surface) 1em;
  border-right: solid var(--blogi-surface) 1em;
}

#cookiecontent button {
  background: none;
  color: rgb(58,212, 58);
  border: double rgb(58,212, 58) 0.3em;
  color: var(--blogi-accent);
  border: double var(--blogi-accent) 0.3em;
  margin: 1em;
}

#contactform {
  width: 95%;
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  margin: auto;
}

@@ -349,7 +316,7 @@ a {
}

.back_content {
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  padding: 0.5vh;
  margin-left:5vw;
}     
+42 −45
Changes for data/template/default/public/style.css: 42 added lines, 45 removed lines.
Original line number Diff line number Diff line
#contactform {
  width: 100%;
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  margin: 2em 0;
}

@@ -22,7 +22,7 @@
}

#searchresult li {
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  margin:2em 1em;
}

@@ -34,7 +34,7 @@
   #header {
      min-width:1024px;
      width:100%;
      background: rgb(49, 54, 59, 0.7);
      background: var(--blogi-surface-a);
   }

   #header img {
@@ -73,7 +73,7 @@
   #idxtags {
     text-align:center;
     float: left;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
     width:260px;
     margin:30px 0 30px 10px;
   }
@@ -100,7 +100,7 @@
     display:block;
     text-align:center;
     bottom:0px;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
     min-width:1024px;
     width:100%;
     height:50px;
@@ -116,7 +116,7 @@
   #header {
      min-width:1440px;
      width:100%;
      background: rgb(49, 54, 59, 0.7);
      background: var(--blogi-surface-a);
   }
 
   #header img {
@@ -155,7 +155,7 @@
   #idxtags {
     text-align:center;
     float: left;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
     width:360px;
     margin:30px 0 30px 10px;
   }
@@ -182,7 +182,7 @@
     display:block;
     text-align:center;
     bottom:0px;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
     min-width:1440px;
     width:100%;
     height:50px;
@@ -198,10 +198,7 @@
  #header {
      min-width:3000px;
      width:100%;
      background: rgb(49, 54, 59, 0.7);
   }

   #header img {
      background: var(--blogi-surface-a);
      width:3000px;
      height:320px;
   }
@@ -237,7 +234,7 @@
  #idxtags {
     text-align:center;
     float: left;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
     width:460px;
     margin:30px 0 30px 10px;
  }
@@ -263,7 +260,7 @@
     display:block;
     text-align:center;
     bottom:0px;
     background: rgb(49, 54, 59);
     background: var(--blogi-surface);
     min-width:3000px;
     width:100%;
     height:50px;
@@ -281,27 +278,27 @@
}

#headnav li.inactive:hover {
    background:rgb(35, 38, 41);
    border-top: solid 1px rgb(58, 212, 58);
    background:var(--blogi-nav-hover);
    border-top: solid 1px var(--blogi-accent);
}

#headnav li.active {
    border-top: solid 1px rgb(61, 174, 233);
    background:rgb(35, 38, 39);
    border-right:solid 1px rgb(34, 37, 41);
    border-top: solid 1px var(--blogi-nav-active);
    background:var(--blogi-bg);
    border-right:solid 1px var(--blogi-nav-border);
}

#headnav li.inactive {
    border-top:solid 1px rgb(35, 38, 39) transparent;
    border-top:solid 1px var(--blogi-bg) transparent;
}

#headnav a:link {
    color:rgb(238, 238, 238);
    color:var(--blogi-text);
    text-decoration: none;
}

#headnav a:visited {
    color:rgb(238, 238, 238);
    color:var(--blogi-text);
    text-decoration: none;
}

@@ -310,8 +307,8 @@
}

body {
    color: rgb(238, 238, 238);
    background: rgb(35, 38, 39) no-repeat url("background.webp");
    color: var(--blogi-text);
    background: var(--blogi-bg) no-repeat url("background.webp");
    background-size:cover;
    margin:0;
    padding:0;
@@ -319,7 +316,7 @@ body {

a {
    text-decoration: none;
    color: rgb(58,212, 58);
    color: var(--blogi-accent);
}

#footer a.footer {
@@ -327,7 +324,7 @@ a {
}

.blog_adminmenu {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    margin:20px 0px;
}

@@ -337,7 +334,7 @@ a {

.title {
    display:block; padding: 10px 0px;
    background: rgb(49, 54, 59, 0.7);
    background: var(--blogi-surface-a);
    width: 60%;
    border-radius: 0 10px 0 0;
    padding: 5px 2em 0;
@@ -364,33 +361,33 @@ a {
#idxtags a{
    display: inline-block;
    text-decoration:none;
    color:rgb(255, 255, 255);
    color:var(--blogi-text);
    font-size: 1.0em;
    margin: 10px;
}

.staticpage {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
}

.gameserver {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    margin:20px 0;
}

.kinfo {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    width:100%;
}

.projects {
    background: rgb(49, 54, 59);
    background: var(--blogi-surface);
    width:100%;
    margin:20px 0;
}

#pager {
  background: #31363B;
  background: var(--blogi-surface);
  text-align: center;
}

@@ -421,19 +418,19 @@ a {
}

#nginxfiler {
    background: rgb(49, 54, 59);   
    background: var(--blogi-surface);   
    margin: 20px 0;
}

.youtiem_head {
  display: block;
  margin: 40px;
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  padding: 10px;
}

#youtube-pl li {
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  text-align: center;
  padding: 20px;
  margin: 40px 40px 40px 80px;
@@ -457,19 +454,19 @@ a {
  left: 35%;
  right: 35%;
  z-index: 100;
  color: rgb(58,212, 58);
  color: var(--blogi-accent);
  opacity: 1;
  background: rgb(0,0,0);
  padding: 20px;
  border-top: solid rgb(49, 54, 59) 1em;
  border-left: solid rgb(49, 54, 59) 1em;
  border-right: solid rgb(49, 54, 59) 1em;
  border-top: solid var(--blogi-surface) 1em;
  border-left: solid var(--blogi-surface) 1em;
  border-right: solid var(--blogi-surface) 1em;
}

#cookiecontent button {
  background: none;
  color: rgb(58,212, 58);
  border: double rgb(58,212, 58) 0.3em;
  color: var(--blogi-accent);
  border: double var(--blogi-accent) 0.3em;
  margin: 1em;
}

@@ -487,14 +484,14 @@ a {
}

.blog_entry_idx_content {
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  padding: 5px 3em 0;
}

#headnav {
  width: 100%;
  margin: 0px auto;
  background: rgba(49, 54, 59);
  background: var(--blogi-surface);
}

.readmore {
@@ -509,6 +506,6 @@ a {
}

.back_content {
  background: rgb(49, 54, 59);
  background: var(--blogi-surface);
  padding: 0.5vh;
}
+81 −2
Changes for src/blogi.cpp: 81 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -114,7 +114,12 @@ blogi::Blogi::Blogi(std::vector<netplus::socket*> serversocket,bool debug) : Htt
    optsql << "CREATE TABLE IF NOT EXISTS options ("
               << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY,"
               << "key character varying(255) NOT NULL,"
               << "value character varying(255) NOT NULL);";
               << "value character varying(255) NOT NULL);"
           << "CREATE TABLE IF NOT EXISTS theme_colors ("
               << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY,"
               << "profile character varying(32) NOT NULL,"
               << "variable character varying(64) NOT NULL,"
               << "value character varying(64) NOT NULL);";

    try{
        initdb->exec(optsql,optres);
@@ -819,6 +824,72 @@ void blogi::Blogi::settingsApi(libhttppp::HttpRequest& curreq,const int tid,cons
    json_object_put(jresponse);
}

static json_object* SettingsLanguage(dbpp::Database &db, libhttppp::HttpRequest &req){
    std::string lang = "en";
    bool saved = false;

    libhttppp::HttpForm langform;
    langform.parse(req);

    for(const auto &cur : langform.urlData()){
        if(cur.key == "language"){
            blogi::setConfig(db, "LANGUAGE", cur.value);
            saved = true;
        }
    }

    try {
        blogi::getConfig(db, "LANGUAGE", lang);
    } catch(...){
        lang = "en";
    }

    json_object *jroot = json_object_new_object();
    json_object_object_add(jroot, "title", json_object_new_string("Language"));

    if(saved){
        json_object_object_add(jroot, "message", json_object_new_string("Saved!"));
        json_object_object_add(jroot, "message_type", json_object_new_string("success"));
    }

    json_object *jform = json_object_new_object();
    json_object_object_add(jform, "method", json_object_new_string("POST"));
    json_object_object_add(jform, "action", json_object_new_string(req.getRequestURL().c_str()));

    json_object *jfields = json_object_new_array();

    // Language selector
    {
        json_object *jf = json_object_new_object();
        json_object_object_add(jf, "name", json_object_new_string("language"));
        json_object_object_add(jf, "label", json_object_new_string("Language / Sprache"));
        json_object_object_add(jf, "type", json_object_new_string("select"));
        json_object_object_add(jf, "value", json_object_new_string(lang.c_str()));
        json_object *opts = json_object_new_array();

        json_object *o1 = json_object_new_object();
        json_object_object_add(o1, "value", json_object_new_string("de"));
        json_object_object_add(o1, "label", json_object_new_string("Deutsch"));
        if(lang == "de") json_object_object_add(o1, "selected", json_object_new_boolean(1));
        json_object_array_add(opts, o1);

        json_object *o2 = json_object_new_object();
        json_object_object_add(o2, "value", json_object_new_string("en"));
        json_object_object_add(o2, "label", json_object_new_string("English"));
        if(lang == "en") json_object_object_add(o2, "selected", json_object_new_boolean(1));
        json_object_array_add(opts, o2);

        json_object_object_add(jf, "options", opts);
        json_object_array_add(jfields, jf);
    }

    json_object_object_add(jform, "fields", jfields);
    json_object_object_add(jform, "submit", json_object_new_string("save"));
    json_object_object_add(jroot, "form", jform);

    return jroot;
}

void blogi::Blogi::Settings(libhttppp::HttpRequest& curreq,const int tid,const std::string &sessiondid){
    libhttppp::HttpCookie cookie;
    cookie.parse(curreq);
@@ -857,6 +928,12 @@ void blogi::Blogi::Settings(libhttppp::HttpRequest& curreq,const int tid,const s
        if(url.compare(0, PlgArgs->config->buildurl("settings/mail").length(),
           PlgArgs->config->buildurl("settings/mail")) == 0){
            jformdata = SettingsMail(*PlgArgs->database[tid], curreq, sessiondid);
        }else if(url.compare(0, PlgArgs->config->buildurl("settings/theme").length(),
           PlgArgs->config->buildurl("settings/theme")) == 0){
            jformdata = PlgArgs->theme->SettingsTheme(tid, curreq);
        }else if(url.compare(0, PlgArgs->config->buildurl("settings/language").length(),
           PlgArgs->config->buildurl("settings/language")) == 0){
            jformdata = SettingsLanguage(*PlgArgs->database[tid], curreq);
        }else{
            bool found = false;
            for(const blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){
@@ -1025,7 +1102,9 @@ void blogi::Blogi::Settings(libhttppp::HttpRequest& curreq,const int tid,const s
    <<     "Einstellungen"
    <<   "</div>"
    <<   "<ul class=\"set-nav\" id=\"set-nav\">"
    <<     "<li data-url=\"" << PlgArgs->config->buildurl("settings/mail") << "\">Mail</li>";
    <<     "<li data-url=\"" << PlgArgs->config->buildurl("settings/mail") << "\">Mail</li>"
    <<     "<li data-url=\"" << PlgArgs->config->buildurl("settings/theme") << "\">Theme</li>"
    <<     "<li data-url=\"" << PlgArgs->config->buildurl("settings/language") << "\">Language</li>";

    for(const blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){
        if(curplg->getInstace()->haveSettings()){
+2 −0
Changes for src/edit.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -187,6 +187,8 @@ void blogi::webedit::WebEditor::Editor(libhttppp::HttpRequest& curreq, const int

    Args.theme->renderPage(tid,"editor.html",editpage,edithtml);

    Args.theme->injectThemeColors(tid, &edithtml);

    libhtmlpp::print(edithtml,ouput,false);

    libhttppp::HttpResponse curres;
Loading