Commit e03c17d6 authored by jan.koester's avatar jan.koester
Browse files

test

parent 8061ad1d
Loading
Loading
Loading
Loading
+26 −1
Changes for data/template/default/editor.html: 26 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2757,7 +2757,32 @@
                }]);

                const resp = result[0];
                if (resp.status === 'success') {
                if (resp.status === 'duplicate') {
                    // Post with same title exists — ask user to overwrite
                    if (confirm(resp.message || 'A post with this title already exists. Overwrite?')) {
                        params.overwrite = true;
                        const owResult = await sendApiRequest([{
                            command: 'publish',
                            target: targetName,
                            params: params
                        }]);
                        const owResp = owResult[0];
                        if (owResp.status === 'success') {
                            statusEl.textContent = '\u2714 ' + I18N.PUBLISHED;
                            statusEl.className = 'prop-status success';
                            if (owResp.url) {
                                statusEl.innerHTML += ` <a href="${escapeHtml(owResp.url)}" target="_blank" style="color:#93c5fd;text-decoration:underline;">${I18N.VIEW}</a>`;
                            }
                            reloadIframe();
                        } else {
                            statusEl.textContent = owResp.message || I18N.PUBLISH_FAILED;
                            statusEl.className = 'prop-status error';
                        }
                    } else {
                        statusEl.textContent = '';
                        statusEl.className = 'prop-status';
                    }
                } else if (resp.status === 'success') {
                    statusEl.textContent = '\u2714 ' + I18N.PUBLISHED;
                    statusEl.className = 'prop-status success';
                    if (resp.url) {
+41 −1
Changes for plugins/content/content.cpp: 41 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1404,6 +1404,45 @@ namespace blogi {
                    return;
                }

                // Check for existing post with same title
                bool overwrite = false;
                if (params) {
                    json_object *ow_obj = nullptr;
                    if (json_object_object_get_ex(params, "overwrite", &ow_obj)) {
                        overwrite = json_object_get_boolean(ow_obj);
                    }
                }

                sql << "SELECT id FROM content WHERE title='" << dbpp::SQL::escaped(sbuf, title.c_str()) << "' LIMIT 1;";
                int dupCount = Args->database[tid]->exec(sql, res);

                int content_id = 0;

                if (dupCount > 0 && !overwrite) {
                    // Duplicate found — ask user to confirm overwrite
                    json_object_object_add(response, "status", json_object_new_string("duplicate"));
                    json_object_object_add(response, "message",
                        json_object_new_string(tr(_lang,"A post with this title already exists. Overwrite?").c_str()));
                    json_object_object_add(response, "existing_id", json_object_new_int(atoi(res[0][0])));
                    return;
                } else if (dupCount > 0 && overwrite) {
                    // Overwrite existing post
                    content_id = atoi(res[0][0]);
                    sql.clear();
                    sql << "UPDATE content SET descrition='" << dbpp::SQL::escaped(sbuf, description.c_str())
                        << "', text='" << dbpp::SQL::escaped(sbuf, html.c_str())
                        << "', author='" << authorId
                        << "', created='" << time_str.c_str()
                        << "' WHERE id=" << content_id << ";";
                    Args->database[tid]->exec(sql, res);

                    // Remove old tag links
                    sql.clear();
                    sql << "DELETE FROM tags_content WHERE content_id=" << content_id << ";";
                    try { Args->database[tid]->exec(sql, res); } catch (...) {}
                } else {
                    // New post
                    sql.clear();
                    sql << "INSERT INTO content (title,descrition,text,author,created) VALUES ('"
                        << dbpp::SQL::escaped(sbuf, title.c_str()) << "','"
                        << dbpp::SQL::escaped(sbuf, description.c_str()) << "','"
@@ -1411,7 +1450,8 @@ namespace blogi {
                        << time_str.c_str() << "') RETURNING id;";

                    Args->database[tid]->exec(sql, res);
                int content_id = atoi(res[0][0]);
                    content_id = atoi(res[0][0]);
                }

                // Process tags
                if (!tags.empty()) {