Loading plugins/content/content.cpp +23 −15 Changes for plugins/content/content.cpp: 23 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -226,7 +226,6 @@ namespace blogi { void contentPage(const int tid,libhttppp::HttpRequest& curreq,libhtmlpp::HtmlElement &page,const std::string &sessionid) { std::string _lang = getLang(*Args->database[tid]); libhttppp::HTTPException excep; libhtmlpp::HtmlString condat; char url[512]; int cid; Loading @@ -245,28 +244,36 @@ namespace blogi { throw excep; } condat << "<div id=\"content\">"; // Admin menu (only when logged in) if (Args->auth->isLoggedIn(tid,curreq,sessionid)) { condat << "<div class=\"blog_adminmenu\">" libhtmlpp::HtmlString admindat; admindat << "<div id=\"content\"><div class=\"blog_adminmenu\">" << "<ul>" << "<li><a href=\"" << Args->config->buildurl("content/edit/") << cid << "\">"+tr(_lang,"Edit")+"</a></li>" << "<li><a href=\"" << Args->config->buildurl("content/del/") << cid << "\">"+tr(_lang,"Delete")+"</a></li>" << "</ul>" << "</div>"; << "</div></div>"; libhtmlpp::HtmlElement *main = page.getElementbyID("main"); if (main) { try { main->insertChild(admindat.parse()); } catch (...) {} } } condat << "<div class=\"blog_entry\">" << "<span class=\"title\">" << res[0][1] << "</span>" << "<div class=\"blog_entry_idx_content\" ><div class=\"text\">" << res[0][2] << "</div>" << "<span class=\"author\">"+tr(_lang,"written by")+" " << res[0][3] << " "+tr(_lang,"on")+" "<< res[0][4] <<" </span>" << "</div></div><a class=\"back_content\" href=\"#\" onclick=\"history.back()\">"+tr(_lang,"Back")+"</a></div>"; libhtmlpp::HtmlString out; // Use RenderPublished for the article wrapper json_object *params = json_object_new_object(); json_object_object_add(params, "title", json_object_new_string(res[0][1] ? res[0][1] : "")); json_object_object_add(params, "author", json_object_new_string(res[0][3] ? res[0][3] : "")); json_object_object_add(params, "date", json_object_new_string(res[0][4] ? res[0][4] : "")); std::string text = res[0][2] ? res[0][2] : ""; RenderPublished(tid, text, params, page); json_object_put(params); try{ page.getElementbyID("main")->insertChild(condat.parse()); }catch(libhtmlpp::HTMLException &e){ excep[libhttppp::HTTPException::Error] << e.what(); throw excep; // Back link libhtmlpp::HtmlString backdat; backdat << "<a class=\"back_content\" href=\"#\" onclick=\"history.back()\">"+tr(_lang,"Back")+"</a>"; libhtmlpp::HtmlElement *main2 = page.getElementbyID("main"); if (main2) { try { main2->appendChild(backdat.parse()); } catch (...) {} } libhtmlpp::HtmlElement canon("link"); Loading @@ -277,6 +284,7 @@ namespace blogi { if(page.getElementbyTag("head")) page.getElementbyTag("head")->appendChild(canon); libhtmlpp::HtmlString out; Args->theme->printSite(tid,out,&page,curreq.getRequestURL(),Args->auth->isLoggedIn(tid,curreq,sessionid)); libhttppp::HttpResponse resp; Loading plugins/template/template.cpp +23 −0 Changes for plugins/template/template.cpp: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -478,6 +478,29 @@ namespace blogi { return true; } void RenderPublished(const int tid, const std::string &html, json_object *params, libhtmlpp::HtmlElement &page) override { std::string layer; json_object *val_obj = nullptr; if (params && json_object_object_get_ex(params, "layer", &val_obj)) { const char *v = json_object_get_string(val_obj); if (v) layer = v; } if (layer.empty()) layer = "main"; libhtmlpp::HtmlElement *el = page.getElementbyID(layer); if (el) { libhtmlpp::HtmlString buf; buf << html; try { el->appendChild(buf.parse()); } catch (libhtmlpp::HTMLException &e) { std::cerr << "template: RenderPublished layer '" << layer << "' HTML error: " << e.what() << std::endl; } } } json_object* getPublishForm(const int tid) override { std::string _lang = getLang(*Args->database[tid]); json_object *fields = json_object_new_array(); Loading Loading
plugins/content/content.cpp +23 −15 Changes for plugins/content/content.cpp: 23 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -226,7 +226,6 @@ namespace blogi { void contentPage(const int tid,libhttppp::HttpRequest& curreq,libhtmlpp::HtmlElement &page,const std::string &sessionid) { std::string _lang = getLang(*Args->database[tid]); libhttppp::HTTPException excep; libhtmlpp::HtmlString condat; char url[512]; int cid; Loading @@ -245,28 +244,36 @@ namespace blogi { throw excep; } condat << "<div id=\"content\">"; // Admin menu (only when logged in) if (Args->auth->isLoggedIn(tid,curreq,sessionid)) { condat << "<div class=\"blog_adminmenu\">" libhtmlpp::HtmlString admindat; admindat << "<div id=\"content\"><div class=\"blog_adminmenu\">" << "<ul>" << "<li><a href=\"" << Args->config->buildurl("content/edit/") << cid << "\">"+tr(_lang,"Edit")+"</a></li>" << "<li><a href=\"" << Args->config->buildurl("content/del/") << cid << "\">"+tr(_lang,"Delete")+"</a></li>" << "</ul>" << "</div>"; << "</div></div>"; libhtmlpp::HtmlElement *main = page.getElementbyID("main"); if (main) { try { main->insertChild(admindat.parse()); } catch (...) {} } } condat << "<div class=\"blog_entry\">" << "<span class=\"title\">" << res[0][1] << "</span>" << "<div class=\"blog_entry_idx_content\" ><div class=\"text\">" << res[0][2] << "</div>" << "<span class=\"author\">"+tr(_lang,"written by")+" " << res[0][3] << " "+tr(_lang,"on")+" "<< res[0][4] <<" </span>" << "</div></div><a class=\"back_content\" href=\"#\" onclick=\"history.back()\">"+tr(_lang,"Back")+"</a></div>"; libhtmlpp::HtmlString out; // Use RenderPublished for the article wrapper json_object *params = json_object_new_object(); json_object_object_add(params, "title", json_object_new_string(res[0][1] ? res[0][1] : "")); json_object_object_add(params, "author", json_object_new_string(res[0][3] ? res[0][3] : "")); json_object_object_add(params, "date", json_object_new_string(res[0][4] ? res[0][4] : "")); std::string text = res[0][2] ? res[0][2] : ""; RenderPublished(tid, text, params, page); json_object_put(params); try{ page.getElementbyID("main")->insertChild(condat.parse()); }catch(libhtmlpp::HTMLException &e){ excep[libhttppp::HTTPException::Error] << e.what(); throw excep; // Back link libhtmlpp::HtmlString backdat; backdat << "<a class=\"back_content\" href=\"#\" onclick=\"history.back()\">"+tr(_lang,"Back")+"</a>"; libhtmlpp::HtmlElement *main2 = page.getElementbyID("main"); if (main2) { try { main2->appendChild(backdat.parse()); } catch (...) {} } libhtmlpp::HtmlElement canon("link"); Loading @@ -277,6 +284,7 @@ namespace blogi { if(page.getElementbyTag("head")) page.getElementbyTag("head")->appendChild(canon); libhtmlpp::HtmlString out; Args->theme->printSite(tid,out,&page,curreq.getRequestURL(),Args->auth->isLoggedIn(tid,curreq,sessionid)); libhttppp::HttpResponse resp; Loading
plugins/template/template.cpp +23 −0 Changes for plugins/template/template.cpp: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -478,6 +478,29 @@ namespace blogi { return true; } void RenderPublished(const int tid, const std::string &html, json_object *params, libhtmlpp::HtmlElement &page) override { std::string layer; json_object *val_obj = nullptr; if (params && json_object_object_get_ex(params, "layer", &val_obj)) { const char *v = json_object_get_string(val_obj); if (v) layer = v; } if (layer.empty()) layer = "main"; libhtmlpp::HtmlElement *el = page.getElementbyID(layer); if (el) { libhtmlpp::HtmlString buf; buf << html; try { el->appendChild(buf.parse()); } catch (libhtmlpp::HTMLException &e) { std::cerr << "template: RenderPublished layer '" << layer << "' HTML error: " << e.what() << std::endl; } } } json_object* getPublishForm(const int tid) override { std::string _lang = getLang(*Args->database[tid]); json_object *fields = json_object_new_array(); Loading