Commit 200d1bda authored by jan.koester's avatar jan.koester
Browse files

test

parent 7c254dae
Loading
Loading
Loading
Loading
+21 −0
Changes for plugins/staticpage/static.cpp: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -615,6 +615,27 @@ bool blogi::StaticPage::canPublish(){
    return true;
}

void blogi::StaticPage::RenderPublished(const int /*tid*/, const std::string &html,
                                        json_object * /*params*/, libhtmlpp::HtmlElement &page){
    libhtmlpp::HtmlElement *main = page.getElementbyID("main");
    if (!main) return;

    libhtmlpp::HtmlString condat;
    condat << "<div id=\"content\" class=\"staticpage\">"
           << html
           << "</div>";
    try {
        main->insertChild(condat.parse());
    } catch (libhtmlpp::HTMLException &e) {
        std::cerr << "staticpage: RenderPublished HTML error: " << e.what() << std::endl;
        libhtmlpp::HtmlElement content("div");
        content.setAttribute("id","content");
        content.setAttribute("class","staticpage");
        content.appendChild(libhtmlpp::TextElement(html.c_str()));
        main->appendChild(content);
    }
}

json_object* blogi::StaticPage::getPublishForm(const int tid){
    std::string _lang = getLang(*Args->database[tid]);
    json_object *fields = json_object_new_array();
+1 −0
Changes for plugins/staticpage/static.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ namespace blogi {
        bool canPublish() override;
        json_object* getPublishForm(const int tid) override;
        void Publish(const int tid, const std::string &html, json_object *params, json_object *response) override;
        void RenderPublished(const int tid, const std::string &html, json_object *params, libhtmlpp::HtmlElement &page) override;
    private:
        json_object* newPage(const int tid,libhttppp::HttpRequest &req);
        json_object* delPage(const int tid,libhttppp::HttpRequest &req);
+4 −16
Changes for plugins/template/template.cpp: 4 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -433,22 +433,10 @@ namespace blogi {
                    if(atoi(res[i][3])==RenderingType::All || type==atoi(res[i][3])){
                        if(!res[i][2] || res[i][2][0] == '\0')
                            continue;
                        try {
                            libhtmlpp::HtmlString buf;
                            buf << res[i][2];
                            libhtmlpp::HtmlElement *el=curpage->getElementbyID(res[i][1]);
                            if(el)
                                el->appendChild(buf.parse());
                        } catch(libhtmlpp::HTMLException &e) {
                            std::cerr << "template: Rendering layer '" << res[i][1]
                                      << "' HTML error: " << e.what() << std::endl;
                        } catch(const std::exception &e) {
                            std::cerr << "template: Rendering layer '" << res[i][1]
                                      << "' error: " << e.what() << std::endl;
                        } catch(...) {
                            std::cerr << "template: Rendering layer '" << res[i][1]
                                      << "' unknown error" << std::endl;
                        }
                        json_object *params = json_object_new_object();
                        json_object_object_add(params, "layer", json_object_new_string(res[i][1]));
                        RenderPublished(tid, res[i][2], params, *curpage);
                        json_object_put(params);
                    }
                }
            } catch(const std::exception &e) {