Loading editor/widgets/CMakeLists.txt +2 −0 Changes for editor/widgets/CMakeLists.txt: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -39,3 +39,5 @@ add_subdirectory(article) add_subdirectory(slider) add_subdirectory(popup) add_subdirectory(accordion) add_subdirectory(googlemaps) add_subdirectory(googlereviews) editor/widgets/googlemaps/CMakeLists.txt 0 → 100644 +15 −0 Changes for editor/widgets/googlemaps/CMakeLists.txt: 15 added lines, 0 removed lines. Original line number Diff line number Diff line add_library(googlemaps SHARED googlemaps.cpp) if(NOT TARGET blogidev) target_link_libraries(googlemaps PUBLIC editor_plugin_base) else() target_link_libraries(googlemaps PUBLIC blogidev) endif() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(googlemaps PUBLIC uuidp::uuidp json-c::json-c kernel32.lib) else() target_link_libraries(googlemaps PUBLIC uuidp::uuidp json-c::json-c dl) endif() install (TARGETS googlemaps DESTINATION lib/blogi/editor/widgets) editor/widgets/googlemaps/googlemaps.cpp 0 → 100644 +137 −0 Changes for editor/widgets/googlemaps/googlemaps.cpp: 137 added lines, 0 removed lines. Original line number Diff line number Diff line #include <string> #include <vector> #include <tinyxml2.h> #include <json-c/json.h> #include <plugin.h> namespace blogi { namespace webedit { class GoogleMaps : public EditPlugin { public: GoogleMaps() { Type = "da3db3b2-6c2e-4b68-b80c-cd0a6f8b9e67"; } virtual ~GoogleMaps() = default; const std::string getName() const override { return "GoogleMaps"; } const std::string getAuthor() const override { return "Jan Koester / Copilot"; } const std::string getVersion() const override { return "1.0"; } void logError(const std::string& message) override {} void JsonApi(json_object *request, json_object *response) override { json_object *action_obj = nullptr; const char *action = nullptr; if (json_object_object_get_ex(request, "action", &action_obj)) { action = json_object_get_string(action_obj); } if (action == nullptr) return; if (strcmp(action, "modify_bulk") == 0) { json_object *props_obj = nullptr; if (json_object_object_get_ex(request, "properties", &props_obj)) { const char *json_str = json_object_to_json_string_ext(props_obj, JSON_C_TO_STRING_NOSLASHESCAPE); if (json_str) fromPropertiesJson(json_str); } } else if (strcmp(action, "read") == 0) { json_object *result_obj = json_object_new_object(); json_object_object_add(result_obj, "properties", json_object_new_string(toPropertiesJson().c_str())); if (response) json_object_object_add(response, "data", result_obj); } else if (strcmp(action, "get_schema") == 0) { if (response) json_object_object_add(response, "schema", getSchemaJson()); } if (response != nullptr) { json_object_object_add(response, "status", json_object_new_string("success")); json_object_object_add(response, "plugin_type", json_object_new_string("GoogleMaps")); } } static json_object* getSchemaJson() { json_object *arr = json_object_new_array(); json_object *prop1 = json_object_new_object(); json_object_object_add(prop1, "name", json_object_new_string("address")); json_object_object_add(prop1, "type", json_object_new_string("text")); json_object_object_add(prop1, "label", json_object_new_string("Adresse/Ort")); json_object_array_add(arr, prop1); json_object *prop2 = json_object_new_object(); json_object_object_add(prop2, "name", json_object_new_string("zoom")); json_object_object_add(prop2, "type", json_object_new_string("number")); json_object_object_add(prop2, "label", json_object_new_string("Zoom-Level")); json_object_array_add(arr, prop2); return arr; } std::string toPropertiesJson() const { json_object *obj = json_object_new_object(); json_object_object_add(obj, "address", json_object_new_string(_address.c_str())); json_object_object_add(obj, "zoom", json_object_new_string(_zoom.c_str())); std::string res = json_object_to_json_string(obj); json_object_put(obj); return res; } void fromPropertiesJson(const std::string& json_str) { if (json_str.empty()) return; json_object *obj = json_tokener_parse(json_str.c_str()); if (!obj) return; json_object *val; if (json_object_object_get_ex(obj, "address", &val)) _address = json_object_get_string(val); if (json_object_object_get_ex(obj, "zoom", &val)) _zoom = json_object_get_string(val); json_object_put(obj); } tinyxml2::XMLElement* toXmlObject(tinyxml2::XMLDocument* doc) override { tinyxml2::XMLElement* el = doc->NewElement("GoogleMaps"); if(!_address.empty()) el->SetAttribute("address", _address.c_str()); if(!_zoom.empty()) el->SetAttribute("zoom", _zoom.c_str()); el->SetAttribute("id", Id.toString().c_str()); return el; } void fromXmlObject(tinyxml2::XMLElement* xml_data) override { if (const char *a = xml_data->Attribute("address")) _address = a; if (const char *z = xml_data->Attribute("zoom")) _zoom = z; if (const char *id_attr = xml_data->Attribute("id")) { uuid::uuid newId; if(newId.parse(id_attr)) Id = newId; } } bool canHaveChildren() const override { return false; } bool haveChilds() override { return false; } void Settings(libhttppp::HttpRequest &curreq, libhtmlpp::HtmlElement &settings) override {} void Render(libhtmlpp::HtmlElement &el) const override { libhtmlpp::HtmlElement *iframe = new libhtmlpp::HtmlElement("iframe"); std::string src = "https://maps.google.com/maps?q=" + _address + "&t=&z=" + _zoom + "&ie=UTF8&iwloc=&output=embed"; iframe->setAttribute("src", src.c_str()); iframe->setAttribute("width", "100%"); iframe->setAttribute("height", "450"); iframe->setAttribute("style", "border:0;"); iframe->setAttribute("allowfullscreen", ""); iframe->setAttribute("loading", "lazy"); el.appendChild(iframe); } void setChildElement(const EditPlugin &el) override {} void unsetChildElement(const EditPlugin &el) override {} void addNextElement(const EditPlugin &el) override {} void remNextElement(const EditPlugin &el) override {} const EditPlugin *getChildElement() const override { return nullptr; } private: std::string _address = "Wetzlar, Deutschland"; std::string _zoom = "13"; }; } } extern "C" EXPORT blogi::webedit::EditPlugin* create() { return new blogi::webedit::GoogleMaps(); } extern "C" EXPORT void destroy(blogi::webedit::EditPlugin* p) { delete p; } No newline at end of file editor/widgets/googlereviews/CMakeLists.txt 0 → 100644 +15 −0 Changes for editor/widgets/googlereviews/CMakeLists.txt: 15 added lines, 0 removed lines. Original line number Diff line number Diff line add_library(googlereviews SHARED googlereviews.cpp) if(NOT TARGET blogidev) target_link_libraries(googlereviews PUBLIC editor_plugin_base) else() target_link_libraries(googlereviews PUBLIC blogidev) endif() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(googlereviews PUBLIC uuidp::uuidp json-c::json-c kernel32.lib) else() target_link_libraries(googlereviews PUBLIC uuidp::uuidp json-c::json-c dl) endif() install (TARGETS googlereviews DESTINATION lib/blogi/editor/widgets) editor/widgets/googlereviews/googlereviews.cpp 0 → 100644 +130 −0 Changes for editor/widgets/googlereviews/googlereviews.cpp: 130 added lines, 0 removed lines. Original line number Diff line number Diff line #include <string> #include <vector> #include <tinyxml2.h> #include <json-c/json.h> #include <plugin.h> namespace blogi { namespace webedit { class GoogleReviews : public EditPlugin { public: GoogleReviews() { Type = "4f553a1a-3e2b-42b7-bd20-1a7f05eb1349"; } virtual ~GoogleReviews() = default; const std::string getName() const override { return "GoogleReviews"; } const std::string getAuthor() const override { return "Jan Koester / Copilot"; } const std::string getVersion() const override { return "1.0"; } void logError(const std::string& message) override {} void JsonApi(json_object *request, json_object *response) override { json_object *action_obj = nullptr; const char *action = nullptr; if (json_object_object_get_ex(request, "action", &action_obj)) { action = json_object_get_string(action_obj); } if (!action) return; if (strcmp(action, "read") == 0) { json_object *result_obj = json_object_new_object(); json_object_object_add(result_obj, "properties", json_object_new_string("{}")); if (response) json_object_object_add(response, "data", result_obj); } else if (strcmp(action, "get_schema") == 0) { json_object *arr = json_object_new_array(); if (response) json_object_object_add(response, "schema", arr); } if (response != nullptr) { json_object_object_add(response, "status", json_object_new_string("success")); json_object_object_add(response, "plugin_type", json_object_new_string("GoogleReviews")); } } tinyxml2::XMLElement* toXmlObject(tinyxml2::XMLDocument* doc) override { tinyxml2::XMLElement* el = doc->NewElement("GoogleReviews"); el->SetAttribute("id", Id.toString().c_str()); return el; } void fromXmlObject(tinyxml2::XMLElement* xml_data) override { if (const char *id_attr = xml_data->Attribute("id")) { uuid::uuid newId; if(newId.parse(id_attr)) Id = newId; } } bool canHaveChildren() const override { return false; } bool haveChilds() override { return false; } void Settings(libhttppp::HttpRequest &curreq, libhtmlpp::HtmlElement &settings) override {} void Render(libhtmlpp::HtmlElement &el) const override { // Wrapper div for reviews libhtmlpp::HtmlElement *container = new libhtmlpp::HtmlElement("div"); container->setAttribute("id", "googlereviews-container"); container->setAttribute("class", "googlereviews-grid"); // Add script to dynamically load reviews libhtmlpp::HtmlElement *script = new libhtmlpp::HtmlElement("script"); std::string js = R"( document.addEventListener('DOMContentLoaded', function() { fetch('/google/reviews/list') .then(response => response.json()) .then(data => { const container = document.getElementById('googlereviews-container'); if (!data || data.length === 0) { container.innerHTML = '<p>Noch keine Bewertungen vorhanden.</p>'; return; } container.innerHTML = ''; data.forEach(rev => { let stars = ''; for(let i=0; i<5; i++) { if (i < rev.rating) stars += '⭐'; else stars += '★'; } const box = document.createElement('div'); box.style = 'background-color:#ffffff; padding:20px; border-radius:10px; border:1px solid #d4e8a8; margin-bottom:20px; flex:1; min-width:250px;'; const head = document.createElement('div'); head.style = 'font-size:14px; color:#07071a; font-weight:bold; padding-bottom:10px;'; head.innerText = rev.author_name + ' ' + stars; const body = document.createElement('div'); body.style = 'font-size:14px; color:#3d4a30;'; body.innerText = '"' + rev.text + '"'; box.appendChild(head); box.appendChild(body); container.appendChild(box); }); }) .catch(err => console.error('Error fetching reviews:', err)); }); )"; script->appendChild(js.c_str()); // Add inline style for a responsive flex grid wrapper if needed container->setAttribute("style", "display: flex; gap: 30px; flex-wrap: wrap; justify-content: center;"); el.appendChild(container); el.appendChild(script); } void setChildElement(const EditPlugin &el) override {} void unsetChildElement(const EditPlugin &el) override {} void addNextElement(const EditPlugin &el) override {} void remNextElement(const EditPlugin &el) override {} const EditPlugin *getChildElement() const override { return nullptr; } }; } } extern "C" EXPORT blogi::webedit::EditPlugin* create() { return new blogi::webedit::GoogleReviews(); } extern "C" EXPORT void destroy(blogi::webedit::EditPlugin* p) { delete p; } No newline at end of file Loading
editor/widgets/CMakeLists.txt +2 −0 Changes for editor/widgets/CMakeLists.txt: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -39,3 +39,5 @@ add_subdirectory(article) add_subdirectory(slider) add_subdirectory(popup) add_subdirectory(accordion) add_subdirectory(googlemaps) add_subdirectory(googlereviews)
editor/widgets/googlemaps/CMakeLists.txt 0 → 100644 +15 −0 Changes for editor/widgets/googlemaps/CMakeLists.txt: 15 added lines, 0 removed lines. Original line number Diff line number Diff line add_library(googlemaps SHARED googlemaps.cpp) if(NOT TARGET blogidev) target_link_libraries(googlemaps PUBLIC editor_plugin_base) else() target_link_libraries(googlemaps PUBLIC blogidev) endif() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(googlemaps PUBLIC uuidp::uuidp json-c::json-c kernel32.lib) else() target_link_libraries(googlemaps PUBLIC uuidp::uuidp json-c::json-c dl) endif() install (TARGETS googlemaps DESTINATION lib/blogi/editor/widgets)
editor/widgets/googlemaps/googlemaps.cpp 0 → 100644 +137 −0 Changes for editor/widgets/googlemaps/googlemaps.cpp: 137 added lines, 0 removed lines. Original line number Diff line number Diff line #include <string> #include <vector> #include <tinyxml2.h> #include <json-c/json.h> #include <plugin.h> namespace blogi { namespace webedit { class GoogleMaps : public EditPlugin { public: GoogleMaps() { Type = "da3db3b2-6c2e-4b68-b80c-cd0a6f8b9e67"; } virtual ~GoogleMaps() = default; const std::string getName() const override { return "GoogleMaps"; } const std::string getAuthor() const override { return "Jan Koester / Copilot"; } const std::string getVersion() const override { return "1.0"; } void logError(const std::string& message) override {} void JsonApi(json_object *request, json_object *response) override { json_object *action_obj = nullptr; const char *action = nullptr; if (json_object_object_get_ex(request, "action", &action_obj)) { action = json_object_get_string(action_obj); } if (action == nullptr) return; if (strcmp(action, "modify_bulk") == 0) { json_object *props_obj = nullptr; if (json_object_object_get_ex(request, "properties", &props_obj)) { const char *json_str = json_object_to_json_string_ext(props_obj, JSON_C_TO_STRING_NOSLASHESCAPE); if (json_str) fromPropertiesJson(json_str); } } else if (strcmp(action, "read") == 0) { json_object *result_obj = json_object_new_object(); json_object_object_add(result_obj, "properties", json_object_new_string(toPropertiesJson().c_str())); if (response) json_object_object_add(response, "data", result_obj); } else if (strcmp(action, "get_schema") == 0) { if (response) json_object_object_add(response, "schema", getSchemaJson()); } if (response != nullptr) { json_object_object_add(response, "status", json_object_new_string("success")); json_object_object_add(response, "plugin_type", json_object_new_string("GoogleMaps")); } } static json_object* getSchemaJson() { json_object *arr = json_object_new_array(); json_object *prop1 = json_object_new_object(); json_object_object_add(prop1, "name", json_object_new_string("address")); json_object_object_add(prop1, "type", json_object_new_string("text")); json_object_object_add(prop1, "label", json_object_new_string("Adresse/Ort")); json_object_array_add(arr, prop1); json_object *prop2 = json_object_new_object(); json_object_object_add(prop2, "name", json_object_new_string("zoom")); json_object_object_add(prop2, "type", json_object_new_string("number")); json_object_object_add(prop2, "label", json_object_new_string("Zoom-Level")); json_object_array_add(arr, prop2); return arr; } std::string toPropertiesJson() const { json_object *obj = json_object_new_object(); json_object_object_add(obj, "address", json_object_new_string(_address.c_str())); json_object_object_add(obj, "zoom", json_object_new_string(_zoom.c_str())); std::string res = json_object_to_json_string(obj); json_object_put(obj); return res; } void fromPropertiesJson(const std::string& json_str) { if (json_str.empty()) return; json_object *obj = json_tokener_parse(json_str.c_str()); if (!obj) return; json_object *val; if (json_object_object_get_ex(obj, "address", &val)) _address = json_object_get_string(val); if (json_object_object_get_ex(obj, "zoom", &val)) _zoom = json_object_get_string(val); json_object_put(obj); } tinyxml2::XMLElement* toXmlObject(tinyxml2::XMLDocument* doc) override { tinyxml2::XMLElement* el = doc->NewElement("GoogleMaps"); if(!_address.empty()) el->SetAttribute("address", _address.c_str()); if(!_zoom.empty()) el->SetAttribute("zoom", _zoom.c_str()); el->SetAttribute("id", Id.toString().c_str()); return el; } void fromXmlObject(tinyxml2::XMLElement* xml_data) override { if (const char *a = xml_data->Attribute("address")) _address = a; if (const char *z = xml_data->Attribute("zoom")) _zoom = z; if (const char *id_attr = xml_data->Attribute("id")) { uuid::uuid newId; if(newId.parse(id_attr)) Id = newId; } } bool canHaveChildren() const override { return false; } bool haveChilds() override { return false; } void Settings(libhttppp::HttpRequest &curreq, libhtmlpp::HtmlElement &settings) override {} void Render(libhtmlpp::HtmlElement &el) const override { libhtmlpp::HtmlElement *iframe = new libhtmlpp::HtmlElement("iframe"); std::string src = "https://maps.google.com/maps?q=" + _address + "&t=&z=" + _zoom + "&ie=UTF8&iwloc=&output=embed"; iframe->setAttribute("src", src.c_str()); iframe->setAttribute("width", "100%"); iframe->setAttribute("height", "450"); iframe->setAttribute("style", "border:0;"); iframe->setAttribute("allowfullscreen", ""); iframe->setAttribute("loading", "lazy"); el.appendChild(iframe); } void setChildElement(const EditPlugin &el) override {} void unsetChildElement(const EditPlugin &el) override {} void addNextElement(const EditPlugin &el) override {} void remNextElement(const EditPlugin &el) override {} const EditPlugin *getChildElement() const override { return nullptr; } private: std::string _address = "Wetzlar, Deutschland"; std::string _zoom = "13"; }; } } extern "C" EXPORT blogi::webedit::EditPlugin* create() { return new blogi::webedit::GoogleMaps(); } extern "C" EXPORT void destroy(blogi::webedit::EditPlugin* p) { delete p; } No newline at end of file
editor/widgets/googlereviews/CMakeLists.txt 0 → 100644 +15 −0 Changes for editor/widgets/googlereviews/CMakeLists.txt: 15 added lines, 0 removed lines. Original line number Diff line number Diff line add_library(googlereviews SHARED googlereviews.cpp) if(NOT TARGET blogidev) target_link_libraries(googlereviews PUBLIC editor_plugin_base) else() target_link_libraries(googlereviews PUBLIC blogidev) endif() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(googlereviews PUBLIC uuidp::uuidp json-c::json-c kernel32.lib) else() target_link_libraries(googlereviews PUBLIC uuidp::uuidp json-c::json-c dl) endif() install (TARGETS googlereviews DESTINATION lib/blogi/editor/widgets)
editor/widgets/googlereviews/googlereviews.cpp 0 → 100644 +130 −0 Changes for editor/widgets/googlereviews/googlereviews.cpp: 130 added lines, 0 removed lines. Original line number Diff line number Diff line #include <string> #include <vector> #include <tinyxml2.h> #include <json-c/json.h> #include <plugin.h> namespace blogi { namespace webedit { class GoogleReviews : public EditPlugin { public: GoogleReviews() { Type = "4f553a1a-3e2b-42b7-bd20-1a7f05eb1349"; } virtual ~GoogleReviews() = default; const std::string getName() const override { return "GoogleReviews"; } const std::string getAuthor() const override { return "Jan Koester / Copilot"; } const std::string getVersion() const override { return "1.0"; } void logError(const std::string& message) override {} void JsonApi(json_object *request, json_object *response) override { json_object *action_obj = nullptr; const char *action = nullptr; if (json_object_object_get_ex(request, "action", &action_obj)) { action = json_object_get_string(action_obj); } if (!action) return; if (strcmp(action, "read") == 0) { json_object *result_obj = json_object_new_object(); json_object_object_add(result_obj, "properties", json_object_new_string("{}")); if (response) json_object_object_add(response, "data", result_obj); } else if (strcmp(action, "get_schema") == 0) { json_object *arr = json_object_new_array(); if (response) json_object_object_add(response, "schema", arr); } if (response != nullptr) { json_object_object_add(response, "status", json_object_new_string("success")); json_object_object_add(response, "plugin_type", json_object_new_string("GoogleReviews")); } } tinyxml2::XMLElement* toXmlObject(tinyxml2::XMLDocument* doc) override { tinyxml2::XMLElement* el = doc->NewElement("GoogleReviews"); el->SetAttribute("id", Id.toString().c_str()); return el; } void fromXmlObject(tinyxml2::XMLElement* xml_data) override { if (const char *id_attr = xml_data->Attribute("id")) { uuid::uuid newId; if(newId.parse(id_attr)) Id = newId; } } bool canHaveChildren() const override { return false; } bool haveChilds() override { return false; } void Settings(libhttppp::HttpRequest &curreq, libhtmlpp::HtmlElement &settings) override {} void Render(libhtmlpp::HtmlElement &el) const override { // Wrapper div for reviews libhtmlpp::HtmlElement *container = new libhtmlpp::HtmlElement("div"); container->setAttribute("id", "googlereviews-container"); container->setAttribute("class", "googlereviews-grid"); // Add script to dynamically load reviews libhtmlpp::HtmlElement *script = new libhtmlpp::HtmlElement("script"); std::string js = R"( document.addEventListener('DOMContentLoaded', function() { fetch('/google/reviews/list') .then(response => response.json()) .then(data => { const container = document.getElementById('googlereviews-container'); if (!data || data.length === 0) { container.innerHTML = '<p>Noch keine Bewertungen vorhanden.</p>'; return; } container.innerHTML = ''; data.forEach(rev => { let stars = ''; for(let i=0; i<5; i++) { if (i < rev.rating) stars += '⭐'; else stars += '★'; } const box = document.createElement('div'); box.style = 'background-color:#ffffff; padding:20px; border-radius:10px; border:1px solid #d4e8a8; margin-bottom:20px; flex:1; min-width:250px;'; const head = document.createElement('div'); head.style = 'font-size:14px; color:#07071a; font-weight:bold; padding-bottom:10px;'; head.innerText = rev.author_name + ' ' + stars; const body = document.createElement('div'); body.style = 'font-size:14px; color:#3d4a30;'; body.innerText = '"' + rev.text + '"'; box.appendChild(head); box.appendChild(body); container.appendChild(box); }); }) .catch(err => console.error('Error fetching reviews:', err)); }); )"; script->appendChild(js.c_str()); // Add inline style for a responsive flex grid wrapper if needed container->setAttribute("style", "display: flex; gap: 30px; flex-wrap: wrap; justify-content: center;"); el.appendChild(container); el.appendChild(script); } void setChildElement(const EditPlugin &el) override {} void unsetChildElement(const EditPlugin &el) override {} void addNextElement(const EditPlugin &el) override {} void remNextElement(const EditPlugin &el) override {} const EditPlugin *getChildElement() const override { return nullptr; } }; } } extern "C" EXPORT blogi::webedit::EditPlugin* create() { return new blogi::webedit::GoogleReviews(); } extern "C" EXPORT void destroy(blogi::webedit::EditPlugin* p) { delete p; } No newline at end of file