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

prefix fixed

parent 364f4ca2
Loading
Loading
Loading
Loading
+7 −0
Changes for editor/documentmanager.cpp: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -154,6 +154,12 @@ bool DocumentManager::importHtml(const QString &html) {
    return importXml(QString::fromStdString(xmlStr));
}

void DocumentManager::propagatePrefix(const std::string &prefix) {
    for (auto *el : _ownedElements) {
        if (el) el->setInstancePrefix(prefix);
    }
}

QString DocumentManager::renderToHtml() {
    if (!_docRoot) return {};

@@ -268,6 +274,7 @@ EditPlugin *DocumentManager::createPluginByName(const std::string &name) {
        if (plgName == lowerName) {
            EditPlugin *inst = p->createNewInstance();
            if (inst) {
                inst->setInstancePrefix(EditPlugin::getStaticPrefix());
                _ownedElements.push_back(inst);
                return inst;
            }
+3 −0
Changes for editor/documentmanager.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -59,6 +59,9 @@ public:
    bool importHtml(const QString &html);
    QString renderToHtml();

    /* Propagate prefix to all widget instances */
    void propagatePrefix(const std::string &prefix);

    /* Plugin info */
    QString getPluginTypes() const;

+1 −0
Changes for editor/edit.cpp: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -427,6 +427,7 @@ blogi::webedit::EditPlugin* blogi::webedit::WebEditor::createPluginByName(const
    if (pd) {
        EditPlugin *newInst = pd->createNewInstance();
        if (newInst) {
            newInst->setInstancePrefix(Args.config->getprefix());
            // Take ownership
            DocElements.emplace_back(newInst);
            return newInst;
+2 −0
Changes for editor/localapi.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -786,6 +786,7 @@ void LocalApi::connectToServer(const QString &url, const QString &user, const QS
    QString path = qurl.path();
    if (path.endsWith('/')) path.chop(1);
    blogi::webedit::EditPlugin::setPrefix(path.toStdString());
    _doc->propagatePrefix(path.toStdString());

    if (user.isEmpty()) {
        /* No credentials — verify server is reachable */
@@ -819,6 +820,7 @@ void LocalApi::disconnectServer() {
    _pub->setServerUrl("");
    _pub->setAuthToken("");
    blogi::webedit::EditPlugin::setPrefix("");
    _doc->propagatePrefix("");
    emit connectionStatusChanged(false, "Disconnected");
    emit statusMessage("Disconnected from server");
}
+10 −1
Changes for src/plugin.h: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -252,10 +252,18 @@ namespace blogi {
                _Prefix = prefix;
            }

            static const std::string& getPrefix() {
            static const std::string& getStaticPrefix() {
                return _Prefix;
            }

            const std::string& getPrefix() const {
                return _instancePrefix.empty() ? _Prefix : _instancePrefix;
            }

            void setInstancePrefix(const std::string &prefix) {
                _instancePrefix = prefix;
            }

            virtual ~EditPlugin()=default;

            virtual const std::string getName() const =0;
@@ -314,6 +322,7 @@ namespace blogi {
            uuid::uuid                              Id;
            EditPlugin* nextel=nullptr;
            EditPlugin* child=nullptr;
            std::string                             _instancePrefix;
            static inline std::string               _Prefix;
            friend class EditPluginLoad;
        };