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

test

parent 005a583a
Loading
Loading
Loading
Loading
+13 −2
Changes for src/blogi.cpp: 13 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -1905,13 +1905,22 @@ RETRY_REQUEST:
                bool mobile=false;

                std::string rootel;

                std::string publishTarget;
                json_object *publishParams = nullptr;

                for(const auto &curdat : renderopts.urlData()){
                    if(curdat.key=="mobile" && curdat.value=="true"){
                        mobile=true;
                    }else if(curdat.key=="rootel"){
                        rootel=curdat.value;
                    }else if(curdat.key=="target"){
                        publishTarget=curdat.value;
                    }else if(curdat.key!="authid"){
                        // Collect remaining params for the publish preview
                        if(!publishParams)
                            publishParams = json_object_new_object();
                        json_object_object_add(publishParams, curdat.key.c_str(),
                            json_object_new_string(curdat.value.c_str()));
                    }
                }

@@ -1927,7 +1936,9 @@ RETRY_REQUEST:
                        curplg->getInstace()->Rendering(tid,curreq,&index,RenderingType::Desktop);
                }

                testedit->Renderer(curreq,tid,sessid,index,rootel);
                testedit->Renderer(curreq,tid,sessid,index,rootel,BlogiPlg.get(),publishTarget,publishParams);
                if(publishParams)
                    json_object_put(publishParams);
                return;
            }

+29 −2
Changes for src/edit.cpp: 29 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2887,7 +2887,10 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
void blogi::webedit::WebEditor::Renderer(
    libhttppp::HttpRequest& curreq, const int tid,
    const std::string &sessionid,const libhtmlpp::HtmlElement &index,
    const std::string &rootEl
    const std::string &rootEl,
    Plugin *plugins,
    const std::string &publishTarget,
    json_object *publishParams
){
    libhtmlpp::HtmlString out;
    libhtmlpp::HtmlElement ridx=index;
@@ -2908,7 +2911,30 @@ void blogi::webedit::WebEditor::Renderer(
            root->appendChild(globalStyle);
        }

        // Render user-created document elements (if any)
        if (!publishTarget.empty() && plugins) {
            // Render widget tree to HTML string, then pass through target plugin's RenderPublished
            std::string renderedHtml;
            if (DocRoot) {
                libhtmlpp::HtmlElement wrapper("div");
                const EditPlugin *el = DocRoot;
                while (el) {
                    el->Render(wrapper);
                    el = el->nextElement();
                }
                libhtmlpp::HtmlString htmlOut;
                libhtmlpp::print(wrapper, htmlOut);
                renderedHtml = htmlOut.str();
            }

            for (const Plugin::PluginData *curplg = plugins->getFirstPlugin(); curplg; curplg = curplg->getNextPlg()) {
                PluginApi *api = curplg->getInstace();
                if (api && api->canPublish() && api->getName() == publishTarget) {
                    api->RenderPublished(tid, renderedHtml, publishParams, ridx);
                    break;
                }
            }
        } else {
            // Default: render widgets directly into root element
            if (DocRoot) {
                const EditPlugin *el = DocRoot;
                while (el) {
@@ -2917,6 +2943,7 @@ void blogi::webedit::WebEditor::Renderer(
                }
            }
        }
    }

    Args.theme->printSite(tid,out,&ridx,curreq.getRequestURL(),false);