From c7a14fbb2383b91d4b30f4de0e73cf5139b8e9ad Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Wed, 30 Apr 2025 08:48:23 +0530 Subject: [PATCH] dlf --- .../Controller/HtmlGeneratorController.java | 4 +- .../OpenAi/Controller/SureOpsController.java | 49 +- .../realnet/OpenAi/Services/HtmlBuilder3.java | 2 - .../realnet/OpenAi/Services/HtmlBuilder4.java | 4601 +++++++++++++++++ .../Controllers/Design_lbraryController.java | 100 + .../com/realnet/dlf/Entity/Design_lbrary.java | 46 + .../Repository/Design_lbraryRepository.java | 36 + .../dlf/Services/Design_lbraryService.java | 100 + .../com/realnet/dlf/Services/DlfService.java | 281 + .../java/com/realnet/utils/PortConstant.java | 3 +- 10 files changed, 5193 insertions(+), 29 deletions(-) create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder4.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/DlfService.java diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/HtmlGeneratorController.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/HtmlGeneratorController.java index 42487d9..a6d7745 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/HtmlGeneratorController.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/HtmlGeneratorController.java @@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.realnet.OpenAi.Services.HtmlBuilder3; +import com.realnet.OpenAi.Services.HtmlBuilder4; import com.realnet.OpenAi.Services.HtmlGenerTorService; import com.realnet.fnd.response.EntityResponse; @@ -47,7 +47,7 @@ public class HtmlGeneratorController { return ResponseEntity.badRequest().body("Missing 'jsonStructure' in request."); } - String html = HtmlBuilder3.buildHtml(jsonStructure); + String html = HtmlBuilder4.buildHtml(jsonStructure); return ResponseEntity.ok(new EntityResponse(html)); } catch (Exception e) { e.printStackTrace(); diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/SureOpsController.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/SureOpsController.java index 5075b93..c1aae1b 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/SureOpsController.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Controller/SureOpsController.java @@ -133,30 +133,31 @@ public class SureOpsController { public void createHtmlFiles(@RequestParam Integer projId, @RequestBody Map pageHtmlMap) throws IOException { - for (Map.Entry entry : pageHtmlMap.entrySet()) { - String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name - String htmlContent = entry.getValue(); - - String folderPath = projectPath + "/cns-portal/code-extractor/builders/" + projId; - File file = new File(folderPath + "/" + pageName + ".html"); - - // Ensure directory exists - File parentDir = file.getParentFile(); - if (!parentDir.exists()) { - parentDir.mkdirs(); - } - - // Create new file - if (!file.exists()) { - file.createNewFile(); - } - - try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { - writer.write(htmlContent); - } - - System.out.println("✅ File created: " + file.getAbsolutePath()); - } + sureopsService.createHtmlFiles(projId, pageHtmlMap); +// for (Map.Entry entry : pageHtmlMap.entrySet()) { +// String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name +// String htmlContent = entry.getValue(); +// +// String folderPath = projectPath + "/cns-portal/code-extractor/builders/" + projId; +// File file = new File(folderPath + "/" + pageName + ".html"); +// +// // Ensure directory exists +// File parentDir = file.getParentFile(); +// if (!parentDir.exists()) { +// parentDir.mkdirs(); +// } +// +// // Create new file +// if (!file.exists()) { +// file.createNewFile(); +// } +// +// try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { +// writer.write(htmlContent); +// } +// +// System.out.println("✅ File created: " + file.getAbsolutePath()); +// } } } diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder3.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder3.java index d93892a..b68418e 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder3.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder3.java @@ -9,8 +9,6 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -import com.realnet.OpenAi.Renders.HtmlRenderer; - public class HtmlBuilder3 { public static String buildHtml(Object node) { diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder4.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder4.java new file mode 100644 index 0000000..9e4f38f --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/HtmlBuilder4.java @@ -0,0 +1,4601 @@ +package com.realnet.OpenAi.Services; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class HtmlBuilder4 { + + public static String buildHtml(Object node) { + if (node instanceof Map) { + Map map = (Map) node; + + // Handle raw section container + if (!map.containsKey("type") && !map.containsKey("tag")) { + StringBuilder html = new StringBuilder(); + for (Map.Entry entry : map.entrySet()) { + String sectionName = entry.getKey(); + Object sectionContent = entry.getValue(); + + if ("teamSlider".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderTeamSlider((Map) sectionContent)); + continue; + } + + if ("teamSectionTemplate".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderTeamSectionTemplate((Map) sectionContent)); + continue; + } + + if ("teamSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderTeamSection((Map) sectionContent)); + continue; + } + + if ("logoGuidelines".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderLogoGuidelines((Map) sectionContent)); + continue; + } + + if ("logoGrid".equalsIgnoreCase(sectionName) && sectionContent instanceof List) { + html.append(renderLogoGrid((List>) sectionContent)); + continue; + } + + if ("brandGuideline".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBrandGuideline((Map) sectionContent)); + continue; + } + + if ("logoShowcase".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderLogoShowcase((Map) sectionContent)); + continue; + } + + if ("logoCloud".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderLogoCloud((Map) sectionContent)); + continue; + } + + if ("ecommerceFAQs".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderEcommerceFAQs((Map) sectionContent)); + continue; + } + + if ("dashboardLayout".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderDashboardLayout((Map) sectionContent)); + continue; + } + + if ("FAQIllustratedSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderFaqIllustrated((Map) sectionContent)); + continue; + } + + if ("FAQSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderFaqSection((Map) sectionContent)); + continue; + } + if ("FAQTwoColumn".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderFaqTwoColumn((Map) sectionContent)); + continue; + } + + if ("TestimonialLanding".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderTestimonialLanding((Map) sectionContent)); + continue; + } + + if ("ClientTestimonialSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderClientTestimonial((Map) sectionContent)); + continue; + } + if ("TestimonialSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderSimpleTestimonial((Map) sectionContent)); + continue; + } + + if ("SubSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderSubSectionCentered((Map) sectionContent)); + continue; + } + if ("HeroSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + Map heroMap = (Map) sectionContent; + + if ("centered".equalsIgnoreCase(getString(heroMap, "layout", "")) + && heroMap.containsKey("artwork")) { + html.append(renderHeroCenteredWithArt(heroMap)); + continue; + } + if ("left-text-right-cards".equalsIgnoreCase(getString(heroMap, "layout", ""))) { + html.append(renderHeroLeftCards(heroMap)); + continue; + } + // Smart internal layout-based routing to correct renderer + String layout = getString(heroMap, "layout", "").toLowerCase(); + + if (layout.equals("two-column") || heroMap.containsKey("leftColumn")) { + html.append(renderTwoColumnHeroSection(heroMap)); + } else if (layout.equals("centered") || heroMap.containsKey("heading")) { + html.append(renderCenteredHeroSection(heroMap)); + } else { + // fallback to older generic renderHeroSection + html.append(renderHeroSection(heroMap)); + } + continue; + } + + if ("Blog".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogCardSection((Map) sectionContent)); + continue; + } + + if ("blogPage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogPage((Map) sectionContent)); + continue; + } + + if ("blogPreviewSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogPreviewSection((Map) sectionContent)); + continue; + } + if ("blogHomePage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogHomePage((Map) sectionContent)); + continue; + } + + if ("blogListSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogListSection((Map) sectionContent)); + continue; + } + + if ("ContactSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderContactSection((Map) sectionContent)); + continue; + } + + if ("Navbar".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderNavbarBlock((Map) sectionContent)); + continue; + } + if ("Footer".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + Map footerMap = (Map) sectionContent; + + // Smart switch based on keys like 'columns', 'topBar', 'bottom' + if (footerMap.containsKey("columns") || footerMap.containsKey("topBar") + || footerMap.containsKey("bottom")) { + html.append(renderMdBootstrapFooter(footerMap)); + } else if (footerMap.containsKey("linkColumns") || footerMap.containsKey("socialIcons")) { + html.append(renderCompactFooter(footerMap)); + } else { + html.append(renderFooterBlock(footerMap)); + } + continue; + } + if ("how-to-blog-post".equalsIgnoreCase(getString(map, "type", ""))) { + html.append(renderHowToBlogPost(map)); + return html.toString(); + } + + if ("blogThumbnailGrid".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogThumbnailGrid((Map) sectionContent)); + continue; + } + if ("blogSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogSection((Map) sectionContent)); + continue; + } + if ("articlePage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderArticlePage((Map) sectionContent)); + continue; + } + if ("templateLibrary".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderTemplateLibrary((Map) sectionContent)); + continue; + } + if ("blogHeader".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { + html.append(renderBlogHeader((Map) sectionContent)); + continue; + } + + // Wrap each section in a
tag with class derived from key + html.append("
"); + + html.append(buildHtml(sectionContent)); + + html.append("
"); + } + return html.toString(); + } + // Check if a universal TYPE_RENDERER exists for this block + String type = getString(map, "type", ""); + if (TYPE_RENDERERS.containsKey(type.toLowerCase())) { + return TYPE_RENDERERS.get(type.toLowerCase()).apply(map); + } + // Normal map block + return renderFromMap(map); + } else if (node instanceof List) { + return renderFromList((List) node); + } else if (node != null) { + return node.toString(); + } else { + return ""; + } + } + + private static final Map TYPE_TAG_MAP = new HashMap<>(); + static { + TYPE_TAG_MAP.put("navbar", "nav"); + TYPE_TAG_MAP.put("footer", "footer"); + TYPE_TAG_MAP.put("article", "article"); + TYPE_TAG_MAP.put("header", "header"); + TYPE_TAG_MAP.put("logo", "div"); + TYPE_TAG_MAP.put("nav", "nav"); + TYPE_TAG_MAP.put("link", "a"); + TYPE_TAG_MAP.put("button", "button"); + TYPE_TAG_MAP.put("span", "span"); + TYPE_TAG_MAP.put("img", "img"); // already supported as self-closing + TYPE_TAG_MAP.put("social-icons", "div"); + TYPE_TAG_MAP.put("icon", "div"); + TYPE_TAG_MAP.put("text", "span"); // or "p" depending on your choice + + // add more if needed + } + private static final Map, String>> TYPE_RENDERERS = new HashMap<>(); + + static { + // Blog Related + TYPE_RENDERERS.put("blog-list", HtmlBuilder4::renderBlogList); + TYPE_RENDERERS.put("blog-featured", HtmlBuilder4::renderBlogFeatured); + TYPE_RENDERERS.put("blog-author-bio", HtmlBuilder4::renderBlogAuthorBio); + TYPE_RENDERERS.put("newsletter-signup", HtmlBuilder4::renderNewsletterSignup); + TYPE_RENDERERS.put("blog-categories", HtmlBuilder4::renderBlogCategories); + + // Media + TYPE_RENDERERS.put("video-section", HtmlBuilder4::renderVideoSection); + TYPE_RENDERERS.put("image-gallery", HtmlBuilder4::renderImageGallery); + TYPE_RENDERERS.put("testimonial-carousel", HtmlBuilder4::renderTestimonialCarousel); + TYPE_RENDERERS.put("brand-logos", HtmlBuilder4::renderBrandLogos); + + // Features + TYPE_RENDERERS.put("feature-grid", HtmlBuilder4::renderFeatureGrid); + TYPE_RENDERERS.put("feature-carousel", HtmlBuilder4::renderFeatureCarousel); + TYPE_RENDERERS.put("feature-with-image", HtmlBuilder4::renderFeatureWithImage); + TYPE_RENDERERS.put("feature-numbered-steps", HtmlBuilder4::renderFeatureNumberedSteps); + TYPE_RENDERERS.put("feature-section", HtmlBuilder4::renderFeatureAuto); + TYPE_RENDERERS.put("section-centered-card-grid", HtmlBuilder4::renderCenteredCardGrid); + TYPE_RENDERERS.put("feature-card-list", HtmlBuilder4::renderFeatureCardList); + + // Interactive + TYPE_RENDERERS.put("faq-accordion", HtmlBuilder4::renderFaqAccordion); + TYPE_RENDERERS.put("tabbed-section", HtmlBuilder4::renderTabbedSection); + TYPE_RENDERERS.put("counter-stats", HtmlBuilder4::renderCounterStats); + TYPE_RENDERERS.put("progress-bars", HtmlBuilder4::renderProgressBars); + + // Marketing + TYPE_RENDERERS.put("call-to-action", HtmlBuilder4::renderCallToAction); + TYPE_RENDERERS.put("download-app", HtmlBuilder4::renderDownloadApp); + TYPE_RENDERERS.put("lead-magnet", HtmlBuilder4::renderLeadMagnet); + TYPE_RENDERERS.put("promo-banner", HtmlBuilder4::renderPromoBanner); + + // Team + TYPE_RENDERERS.put("team-grid", HtmlBuilder4::renderTeamGrid); + TYPE_RENDERERS.put("team-profile-list", HtmlBuilder4::renderTeamProfileList); + TYPE_RENDERERS.put("company-timeline", HtmlBuilder4::renderCompanyTimeline); + TYPE_RENDERERS.put("values-section", HtmlBuilder4::renderValuesSection); + + // Pricing + TYPE_RENDERERS.put("pricing-cards", HtmlBuilder4::renderPricingCards); + TYPE_RENDERERS.put("pricing-comparison", HtmlBuilder4::renderPricingComparison); + + // Contact + TYPE_RENDERERS.put("contact-form", HtmlBuilder4::renderContactForm); + TYPE_RENDERERS.put("contact-map", HtmlBuilder4::renderContactMap); + TYPE_RENDERERS.put("contact-grid", HtmlBuilder4::renderContactGrid); + TYPE_RENDERERS.put("contactformsection", HtmlBuilder4::renderContactFormSection); + TYPE_RENDERERS.put("contactinfosection", HtmlBuilder4::renderContactInfoSection); + TYPE_RENDERERS.put("contactsplitsection", HtmlBuilder4::renderContactSplitSection); + TYPE_RENDERERS.put("contactpage", HtmlBuilder4::renderContactPage); + TYPE_RENDERERS.put("contactussection", HtmlBuilder4::renderContactUsSection); + + // Footer + TYPE_RENDERERS.put("footer-minimal", HtmlBuilder4::renderFooterMinimal); + TYPE_RENDERERS.put("footer-centered", HtmlBuilder4::renderFooterCentered); + TYPE_RENDERERS.put("footer-columns", HtmlBuilder4::renderFooterColumns); + +// Subscription + TYPE_RENDERERS.put("subscription-form", HtmlBuilder4::renderSubscriptionForm); + TYPE_RENDERERS.put("cta-block", HtmlBuilder4::renderCtaBlock); + TYPE_RENDERERS.put("cta-gradient", HtmlBuilder4::renderCtaGradientSection); + TYPE_RENDERERS.put("contact-signup", HtmlBuilder4::renderContactSignupSection); + TYPE_RENDERERS.put("hero-banner", HtmlBuilder4::renderHeroBanner); + +// Pricing + + TYPE_RENDERERS.put("pricing-section", HtmlBuilder4::renderPricingSection); + TYPE_RENDERERS.put("pricingsectiondark", HtmlBuilder4::renderPricingSectionDark); + TYPE_RENDERERS.put("pricingsection", HtmlBuilder4::renderPricingHubPlans); + TYPE_RENDERERS.put("pricingsection", HtmlBuilder4::renderTogglePricingSection); + TYPE_RENDERERS.put("singleplansection", HtmlBuilder4::renderSinglePlanSection); + + // Utility Elements + TYPE_RENDERERS.put("icon-button", HtmlBuilder4::renderIconButton); + TYPE_RENDERERS.put("label", HtmlBuilder4::renderLabel); + TYPE_RENDERERS.put("badge", HtmlBuilder4::renderBadge); + TYPE_RENDERERS.put("rating-stars", HtmlBuilder4::renderRatingStars); + TYPE_RENDERERS.put("classic-list-post", HtmlBuilder4::renderClassicListPost); + TYPE_RENDERERS.put("list-post", HtmlBuilder4::renderListPost); + TYPE_RENDERERS.put("perfect-blog-post", HtmlBuilder4::renderPerfectBlogPost); + TYPE_RENDERERS.put("blog-thumbnail-grid", HtmlBuilder4::renderBlogThumbnailGrid); + TYPE_RENDERERS.put("teamShowcase", HtmlBuilder4::renderTeamShowcase); + TYPE_RENDERERS.put("herosection", HtmlBuilder4::renderHeroCenteredHeadingSplit); + + TYPE_RENDERERS.put("header", HtmlBuilder4::renderSmartHeader); + TYPE_RENDERERS.put("centered-section-with-image", HtmlBuilder4::renderCenteredSectionWithImage); + + TYPE_RENDERERS.put("Header Section", HtmlBuilder4::renderHeaderSection); + TYPE_RENDERERS.put("herosection", HtmlBuilder4::renderSmartHeroSection); + TYPE_RENDERERS.put("hero-section", HtmlBuilder4::renderSmartHeroSection); + + TYPE_RENDERERS.put("page", (node) -> buildHtml(node.get("children"))); + TYPE_RENDERERS.put("heading", (node) -> "

" + + get(node, "content") + "

"); + TYPE_RENDERERS.put("paragraph", (node) -> "

" + + get(node, "content") + "

"); + TYPE_RENDERERS.put("button-group", (node) -> wrapTag("div", "button-group", node)); + TYPE_RENDERERS.put("image-grid", (node) -> wrapTag("div", "image-grid", node)); + TYPE_RENDERERS.put("image-tile", (node) -> "
\"image\"/
"); + TYPE_RENDERERS.put("logo", + (node) -> "
" + get(node, "content") + "
"); + + TYPE_RENDERERS.put("nav", (node) -> { + StringBuilder b = new StringBuilder(); + b.append(""); + return b.toString(); + }); + TYPE_RENDERERS.put("link", (node) -> ""); // handled above in nav + TYPE_RENDERERS.put("button", (node) -> ""); + + } + + private static String wrapTag(String tag, String className, Map node) { + StringBuilder html = new StringBuilder(); + html.append("<").append(tag); + if (className != null) { + html.append(" class=\"").append(className).append("\""); + } + html.append(">"); + + if (node.containsKey("children")) { + List> children = (List>) node.get("children"); + for (Map child : children) { + html.append(buildHtml(child)); // ✅ Use universal method + } + } + + html.append(""); + return html.toString(); + } + + private static String get(Map map, String key) { + Object val = map.get(key); + return val instanceof String ? (String) val : ""; + } + + public static String get(Map map, String key, String defaultValue) { + Object value = map.get(key); + return value != null ? value.toString() : defaultValue; + } + + @SuppressWarnings("unchecked") + public static List> getList(Map map, String key) { + Object value = map.get(key); + if (value instanceof List) { + return (List>) value; + } + return Collections.emptyList(); + } + + @SuppressWarnings("unchecked") + public static List getStringList(Map map, String key) { + Object value = map.get(key); + if (value instanceof List) { + return ((List) value).stream().filter(String.class::isInstance).map(String.class::cast) + .collect(Collectors.toList()); + } + return Collections.emptyList(); + } + + @SuppressWarnings("unchecked") + public static Map getMap(Map map, String key) { + Object value = map.get(key); + if (value instanceof Map) { + return (Map) value; + } + return Collections.emptyMap(); + } + + // ---------------- Placeholder Functions ---------------- + private static String renderBlogList(Map node) { + return "
Blog List Placeholder
"; + } + + private static String renderBlogFeatured(Map node) { + return ""; + } + + private static String renderBlogAuthorBio(Map node) { + return "
Author Bio
"; + } + + private static String renderNewsletterSignup(Map node) { + return ""; + } + + private static String renderBlogCategories(Map node) { + return "
Categories
"; + } + + private static String renderVideoSection(Map node) { + return "
Video Section
"; + } + + private static String renderImageGallery(Map node) { + return ""; + } + + private static String renderPricingSectionDark(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
"); + + html.append("
").append(get(data, "badge")).append("
"); + html.append("

").append(get(data, "title")).append("

"); + html.append("

").append(get(data, "description")).append("

"); + + html.append("
"); + List> cards = getList(data, "cards"); + for (Map card : cards) { + String cardClass = "pricing-card" + (getBoolean(card, "highlight") ? " highlight" : ""); + html.append("
"); + html.append("
").append(get(card, "badge")).append("
"); + html.append("

").append(get(card, "price")).append("

"); + html.append("
    "); + List features = (List) card.get("features"); + for (String feature : features) { + html.append("
  • ").append(feature).append("
  • "); + } + html.append("
"); + Map btn = getMap(card, "button"); + String btnClass = "filled"; + if ("outline".equals(btn.get("style"))) + btnClass = "outline"; + else if ("light".equals(btn.get("style"))) + btnClass = "light"; + + html.append(""); + + html.append("
"); + } + html.append("
"); + return html.toString(); + } + + private static String renderSinglePlanSection(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
"); + + // Header + html.append("
").append("

") + .append(getText(data, "title")).append("

").append("

") + .append(getText(data, "subtitle")).append("

").append("
"); + + // Features + List> features = getList(data, "features"); + html.append("
"); + for (Map feature : features) { + html.append("
").append("") + .append(getText(feature, "icon")).append("").append("

") + .append(getText(feature, "title")).append("

").append("

") + .append(getText(feature, "description")).append("

").append("
"); + } + html.append("
"); + + // Plan Card + Map planCard = getMap(data, "planCard"); + Map cta = getMap(planCard, "cta"); + html.append("
").append("

").append(getText(planCard, "title")) + .append("

").append("

").append(getText(planCard, "price")).append(" / ") + .append(getText(planCard, "frequency")).append("

").append("

") + .append(getText(planCard, "description")).append("

").append("") + .append(getText(cta, "label")).append("").append("
"); + + html.append("
"); + return html.toString(); + } + + private static String renderTogglePricingSection(Map data) { + StringBuilder html = new StringBuilder(); + + html.append("
"); + + html.append("
").append("

").append(get(data, "title")).append("

") + .append("

").append(get(data, "subtitle")).append("

").append("
"); + + Map toggle = getMap(data, "toggle"); + List options = getStringList(toggle, "options"); + String def = get(toggle, "default"); + + html.append("
"); + for (String option : options) { + String active = option.equalsIgnoreCase(def) ? "active" : ""; + html.append(""); + } + html.append("
"); + + html.append("
"); + List> plans = getList(data, "plans"); + for (Map plan : plans) { + boolean highlight = getBoolean(plan, "highlight"); + html.append("
").append("

") + .append(get(plan, "name")).append("

").append("
") + .append(get(plan, "price")).append("
").append("
") + .append(get(plan, "savings")).append("
").append("
") + .append(get(plan, "bonus")).append("
").append("
    "); + List features = getStringList(plan, "features"); + for (String feat : features) { + html.append("
  • ").append(feat).append("
  • "); + } + html.append("
").append("") + .append("
"); + } + html.append("
"); + + return html.toString(); + } + + private static String renderPricingHubPlans(Map data) { + StringBuilder html = new StringBuilder(); + + Map header = getMap(data, "header"); + html.append("
"); + + html.append("
").append("

").append(get(header, "title")).append("

") + .append("

").append(get(header, "subtitle")).append("

").append("
"); + + List tabs = (List) data.get("tabs"); + if (tabs != null && !tabs.isEmpty()) { + html.append("
"); + for (String tab : tabs) { + html.append("
").append(tab).append("
"); + } + html.append("
"); + } + + Map hub = getMap(data, "hub"); + html.append("
").append("

").append(get(hub, "name")).append("

").append("

") + .append(get(hub, "description")).append("

").append("").append(get(hub, "link")) + .append("").append("
"); + + html.append("
"); + List> plans = getList(data, "plans"); + for (Map plan : plans) { + html.append("
").append("

").append(get(plan, "name")).append("

") + .append("

").append(get(plan, "priceMonthly")).append(" / ").append(get(plan, "priceYearly")) + .append("

").append("

Contacts: ").append(get(plan, "contacts")).append("

").append("

") + .append(get(plan, "notes")).append("

").append("").append("
"); + } + html.append("
"); + + return html.toString(); + } + + public static boolean getBoolean(Map data, String key) { + Object value = data.get(key); + return value instanceof Boolean ? (Boolean) value : false; + } + + private static String renderPricingSection(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + sb.append("

").append(getText(data, "tagline.text")).append("

"); + sb.append("

").append(getText(data, "title.text")).append("

"); + sb.append("

").append(getText(data, "description.text")).append("

"); + + sb.append("
"); + List> cards = getList(data, "cards"); + for (Map card : cards) { + sb.append("
"); + + sb.append("

").append(card.get("plan")).append("

"); + sb.append("

").append(card.get("monthly")).append(" / mo

"); + sb.append("

").append(card.get("yearly")).append(" / yr

"); + + sb.append("
    "); + List features = (List) card.get("features"); + for (String feature : features) { + sb.append("
  • ").append(feature).append("
  • "); + } + sb.append("
"); + + Map button = getMap(card, "button"); + sb.append("").append(button.get("label")) + .append(""); + + sb.append("
"); + } + sb.append("
"); + return sb.toString(); + } + + @SuppressWarnings("unchecked") + public static String getText(Map data, String path) { + String[] keys = path.split("\\."); + Object current = data; + for (String key : keys) { + if (current instanceof Map) { + current = ((Map) current).get(key); + } else { + return ""; // return blank if path breaks + } + } + return current != null ? current.toString() : ""; + } + + private static String renderHeroBanner(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + Map headline = getMap(data, "headline"); + Map subheading = getMap(data, "subheading"); + Map button = getMap(data, "ctaButton"); + List> images = getList(data, "decorativeImages"); + + sb.append("

").append(headline.get("text")) + .append("

"); + + sb.append("

").append(subheading.get("text")) + .append("

"); + + sb.append("").append(button.get("text")) + .append(""); + + for (Map img : images) { + sb.append("\"decorative\""); + } + + sb.append("
"); + return sb.toString(); + } + + private static String renderContactSignupSection(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append(""); + return sb.toString(); + } + + private static String renderCtaGradientSection(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + Map title = getMap(data, "title"); + sb.append("

").append(title.get("text")).append("

"); + + Map desc = getMap(data, "description"); + sb.append("

").append(desc.get("text")).append("

"); + + Map button = getMap(data, "button"); + sb.append("").append(button.get("label")) + .append(""); + + sb.append("
"); + return sb.toString(); + } + + private static String renderCtaBlock(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + // Heading + Map heading = getMap(data, "heading"); + sb.append("

").append(heading.get("text")) + .append("

"); + + // Description + Map description = getMap(data, "description"); + sb.append("

").append(description.get("text")) + .append("

"); + + // Buttons + List> buttons = getList(data, "buttons"); + sb.append("
"); + for (Map button : buttons) { + sb.append("").append(button.get("label")) + .append(""); + } + sb.append("
"); + + sb.append("
"); + return sb.toString(); + } + + private static String renderSubscriptionForm(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + // Left side: Heading + Description + sb.append("
"); + sb.append("

").append(getMap(data, "heading").get("text")).append("

"); + sb.append("

").append(getMap(data, "description").get("text")) + .append("

"); + sb.append("
"); + + // Right side: Form + sb.append("
"); + + List> fields = getList(getMap(data, "form"), "fields"); + for (Map field : fields) { + sb.append(""); + } + + Map button = getMap(getMap(data, "form"), "button"); + sb.append(""); + + // Disclaimer + Map disclaimer = getMap(getMap(data, "form"), "disclaimer"); + Map link = getMap(disclaimer, "link"); + sb.append("

").append(disclaimer.get("text")).append(" ").append(link.get("label")) + .append("

"); + + sb.append(""); + sb.append("
"); + return sb.toString(); + } + + private static String renderFeatureCardList(Map data) { + StringBuilder sb = new StringBuilder(); + + sb.append("
"); + + // Heading + Map heading = getMap(data, "heading"); + sb.append("

").append(get(heading, "text")).append("

"); + + // Features grid + List> features = getList(data, "features"); + sb.append("
"); + + for (Map feature : features) { + sb.append("
"); + + // Icon + Map icon = getMap(feature, "icon"); + sb.append("\"").append(get(icon,"); + + // Title + sb.append("

").append(get(feature, "title")).append("

"); + + // Description + sb.append("

").append(get(feature, "description")).append("

"); + + // Button + Map button = getMap(feature, "button"); + String arrow = Boolean.TRUE.equals(button.get("arrow")) ? " →" : ""; + sb.append(""); + + sb.append("
"); + } + + sb.append("
"); + return sb.toString(); + } + + private static String renderTestimonialCarousel(Map node) { + return ""; + } + + private static String renderBrandLogos(Map node) { + return "
Brand Logos
"; + } + + private static String renderCenteredCardGrid(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + sb.append(p("hero-label", get(data, "tagline", "text"))); + sb.append(h("h2", "hero-heading", get(data, "heading", "text"))); + sb.append(p("hero-description", get(data, "description", "text"))); + + List> cards = getList(data, "cards"); + if (!cards.isEmpty()) { + sb.append("
"); + for (Map card : cards) { + sb.append("
"); + Map image = getMap(card, "image"); + sb.append(img("card-img", image.get("src"), image.get("alt"))); + sb.append(h("h3", "card-title", card.get("title"))); + sb.append(p("card-description", card.get("description"))); + sb.append("
"); + } + sb.append("
"); + } + + List> buttons = getList(data, "buttons"); + if (!buttons.isEmpty()) { + sb.append("
"); + for (Map button : buttons) { + String btnClass = getBtnClass(button); + sb.append(a(btnClass, "#", button.get("label"))); + } + sb.append("
"); + } + + sb.append("
"); + return sb.toString(); + } + + private static String p(String cls, Object content) { + return "

" + content + "

"; + } + + private static String h(String tag, String cls, Object content) { + return "<" + tag + " class=\"" + cls + "\">" + content + ""; + } + + private static String img(String cls, Object src, Object alt) { + return "\"""; + } + + private static String a(String cls, String href, Object content) { + return "" + content + ""; + } + + private static String getBtnClass(Map btn) { + String style = String.valueOf(btn.get("style")); + return "filled".equals(style) ? "btn-filled" : "btn-outlined"; + } + + private static String renderFeatureAuto(Map data) { + // Smart detection based on structure + List> children = getChildren(data); + + for (Map child : children) { + String type = get(child, "type"); + String sclass = get(child, "class"); + String ref = get(child, "ref"); + + String sectionclass = !sclass.isEmpty() ? sclass : ref; + if ("img".equalsIgnoreCase(type) && "feature-image".equalsIgnoreCase(sectionclass)) { + return renderFeatureWithImage(data); // This is the new one + } + } + + return renderFeatureSection(data); // This is the old one + } + + private static String renderFeatureWithImage(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + List> children = getChildren(data); + + for (Map child : children) { + String type = get(child, "type"); + String className = get(child, "class"); + + if ("img".equalsIgnoreCase(type)) { + sb.append("\"")"); + } + if ("img".equals(type)) { + sb.append(renderImageDiv(child)); + } else if ("div".equals(type) && "placeholder-img".equals(className)) { + sb.append(renderImageDiv(child)); + } + + else if ("div".equalsIgnoreCase(type)) { + sb.append("
"); + List> contentChildren = getChildren(child); + for (Map c : contentChildren) { + String innerType = get(c, "type"); + String content = get(c, "content"); + + switch (innerType) { + case "p": + case "h2": + sb.append("<").append(innerType).append(" class=\"").append(get(c, "class")).append("\">") + .append(content).append(""); + break; + case "div": + sb.append("
"); + List> buttons = getChildren(c); + for (Map b : buttons) { + sb.append("").append(get(b, "content")).append(""); + } + sb.append("
"); + break; + } + } + sb.append("
"); + } + } + + sb.append("
"); + return sb.toString(); + } + + private static String renderFeatureGrid(Map node) { + return "
Features
"; + } + + private static String renderFeatureCarousel(Map node) { + return ""; + } + + private static String renderFeatureNumberedSteps(Map node) { + return "
  1. Step 1
"; + } + + private static String renderFaqAccordion(Map node) { + return "
FAQs
"; + } + + private static String renderTabbedSection(Map node) { + return "
Tabbed Section
"; + } + + private static String renderCounterStats(Map node) { + return "
Stats
"; + } + + private static String renderProgressBars(Map node) { + return "
Progress Bars
"; + } + + private static String renderCallToAction(Map node) { + return "
Call to Action
"; + } + + private static String renderDownloadApp(Map node) { + return "
App Download
"; + } + + private static String renderLeadMagnet(Map node) { + return "
Lead Magnet
"; + } + + private static String renderPromoBanner(Map node) { + return "
Promo
"; + } + + private static String renderTeamGrid(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
"); + + // Tag + if (section.containsKey("tag")) { + html.append("
").append(section.get("tag")).append("
"); + } + + // Heading + if (section.containsKey("title")) { + html.append("

").append(section.get("title")).append("

"); + } + + // Description + if (section.containsKey("description")) { + html.append("

").append(section.get("description")).append("

"); + } + + // Grid + List> members = (List>) section.get("members"); + html.append("
"); + + for (Map member : members) { + html.append("
"); + + html.append("\"").append(member.get("name"))"); + + html.append("
").append(member.get("name")).append("
"); + html.append("
").append(member.get("description")).append("
"); + + html.append("
"); // .team-member + } + + html.append("
"); // #team-member-grid + html.append("
"); + + return html.toString(); + } + + private static String renderTeamProfileList(Map node) { + return "
  • Team Member
"; + } + + private static String renderCompanyTimeline(Map node) { + return "
Timeline
"; + } + + private static String renderValuesSection(Map node) { + return "
Company Values
"; + } + + private static String renderPricingCards(Map node) { + return "
Pricing
"; + } + + private static String renderPricingComparison(Map node) { + return "
Plan
"; + } + + private static String renderContactForm(Map node) { + return "
"; + } + + private static String renderContactMap(Map node) { + return "
Map
"; + } + + private static String renderContactGrid(Map node) { + return "
Grid
"; + } + + private static String renderContactPage(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + // Hero + Map hero = getMap(data, "hero"); + sb.append("
"); + sb.append("
").append(getText(hero, "logo")).append("
"); + + List navLinks = getStringList(hero, "navLinks"); + sb.append("
    "); + for (String link : navLinks) { + sb.append("
  • ").append(link).append("
  • "); + } + sb.append("
"); + + sb.append("

").append(getText(hero, "title")).append("

"); + sb.append("
"); + + // Three-column layout + sb.append("
"); + List> sections = getListMap(data, "sections"); + + for (Map sec : sections) { + String type = getText(sec, "type"); + + if ("map".equalsIgnoreCase(type)) { + sb.append(""); + } + + else if ("info".equalsIgnoreCase(type)) { + Map details = getMap(sec, "details"); + sb.append("
").append("

") + .append(getText(sec, "heading")).append("

").append("

") + .append(getText(details, "phone")).append("

").append("

") + .append(getText(details, "email")).append("

").append("

") + .append(getText(details, "address")).append("

").append("
"); + } + + else if ("form".equalsIgnoreCase(type)) { + sb.append("
").append("

") + .append(getText(sec, "heading")).append("

"); + + List> fields = getListMap(sec, "fields"); + for (Map field : fields) { + String inputType = getText(field, "type"); + if ("textarea".equalsIgnoreCase(inputType)) { + sb.append(""); + } else { + sb.append(""); + } + } + + Map button = getMap(sec, "button"); + sb.append("") + .append(""); + } + } + + sb.append("
"); + return sb.toString(); + } + + public static String getText(Map map, String key, String defaultValue) { + Object val = map.get(key); + return (val instanceof String) ? (String) val : defaultValue; + } + + private static String renderContactUsSection(Map data) { + StringBuilder sb = new StringBuilder(); + + Map getInTouch = getMap(data, "getInTouch"); + List> columns = getListMap(getInTouch, "columns"); + + sb.append("
"); + sb.append("

").append(getText(getInTouch, "heading")).append("

"); + sb.append("
"); + for (Map col : columns) { + sb.append("
"); + sb.append("
").append(getText(col, "icon")).append("
"); + sb.append("

").append(getText(col, "title")).append("

"); + List lines = getStringList(col, "lines"); + for (String line : lines) { + sb.append("

").append(line).append("

"); + } + sb.append("
"); + } + sb.append("
"); + + Map messageUs = getMap(data, "messageUs"); + Map leftColumn = getMap(messageUs, "leftColumn"); + Map form = getMap(messageUs, "form"); + List> fields = getListMap(form, "fields"); + Map submit = getMap(form, "submit"); + + sb.append("
"); + sb.append("
"); + sb.append("

").append(getText(leftColumn, "heading")).append("

"); + sb.append("

").append(getText(leftColumn, "description")).append("

"); + sb.append("

").append(getText(leftColumn, "awardText")).append("

"); + sb.append("
"); + + sb.append("
"); + sb.append("
"); + for (Map field : fields) { + String type = getText(field, "type"); + String name = getText(field, "name", type); + String placeholder = getText(field, "placeholder"); + if ("textarea".equals(type)) { + int rows = getInt(field, "rows", 4); + sb.append(""); + } else { + sb.append(""); + } + } + sb.append(""); + sb.append("
"); + + return sb.toString(); + } + + @SuppressWarnings("unchecked") + public static int getInt(Map map, String key, int defaultValue) { + Object value = map.get(key); + if (value instanceof Number) { + return ((Number) value).intValue(); + } + try { + return Integer.parseInt(String.valueOf(value)); + } catch (Exception e) { + return defaultValue; + } + } + + private static String renderContactSplitSection(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + // LEFT PANEL + Map left = getMap(data, "leftPanel"); + sb.append("
"); + + List> sections = getListMap(left, "sections"); + for (Map sec : sections) { + sb.append("
"); + sb.append("

").append(getText(sec, "heading")).append("

"); + if (sec.containsKey("highlightColor")) { + sb.append("

").append(getText(sec, "content")).append("

"); + } else { + sb.append("

").append(getText(sec, "content")).append("

"); + } + sb.append("
"); + } + sb.append("
"); + + // RIGHT PANEL + Map right = getMap(data, "rightPanel"); + sb.append("
"); + sb.append("

").append(getText(right, "heading")).append("

"); + + sb.append("
"); + Map form = getMap(right, "form"); + List> fields = getListMap(form, "fields"); + + for (Map field : fields) { + String type = getText(field, "type"); + if ("textarea".equalsIgnoreCase(type)) { + sb.append(""); + } else { + sb.append(""); + } + } + + Map btn = getMap(form, "button"); + sb.append(""); + + sb.append("
"); // end right panel + sb.append("
"); + return sb.toString(); + } + + private static String renderContactInfoSection(Map data) { + StringBuilder sb = new StringBuilder(); + sb.append("
"); + + // Profile Image + Map image = getMap(data, "profileImage"); + if (!image.isEmpty()) { + sb.append("\"")"); + } + + // Heading + Map heading = getMap(data, "heading"); + sb.append("

").append(getText(heading, "text")).append("

"); + + // Description + Map desc = getMap(data, "description"); + sb.append("

").append(getText(desc, "text")).append("

"); + + // Columns + List> columns = getListMap(data, "columns"); + if (!columns.isEmpty()) { + sb.append("
"); + for (Map col : columns) { + sb.append("
"); + sb.append("").append(getText(col, "icon")).append(""); + sb.append("

").append(getText(col, "title")).append("

"); + sb.append("

").append(getText(col, "text")).append("

"); + sb.append("
"); + } + sb.append("
"); + } + + sb.append("
"); + return sb.toString(); + } + + private static String renderContactFormSection(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
"); + + html.append("
").append("

") + .append(getText(data, "tagline")).append("

").append("

") + .append(getTextMap(data, "heading", "text")).append("

").append("

") + .append(getTextMap(data, "description", "text")).append("

").append("
"); + + html.append("
"); + List> fields = getListMap(getMap(data, "form"), "fields"); + + for (Map field : fields) { + String type = getText(field, "type"); + String name = getText(field, "name"); + String label = getText(field, "label"); + String placeholder = getText(field, "placeholder"); + + switch (type) { + case "text": + case "email": + html.append(""); + break; + case "textarea": + html.append(""); + break; + case "checkbox": + html.append(""); + break; + } + } + + Map button = getMap(getMap(data, "form"), "button"); + html.append(""); + html.append(""); + + html.append("
"); + return html.toString(); + } + + @SuppressWarnings("unchecked") + public static String getTextMap(Map map, String key, String innerKey) { + Object inner = map.get(key); + if (inner instanceof Map) { + Object value = ((Map) inner).get(innerKey); + return value != null ? value.toString() : ""; + } + return ""; + } + + @SuppressWarnings("unchecked") + public static List> getListMap(Map map, String key) { + Object value = map.get(key); + if (value instanceof List) { + return (List>) value; + } + return new ArrayList<>(); + } + + private static String renderFooterMinimal(Map node) { + return "
Minimal Footer
"; + } + + private static String renderFooterCentered(Map node) { + return "
Centered Footer
"; + } + + private static String renderFooterColumns(Map node) { + return "
Footer Columns
"; + } + + private static String renderIconButton(Map node) { + return ""; + } + + private static String renderLabel(Map node) { + return "Label"; + } + + private static String renderBadge(Map node) { + return "Badge"; + } + + private static String renderRatingStars(Map node) { + return "
★★★★★
"; + } + + private static String renderClassicListPost(Map data) { + StringBuilder html = new StringBuilder(); + + html.append("
"); + + // Title + html.append("

").append(getString(data, "title", "List Post Title")).append("

"); + + // Hook/Intro + html.append("

") + .append(getString(data, "hook", "")).append("

"); + + // List Content + if (data.containsKey("content")) { + List> items = (List>) data.get("content"); + html.append("
"); + for (Map item : items) { + html.append("
"); + html.append("

").append(getString(item, "subheading", "")).append("

"); + html.append("

").append(getString(item, "description", "")).append("

"); + + if (item.containsKey("actionSteps")) { + List steps = (List) item.get("actionSteps"); + html.append("
    "); + for (String step : steps) { + html.append("
  • ").append(step).append("
  • "); + } + html.append("
"); + } + + html.append("
"); + } + html.append("
"); + } + + // Conclusion + if (data.containsKey("conclusion")) { + html.append("
") + .append(data.get("conclusion")).append("
"); + } + + // Call to action + if (data.containsKey("callToAction")) { + html.append("
") + .append(data.get("callToAction")).append("
"); + } + + html.append("
"); + return html.toString(); + } + + private static String renderListPost(Map data) { + StringBuilder html = new StringBuilder(); + + html.append("
"); + + // Title + html.append("

").append(getString(data, "title", "List Post Title")).append("

"); + + // Intro + if (data.containsKey("intro")) { + Map intro = (Map) data.get("intro"); + html.append("
"); + html.append("

") + .append(getString(intro, "hook", "")).append("

"); + html.append("

").append(getString(intro, "summary", "")).append("

"); + html.append("

").append(getString(intro, "benefitStatement", "")).append("

"); + html.append("
"); + } + + // List Items + if (data.containsKey("listItems")) { + List> items = (List>) data.get("listItems"); + html.append("
    "); + for (Map item : items) { + html.append("
  1. ").append("") + .append(getString(item, "title", "")).append("").append("

    ") + .append(getString(item, "description", "")).append("

    ").append("
  2. "); + } + html.append("
"); + } + + // Conclusion + if (data.containsKey("conclusion")) { + Map conclusion = (Map) data.get("conclusion"); + html.append("
"); + html.append("

").append(getString(conclusion, "summary", "")).append("

"); + html.append("

").append(getString(conclusion, "callToAction", "")) + .append("

"); + html.append("
"); + } + + html.append("
"); + return html.toString(); + } + + private static String renderPerfectBlogPost(Map data) { + StringBuilder html = new StringBuilder(); + + html.append("
"); + + // Title + html.append("

").append(getString(data, "title", "Perfect Blog Post")).append("

"); + + // Sections + if (data.containsKey("sections")) { + List> sections = (List>) data.get("sections"); + html.append("
"); + for (Map section : sections) { + html.append("
"); + html.append("

").append(getString(section, "label", "Section")) + .append("

"); + html.append("

").append(getString(section, "description", "")).append("

"); + html.append("
"); + } + html.append("
"); + } + + // Footer CTA + if (data.containsKey("footer")) { + html.append("
") + .append(getString(data, "footer", "")).append("
"); + } + + html.append("
"); + return html.toString(); + } + + private static String renderHeroCenteredSection(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
"); + + // Tagline + Map tagline = (Map) section.get("tagline"); + if (tagline != null) { + html.append("
").append(tagline.get("text")).append("
"); + } + + // Heading + Map heading = (Map) section.get("heading"); + if (heading != null) { + html.append("

").append(heading.get("text")).append("

"); + } + + // Description + Map description = (Map) section.get("description"); + if (description != null) { + html.append("

").append(description.get("text")).append("

"); + } + + // Buttons + List> buttons = (List>) section.get("buttons"); + if (buttons != null && !buttons.isEmpty()) { + html.append("
"); + for (Map btn : buttons) { + html.append("") + .append(btn.getOrDefault("label", "Click")).append(""); + } + html.append("
"); + } + + html.append("
"); + return html.toString(); + } + + private static String renderHeaderSection(Map section) { + StringBuilder html = new StringBuilder(); + String sectionClass = getString(section, "class", "hero-header"); + + html.append("
"); + + for (Map.Entry entry : section.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + + if ("class".equalsIgnoreCase(key)) + continue; + + if (value instanceof String) { + if (key.toLowerCase().contains("heading")) { + html.append("

").append(value).append("

"); + } else if (key.toLowerCase().contains("subheading") || key.toLowerCase().contains("paragraph")) { + html.append("

").append(value).append("

"); + } else { + html.append("
").append(value) + .append("
"); + } + } else if (value instanceof Map) { + Map nested = (Map) value; + String nestedClass = getString(nested, "class", key.toLowerCase().replace(" ", "-")); + html.append("
"); + + Object items = nested.get("items"); + if (items instanceof List) { + for (Object item : (List) items) { + html.append(""); + } + } + + html.append("
"); + } + } + + html.append("
"); + return html.toString(); + } + + private static String renderFromMap(Map node) { + StringBuilder html = new StringBuilder(); + + // Get tag from 'tag' or fallback to 'type' + String type = getString(node, "type", "div"); + String rawTag = getString(node, "tag", ""); + String tag = !rawTag.isEmpty() ? rawTag : TYPE_TAG_MAP.getOrDefault(type.toLowerCase(), type); + + html.append("<").append(tag); + + // Add class and id if present + String className = getString(node, "class", getString(node, "ref", "")); + String id = getString(node, "id", ""); + + if (!className.isEmpty()) + html.append(" class=\"").append(className).append("\""); + if (!id.isEmpty()) + html.append(" id=\"").append(id).append("\""); + + // Add other attributes (like src, alt for img) + for (Map.Entry entry : node.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (!Arrays.asList("type", "tag", "class", "id", "content", "children", "menu", "actions", "buttons") + .contains(key) && !(value instanceof Map || value instanceof List)) { + html.append(" ").append(key).append("=\"").append(value).append("\""); + } + } + + // Self-closing tag support (like img) + // Self-closing tag like + if ("img".equalsIgnoreCase(tag)) { + html.append(" src=\"").append(getString(node, "src", "")).append("\""); + html.append(" alt=\"").append(getString(node, "alt", "")).append("\""); + html.append(" />"); + return html.toString(); + } + + // Content rendering + if (node.containsKey("content")) { + html.append(node.get("content")); + } + + html.append(">"); + + // Render inline content if present + + // Special short-circuit rendering for link and button + if ("link".equalsIgnoreCase(type)) { + html.append("").append(node.get("content")).append(""); + return html.toString(); + } + + if ("text".equalsIgnoreCase(type)) { + html.append(getString(node, "content", "")); + return html.toString(); + } + + if ("logo".equalsIgnoreCase(type)) { + html.append("
").append(getString(node, "content", "Logo")) + .append("
"); + return html.toString(); + } + + if ("icon".equalsIgnoreCase(type)) { + String label = getString(node, "content", ""); + String emoji = getIconEmoji(label); + html.append("
").append(emoji).append(" ").append(label).append("
"); + return html.toString(); + } + + if ("a".equalsIgnoreCase(type)) { + String href = getString(node, "href", "#"); + html.append("").append(getString(node, "content", "")).append(""); + return html.toString(); + } + + if ("button".equalsIgnoreCase(type)) { + html.append(""); + return html.toString(); + } + + if (node.containsKey("content")) { + html.append(node.get("content")); + } + + // Handle structured known patterns + if (node.containsKey("logo")) { + html.append("
").append(node.get("logo")).append("
"); + } + + if (node.containsKey("heading")) { + html.append("

").append(node.get("heading")).append("

"); + } + + if (node.containsKey("subheading")) { + html.append("

").append(node.get("subheading")).append("

"); + } + + if (node.containsKey("text")) { + html.append("

").append(node.get("text")).append("

"); + } + + if (node.containsKey("menu")) { + html.append(renderMenu(node.get("menu"))); + } + + if (node.containsKey("actions")) { + html.append(renderActions(node.get("actions"))); + } + + if (node.containsKey("buttons")) { + html.append(renderButtons(node.get("buttons"))); + } + + if (node.containsKey("columns")) { + html.append(renderColumns(node.get("columns"))); + } + + if (node.containsKey("children")) { + html.append(buildHtml(node.get("children"))); + } + + html.append(""); + return html.toString(); + } + + private static String renderFromList(List list) { + StringBuilder html = new StringBuilder(); + for (Object item : list) { + html.append(buildHtml(item)); + } + return html.toString(); + } + + private static String renderButtons(Object obj) { + StringBuilder html = new StringBuilder(); + + // Case 1: Simple list of string labels + if (obj instanceof List) { + List btns = (List) obj; + html.append("
"); + for (Object item : btns) { + if (item instanceof String) { + html.append(""); + } else if (item instanceof Map) { + html.append(renderSingleButton((Map) item)); + } + } + html.append("
"); + } + + // Case 2: Object with "items" list and optional class + else if (obj instanceof Map) { + Map btnMap = (Map) obj; + List items = (List) btnMap.get("items"); + String btnClass = getString(btnMap, "class", "cta-buttons"); + + html.append("
"); + if (items != null) { + for (Object btn : items) { + if (btn instanceof String) { + html.append(""); + } else if (btn instanceof Map) { + html.append(renderSingleButton((Map) btn)); + } + } + } + html.append("
"); + } + + return html.toString(); + } + + private static String renderSingleButton(Map btn) { + String label = getString(btn, "label", "Button"); + String href = getString(btn, "action", "#"); + String style = getString(btn, "style", "filled"); + String bg = getString(btn, "backgroundColor", style.equals("outlined") ? "white" : "black"); + String color = getString(btn, "textColor", style.equals("outlined") ? "black" : "white"); + String border = style.equals("outlined") ? "1px solid " + getString(btn, "borderColor", "#000") : "none"; + + return new StringBuilder().append("").append(label).append("").toString(); + } + + private static String renderColumns(Object obj) { + StringBuilder html = new StringBuilder(); + html.append("
"); + + List> columns = (List>) obj; + for (Map col : columns) { + String type = getString(col, "type", ""); + if ("main".equalsIgnoreCase(type)) { + html.append("
"); + if (col.containsKey("contentBlocks")) { + List> blocks = (List>) col.get("contentBlocks"); + for (Map block : blocks) { + html.append("
").append("

") + .append(getString(block, "heading", "")).append("

").append("

") + .append(getString(block, "text", "")).append("

").append("
"); + } + } + html.append("
"); + } else if ("sidebar".equalsIgnoreCase(type)) { + html.append(""); + } + } + + html.append("
"); + return html.toString(); + } + + private static String renderMenu(Object obj) { + StringBuilder html = new StringBuilder("
    "); + + List menu = (List) obj; + for (Object item : menu) { + if (item instanceof String) { + html.append("
  • ").append(item).append("
  • "); + } else if (item instanceof Map) { + Map dropdownItem = (Map) item; + html.append("
  • "); + html.append("").append(dropdownItem.get("title")).append(""); + + if (dropdownItem.containsKey("dropdown")) { + html.append(renderDropdown(dropdownItem.get("dropdown"))); + } + html.append("
  • "); + } + } + + html.append(""); + return html.toString(); + } + + private static String renderDropdown(Object obj) { + StringBuilder html = new StringBuilder("
    "); + + Map dropdown = (Map) obj; + List> columns = (List>) dropdown.get("columns"); + + for (Map column : columns) { + html.append("
    "); + html.append("

    ").append(column.get("title")).append("

    "); + html.append("
      "); + + if (column.containsKey("items")) { + List> items = (List>) column.get("items"); + for (Map item : items) { + html.append("
    • ").append(item.get("icon")).append("").append("") + .append(item.get("title")).append("").append("

      ").append(item.get("description")) + .append("

      ").append("
    • "); + } + } else if (column.containsKey("blogs")) { + List> blogs = (List>) column.get("blogs"); + for (Map blog : blogs) { + html.append("
    • ").append(blog.get("title")).append("").append("

      ") + .append(blog.get("description")).append("

      ").append("") + .append(blog.get("cta")).append("
    • "); + } + if (column.containsKey("footerLink")) { + html.append(""); + } + } + + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderActions(Object obj) { + StringBuilder html = new StringBuilder("
    "); + + List> actions = (List>) obj; + for (Map action : actions) { + String label = getString(action, "label", "Button"); + String variant = getString(action, "variant", ""); + String btnClass = "join-btn"; + if (!variant.isEmpty()) { + btnClass += " " + variant; + } + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderNavbarBlock(Map nav) { + StringBuilder html = new StringBuilder(); + + // Inline styles + StringBuilder style = new StringBuilder(); + if (nav.containsKey("style")) { + Map styleMap = (Map) nav.get("style"); + for (Map.Entry s : styleMap.entrySet()) { + appendStyle(style, s.getKey(), s.getValue()); + } + } + + html.append(""); + return html.toString(); + } + + private static String renderFooterBlock(Map footer) { + StringBuilder html = new StringBuilder(); + + // Inline styles + StringBuilder style = new StringBuilder(); + appendStyle(style, "background", footer.get("background")); + appendStyle(style, "padding", footer.get("padding")); + appendStyle(style, "font-family", footer.get("fontFamily")); + + html.append("
    "); + + // Logo + if (footer.containsKey("Logo")) { + Map logo = (Map) footer.get("Logo"); + html.append("
    ") + .append(getString(logo, "text", "Logo")).append("
    "); + } + + // Address + if (footer.containsKey("Address")) { + html.append("

    ").append(getString(footer, "Address", "")).append("

    "); + } + + // Contact + if (footer.containsKey("Contact")) { + Map contact = (Map) footer.get("Contact"); + html.append("

    Phone: ").append(getString(contact, "phone", "")).append("

    "); + html.append("

    Email: ") + .append(getString(contact, "email", "")).append("

    "); + } + + // Social Links + if (footer.containsKey("SocialLinks")) { + List> social = (List>) footer.get("SocialLinks"); + html.append("
    "); + for (Map s : social) { + String platform = getString(s, "platform", ""); + String emoji = getIconEmoji(platform); + html.append("") + .append(emoji).append(""); + } + html.append("
    "); + } + + // Links + if (footer.containsKey("Links")) { + Map>> links = (Map>>) footer.get("Links"); + html.append("
    "); + for (Map.Entry>> col : links.entrySet()) { + html.append(""); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderMdBootstrapFooter(Map footer) { + StringBuilder html = new StringBuilder(); + String theme = getString(footer, "theme", "light"); + + html.append("
    "); + + // Top Bar + if (footer.containsKey("topBar")) { + Map topBar = (Map) footer.get("topBar"); + html.append("
    "); + + html.append("

    ").append(getString(topBar, "text", "")).append("

    "); + + if (topBar.containsKey("socialLinks")) { + List> socials = (List>) topBar.get("socialLinks"); + for (Map s : socials) { + String icon = getIconEmoji(getString(s, "platform", "")); + html.append("").append(icon).append(""); + } + } + html.append("
    "); + } + + // Columns + if (footer.containsKey("columns")) { + List> columns = (List>) footer.get("columns"); + html.append("
    "); + for (Map col : columns) { + html.append("
    "); + html.append("

    ").append(getString(col, "title", "")).append("

    "); + + if (col.containsKey("content")) { + html.append("

    ").append(getString(col, "content", "")).append("

    "); + } + + if (col.containsKey("links")) { + List> links = (List>) col.get("links"); + for (Map link : links) { + html.append("

    ") + .append(getString(link, "label", "")).append("

    "); + } + } + + if (col.containsKey("info")) { + Map info = (Map) col.get("info"); + html.append("

    ").append(getString(info, "address", "")).append("

    "); + html.append("

    ") + .append(getString(info, "email", "")).append("

    "); + html.append("

    ").append(getString(info, "phone", "")).append("

    "); + html.append("

    ").append(getString(info, "fax", "")).append("

    "); + } + + html.append("
    "); + } + html.append("
    "); + } + + // Bottom Bar + if (footer.containsKey("bottom")) { + Map bottom = (Map) footer.get("bottom"); + html.append("
    ").append("

    ").append(getString(bottom, "text", "")) + .append("

    ").append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderCompactFooter(Map footer) { + StringBuilder html = new StringBuilder(); + + String bg = getString(footer, "backgroundColor", "#222"); + String color = getString(footer, "textColor", "white"); + + html.append("
    "); + + // Logo and Slogan + if (footer.containsKey("logo")) { + Map logo = (Map) footer.get("logo"); + html.append("
    ").append("

    ").append(getString(logo, "text", "LOGO")) + .append("

    ").append("

    ").append(getString(logo, "slogan", "")).append("

    ") + .append("
    "); + } + + // Link Columns + if (footer.containsKey("linkColumns")) { + List> columns = (List>) footer.get("linkColumns"); + html.append("
    "); + for (Map col : columns) { + html.append(""); + } + html.append("
    "); + } + + // Social Icons + if (footer.containsKey("socialIcons")) { + List> icons = (List>) footer.get("socialIcons"); + html.append("
    "); + for (Map icon : icons) { + String label = getString(icon, "icon", ""); + String emoji = getIconEmoji(label); + html.append("").append(emoji).append(""); + } + html.append("
    "); + } + + // Copyright + if (footer.containsKey("copyright")) { + html.append("

    ").append(getString(footer, "copyright", "")) + .append("

    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderContactSection(Map section) { + StringBuilder html = new StringBuilder(); + + String bg = getString(section, "background", "#fff"); + String color = getString(section, "textColor", "#000"); + String font = getString(section, "fontFamily", "sans-serif"); + + html.append("
    "); + + html.append("
    "); + + // LEFT COLUMN + if (section.containsKey("left")) { + Map left = (Map) section.get("left"); + html.append("
    "); + + if (left.containsKey("heading")) { + html.append("

    ").append(getString(left, "heading", "")).append("

    "); + } + if (left.containsKey("description")) { + html.append("

    ").append(getString(left, "description", "")).append("

    "); + } + + if (left.containsKey("ctaButton")) { + Map btn = (Map) left.get("ctaButton"); + Map style = (Map) btn.get("style"); + html.append("") + .append(getString(btn, "label", "Click")).append(""); + } + + html.append("
    "); + } + + // RIGHT COLUMN + if (section.containsKey("right")) { + Map right = (Map) section.get("right"); + html.append("
    "); + + if (right.containsKey("contactDetails")) { + Map details = (Map) right.get("contactDetails"); + + if (details.containsKey("email")) { + Map email = (Map) details.get("email"); + html.append("

    ").append(getString(email, "label", "Email")).append(": ") + .append("") + .append(getString(email, "value", "")).append("

    "); + } + if (details.containsKey("phone")) { + Map phone = (Map) details.get("phone"); + html.append("

    ").append(getString(phone, "label", "Phone")).append(": ") + .append("") + .append(getString(phone, "value", "")).append("

    "); + } + if (details.containsKey("address")) { + Map addr = (Map) details.get("address"); + html.append("

    ").append(getString(addr, "label", "Address")).append(":
    "); + List lines = (List) addr.get("lines"); + for (String line : lines) { + html.append(line).append("
    "); + } + html.append("

    "); + } + } + + if (right.containsKey("socialLinks")) { + List> socials = (List>) right.get("socialLinks"); + html.append("
    "); + for (Map s : socials) { + String icon = getString(s, "icon", ""); + String emoji = getIconEmoji(icon); + html.append("").append(emoji).append(""); + } + html.append("
    "); + } + + html.append("
    "); + } + + html.append("
    "); + html.append("
    "); + + return html.toString(); + } + + private static String renderHowToBlogPost(Map blog) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + html.append("

    ").append(getString(blog, "title", "How to Do Something")).append("

    "); + html.append("

    ") + .append(getString(blog, "hook", "")).append("

    "); + + // Content Section + if (blog.containsKey("content")) { + Map content = (Map) blog.get("content"); + html.append("
    "); + for (Map.Entry entry : content.entrySet()) { + html.append("
    ").append("

    ").append(formatKey(entry.getKey())).append("

    ") + .append("

    ").append(entry.getValue()).append("

    ").append("
    "); + } + html.append("
    "); + } + + // Conclusion Section + if (blog.containsKey("conclusion")) { + Map conclusion = (Map) blog.get("conclusion"); + html.append("
    "); + + if (conclusion.containsKey("recap")) { + html.append("

    Summary: ").append(conclusion.get("recap")).append("

    "); + } + if (conclusion.containsKey("cta")) { + html.append("

    ").append(conclusion.get("cta")).append("

    "); + } + + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderBlogListSection(Map section) { + StringBuilder html = new StringBuilder(); + + html.append("
    "); + + // Title and Subtitle + html.append("
    "); + html.append("

    ").append(getString(section, "title", "Blog List")).append("

    "); + html.append("

    ").append(getString(section, "subtitle", "")).append("

    "); + html.append("
    "); + + // Blogs + if (section.containsKey("blogs")) { + List> blogs = (List>) section.get("blogs"); + + html.append("
    "); + + for (Map blog : blogs) { + html.append("
    "); + + String img = getString(blog, "image", ""); + if (!img.isEmpty()) { + html.append("\"blog"); + } + + html.append("

    ").append(getString(blog, "category", "")) + .append("

    "); + html.append("

    ").append(getString(blog, "title", "")).append("

    "); + html.append("

    ").append(getString(blog, "description", "")).append("

    "); + html.append("

    By ") + .append(getString(blog, "author", "")).append(" • ") + .append(getString(blog, "date", "")).append(" • ").append(getString(blog, "readTime", "")) + .append("

    "); + + html.append("
    "); + } + + html.append("
    "); + } + + // CTA Button + if (section.containsKey("cta")) { + Map cta = (Map) section.get("cta"); + html.append(""); + } + + html.append("
    "); + + return html.toString(); + } + + private static String renderBlogPreviewSection(Map section) { + StringBuilder html = new StringBuilder(); + + html.append("
    "); + + // Section Label + String sectionLabel = getString(section, "sectionLabel", ""); + if (!sectionLabel.isEmpty()) { + html.append("

    ").append(sectionLabel) + .append("

    "); + } + + // Heading + html.append("

    ").append(getString(section, "heading", "Our Blogs")).append("

    "); + html.append("

    ").append(getString(section, "subtext", "")).append("

    "); + + // Blog Grid + if (section.containsKey("blogs")) { + List> blogs = (List>) section.get("blogs"); + + html.append( + "
    "); + + for (Map blog : blogs) { + html.append("
    "); + + String image = getString(blog, "image", ""); + if (!image.isEmpty()) { + html.append("\"blog\""); + } + + html.append("

    ").append(getString(blog, "category", "")) + .append(" • ").append(getString(blog, "readTime", "")).append("

    "); + + html.append("

    ").append(getString(blog, "title", "")).append("

    "); + html.append("

    ").append(getString(blog, "excerpt", "")).append("

    "); + + html.append("Read more"); + + html.append("
    "); + } + + html.append("
    "); + } + + // View All CTA + if (section.containsKey("viewAll")) { + Map viewAll = (Map) section.get("viewAll"); + html.append(""); + } + + html.append("
    "); + + return html.toString(); + } + + private static String renderBlogHomePage(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Logo + String logo = getString(data, "logo", "Logo"); + html.append("

    ").append(logo).append("

    "); + + // Nav Menu + if (data.containsKey("navMenu")) { + List navItems = (List) data.get("navMenu"); + html.append( + ""); + } + + // Top Bar Icons + if (data.containsKey("topBarIcons")) { + List icons = (List) data.get("topBarIcons"); + html.append("
    "); + for (String icon : icons) { + String emoji = getIconEmoji(icon); + html.append("").append(emoji).append(""); + } + html.append("
    "); + } + + // Hero Section + if (data.containsKey("heroSection")) { + Map hero = (Map) data.get("heroSection"); + html.append("
    "); + html.append("

    ") + .append(getString(hero, "label", "")).append("

    "); + html.append("

    ").append(getString(hero, "title", "")).append("

    "); + html.append("

    ").append(getString(hero, "excerpt", "")).append("

    "); + html.append("

    By ").append(getString(hero, "author", "")) + .append(" • ").append(getString(hero, "date", "")).append("

    "); + html.append("
    "); + } + + // Editor Pick + if (data.containsKey("editorPick")) { + List> picks = (List>) data.get("editorPick"); + html.append("

    Editor's Pick

    "); + for (Map post : picks) { + html.append("
    "); + html.append("\"thumb\""); + html.append("

    ").append(getString(post, "title", "")).append("

    "); + html.append("
    "); + } + html.append("
    "); + } + + // Trending Section + if (data.containsKey("trending")) { + List> trending = (List>) data.get("trending"); + html.append("

    Trending

    "); + for (Map t : trending) { + html.append( + "
    "); + html.append("\"trend\""); + html.append("").append(getString(t, "rank", "1")).append("."); + html.append("").append(getString(t, "title", "")).append(""); + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderBlogPage(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Header + if (data.containsKey("header")) { + Map header = (Map) data.get("header"); + html.append( + "
    "); + + // Logo + html.append("

    ").append(getString(header, "logo", "Logo")).append("

    "); + + // Menu + if (header.containsKey("menu")) { + List menu = (List) header.get("menu"); + html.append(""); + } + + // Icons + html.append("
    "); + + if (header.containsKey("socialIcons")) { + List icons = (List) header.get("socialIcons"); + for (String icon : icons) { + html.append("").append(getIconEmoji(icon)).append(""); + } + } + if (header.containsKey("actions")) { + List actions = (List) header.get("actions"); + for (String action : actions) { + html.append("").append(getIconEmoji(action)).append(""); + } + } + + html.append("
    "); + html.append("
    "); + } + + // Hero Section + if (data.containsKey("heroSection")) { + Map hero = (Map) data.get("heroSection"); + html.append("
    "); + + // Main Post + if (hero.containsKey("mainPost")) { + Map main = (Map) hero.get("mainPost"); + html.append("
    "); + html.append(""); + html.append("

    ").append(getString(main, "category", "")) + .append("

    "); + html.append("

    ").append(getString(main, "title", "")).append("

    "); + html.append("

    By ").append(getString(main, "author", "")) + .append("

    "); + html.append("
    "); + } + + // Featured Side Posts + if (hero.containsKey("featuredPosts")) { + List> side = (List>) hero.get("featuredPosts"); + html.append("
    "); + for (Map post : side) { + html.append("
    "); + html.append(""); + html.append("

    ").append(getString(post, "title", "")).append("

    "); + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + } + + // Post Grid + if (data.containsKey("postGrid")) { + List> posts = (List>) data.get("postGrid"); + html.append( + "
    "); + for (Map post : posts) { + html.append("
    "); + html.append(""); + html.append("

    ").append(getString(post, "title", "")).append("

    "); + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderBlogCardSection(Map blog) { + StringBuilder html = new StringBuilder(); + + html.append("
    "); + + // Heading + if (blog.containsKey("heading")) { + Map heading = (Map) blog.get("heading"); + html.append("
    "); + html.append("

    ").append(getString(heading, "title", "My Blog")).append("

    "); + html.append("

    ") + .append(getString(heading, "description", "")).append("

    "); + html.append("
    "); + } + + // Posts + if (blog.containsKey("posts")) { + List> posts = (List>) blog.get("posts"); + + html.append( + "
    "); + for (Map post : posts) { + html.append( + "
    "); + + html.append(""); + + html.append("
    "); + html.append("

    ").append(getString(post, "date", "")) + .append(" | ").append(getString(post, "category", "")).append("

    "); + html.append("

    ").append(getString(post, "title", "")).append("

    "); + html.append("

    ").append(getString(post, "description", "")) + .append("

    "); + html.append( + "") + .append(getString(post, "cta", "Read More")).append(""); + html.append("
    "); + + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderBlogThumbnailGrid(Map data) { + StringBuilder html = new StringBuilder(); + + // Outer Section + html.append("
    "); + + // Find the

    heading + List> children = (List>) data.getOrDefault("children", + new ArrayList<>()); + + for (Map child : children) { + String type = getString(child, "type", ""); + + if ("h2".equalsIgnoreCase(type)) { + String title = getString(child, "content", "Featured Insights"); + html.append("

    ").append(title).append("

    "); + } + + // Grid Block + if ("div".equalsIgnoreCase(type) && "blog-grid".equalsIgnoreCase(getString(child, "class", ""))) { + List> blogCards = (List>) child.getOrDefault("children", + new ArrayList<>()); + + html.append("
    "); + + for (Map card : blogCards) { + html.append( + "
    "); + + List> cardChildren = (List>) card.getOrDefault("children", + new ArrayList<>()); + + for (Map cardChild : cardChildren) { + String childType = getString(cardChild, "type", ""); + + if ("a".equalsIgnoreCase(childType)) { + String href = getString(cardChild, "href", "#"); + html.append(""); + + List> innerChildren = (List>) cardChild + .getOrDefault("children", new ArrayList<>()); + + for (Map inner : innerChildren) { + if ("img".equalsIgnoreCase(getString(inner, "type", ""))) { + String src = getString(inner, "src", "default-placeholder.png"); + String alt = getString(inner, "alt", "Image"); + html.append("\"").append(alt)"); + } + } + + html.append(""); + } + + if ("div".equalsIgnoreCase(childType) + && "blog-card-content".equalsIgnoreCase(getString(cardChild, "class", ""))) { + List> contentItems = (List>) cardChild + .getOrDefault("children", new ArrayList<>()); + + html.append("
    "); + + for (Map contentItem : contentItems) { + String contentType = getString(contentItem, "type", ""); + + if ("p".equalsIgnoreCase(contentType)) { + String category = getString(contentItem, "content", ""); + html.append("

    ") + .append(category).append("

    "); + } + + if ("h4".equalsIgnoreCase(contentType)) { + List> h4Children = (List>) contentItem + .getOrDefault("children", new ArrayList<>()); + for (Map h4Child : h4Children) { + String href = getString(h4Child, "href", "#"); + String title = getString(h4Child, "content", "Blog Title"); + html.append("

    ") + .append(title).append("

    "); + } + } + + if ("a".equalsIgnoreCase(contentType) + && "read-more".equalsIgnoreCase(getString(contentItem, "class", ""))) { + String href = getString(contentItem, "href", "#"); + String label = getString(contentItem, "content", "Read More →"); + html.append("") + .append(label).append(""); + } + } + + html.append("
    "); // end card content div + } + } + + html.append("
    "); // end blog-card + } + + html.append("
    "); // end grid div + } + } + + html.append("

    "); // end section + return html.toString(); + } + + private static String renderBlogSection(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Optional heading + if (section.containsKey("sectionLabel") || section.containsKey("title") || section.containsKey("heading")) { + html.append("
    "); + + if (section.containsKey("sectionLabel")) { + html.append("

    ").append(section.get("sectionLabel")) + .append("

    "); + } + if (section.containsKey("breadcrumb")) { + html.append("

    ").append(section.get("breadcrumb")) + .append("

    "); + } + + if (section.containsKey("heading")) { + Object headingObj = section.get("heading"); + if (headingObj instanceof Map) { + Map heading = (Map) headingObj; + html.append("

    ").append(heading.getOrDefault("title", "")) + .append(" ").append(heading.getOrDefault("highlighted", "")) + .append("

    "); + html.append("

    ").append(heading.getOrDefault("description", "")).append("

    "); + } else { + html.append("

    ").append(section.get("heading")).append("

    "); + } + } else if (section.containsKey("title")) { + html.append("

    ").append(section.get("title")).append("

    "); + } + + if (section.containsKey("subtext")) { + html.append("

    ").append(section.get("subtext")).append("

    "); + } + html.append("
    "); + } + + // Blogs/Articles list + List> posts = null; + if (section.containsKey("blogs")) { + posts = (List>) section.get("blogs"); + } else if (section.containsKey("articles")) { + posts = (List>) section.get("articles"); + } else if (section.containsKey("posts")) { + posts = (List>) section.get("posts"); + } + + if (posts != null && !posts.isEmpty()) { + html.append( + "
    "); + + for (Map post : posts) { + String title = getString(post, "title", "Untitled"); + String image = getString(post, "image", ""); + String link = getString(post, "link", "#"); + String category = getString(post, "category", ""); + String date = getString(post, "date", ""); + String readTime = getString(post, "readTime", ""); + String description = getString(post, "description", getString(post, "excerpt", "")); + + html.append( + "
    "); + if (!image.isEmpty()) { + html.append(""); + } + html.append("
    "); + if (!category.isEmpty()) + html.append("

    ").append(category).append("

    "); + html.append("

    ").append(title).append("

    "); + if (!description.isEmpty()) + html.append("

    ").append(description).append("

    "); + if (!date.isEmpty() || !readTime.isEmpty()) { + html.append("

    ").append(date).append(" ").append(readTime) + .append("

    "); + } + if (post.containsKey("cta")) { + html.append("") + .append(post.get("cta")).append(""); + } + if (post.containsKey("readMoreLink")) { + html.append("Read more"); + } + html.append("
    "); + } + html.append("
    "); + } + + // Optional CTA/View All + if (section.containsKey("viewAll") || section.containsKey("cta")) { + Map viewAll = (Map) section.getOrDefault("viewAll", section.get("cta")); + String text = getString(viewAll, "text", "View All"); + String link = getString(viewAll, "link", "#"); + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderArticlePage(Map articlePage) { + StringBuilder html = new StringBuilder(); + + html.append( + "
    "); + + // Title & Subtitle + html.append("
    "); + html.append("

    ").append(getString(articlePage, "title", "Untitled")).append("

    "); + html.append("

    ").append(getString(articlePage, "subtitle", "")) + .append("

    "); + html.append("
    "); + + // Cover Image + String coverImage = getString(articlePage, "coverImage", ""); + if (!coverImage.isEmpty()) { + html.append("\"cover\""); + } + + // Author + Metadata + if (articlePage.containsKey("author")) { + Map author = (Map) articlePage.get("author"); + html.append("
    "); + html.append(""); + html.append("
    "); + html.append("").append(getString(author, "name", "")).append("
    "); + html.append("").append(getString(author, "role", "")).append(""); + html.append("
    "); + html.append("
    "); + } + + // Publish Date + html.append("

    Published on ") + .append(getString(articlePage, "publishedDate", "")).append("

    "); + + // Main Content + if (articlePage.containsKey("content")) { + List> content = (List>) articlePage.get("content"); + + for (Map block : content) { + String type = getString(block, "type", ""); + switch (type) { + case "paragraph": + html.append("

    ") + .append(getString(block, "text", "")).append("

    "); + break; + case "image": + html.append("
    "); + html.append(""); + String caption = getString(block, "caption", ""); + if (!caption.isEmpty()) { + html.append( + "
    ") + .append(caption).append("
    "); + } + html.append("
    "); + break; + case "heading": + html.append("

    ") + .append(getString(block, "text", "")).append("

    "); + break; + } + } + } + + // Sidebar + if (articlePage.containsKey("sidebar")) { + Map sidebar = (Map) articlePage.get("sidebar"); + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTemplateLibrary(Map lib) { + StringBuilder html = new StringBuilder(); + + html.append( + "
    "); + + // Title and subtitle + html.append("
    "); + html.append("

    ").append(getString(lib, "title", "")).append("

    "); + html.append("

    ").append(getString(lib, "subtitle", "")).append("

    "); + html.append("
    "); + + // Search input + html.append("
    "); + html.append(""); + html.append("
    "); + + // Categories + if (lib.containsKey("categories")) { + List categories = (List) lib.get("categories"); + html.append( + "
    "); + for (String cat : categories) { + html.append( + ""); + } + html.append("
    "); + } + + // Templates + if (lib.containsKey("templates")) { + List> templates = (List>) lib.get("templates"); + + html.append( + "
    "); + for (Map template : templates) { + html.append( + "
    "); + + html.append("\"icon\""); + html.append("

    ").append(getString(template, "title", "")) + .append("

    "); + html.append("

    ").append(getString(template, "description", "")) + .append("

    "); + html.append("").append(getString(template, "category", "")) + .append(""); + + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderBlogHeader(Map header) { + StringBuilder html = new StringBuilder(); + + Map style = (Map) header.getOrDefault("style", new HashMap<>()); + String font = getString(style, "font", "sans-serif"); + String primaryColor = getString(style, "primaryColor", "#000"); + String accentColor = getString(style, "accentColor", "#ccc"); + String alignment = getString(style, "alignment", "left"); + + // Background images + Map background = (Map) header.getOrDefault("background", new HashMap<>()); + String topBg = getString(background, "top", ""); + String bottomBg = getString(background, "bottom", ""); + + html.append("
    "); + + if (!topBg.isEmpty()) { + html.append(""); + } + + if (header.containsKey("date")) { + html.append("

    ") + .append(header.get("date")).append("

    "); + } + + if (header.containsKey("title")) { + html.append("

    ").append(header.get("title")).append("

    "); + } + + if (header.containsKey("subtitle")) { + html.append("

    ") + .append(header.get("subtitle")).append("

    "); + } + + if (!bottomBg.isEmpty()) { + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderHeroSection(Map section) { + String layout = getString(section, "layout", "centered").toLowerCase(); + switch (layout) { + case "two-column": + return renderTwoColumnHeroV2(section); + case "centered": + default: + return renderCenteredHeroSection(section); // fallback + } + } + + private static String renderCenteredHeroSection(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Heading + if (section.containsKey("heading")) { + Map heading = (Map) section.get("heading"); + html.append("

    ") + .append(getString(heading, "text", "")).append("

    "); + } + + // Description + if (section.containsKey("description")) { + Map desc = (Map) section.get("description"); + html.append("

    ").append(getString(desc, "text", "")) + .append("

    "); + } + + // Buttons + if (section.containsKey("buttons")) { + List> buttons = (List>) section.get("buttons"); + html.append( + "
    "); + for (Map btn : buttons) { + String style = getString(btn, "style", "filled"); + String bg = getString(btn, "backgroundColor", "#000"); + String color = getString(btn, "textColor", "#fff"); + String border = "outlined".equals(style) ? "1px solid " + getString(btn, "borderColor", "#000") + : "none"; + html.append("") + .append(getString(btn, "label", "Button")).append(""); + } + html.append("
    "); + } + + // Image + if (section.containsKey("image")) { + Map img = (Map) section.get("image"); + html.append("\"")"); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTwoColumnHeroV2(Map section) { + String bg = getString(section, "backgroundColor", "#fff"); + String font = getString(section, "fontFamily", "sans-serif"); + + Map left = (Map) section.get("leftColumn"); + Map right = (Map) section.get("rightColumn"); + + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // --- LEFT COLUMN --- + html.append("
    "); + + // Heading + if (left.containsKey("heading")) { + Map heading = (Map) left.get("heading"); + String text = getString(heading, "text", ""); + String highlight = getString(heading, "highlight", ""); + if (!highlight.isEmpty()) { + text = text.replace(highlight, "" + highlight + ""); + } + html.append("

    ").append(text).append("

    "); + } + + // Subheading + if (left.containsKey("subheading")) { + Map sub = (Map) left.get("subheading"); + html.append("

    ").append(getString(sub, "text", "")) + .append("

    "); + } + + // Buttons + if (left.containsKey("buttons")) { + html.append("
    "); + List> buttons = (List>) left.get("buttons"); + for (Map btn : buttons) { + String style = getString(btn, "style", "filled"); + String bgCol = getString(btn, "backgroundColor", "#000"); + String txtCol = getString(btn, "textColor", "#fff"); + String brdCol = getString(btn, "borderColor", ""); + String borderRadius = getString(btn, "borderRadius", "4px"); + String label = getString(btn, "label", "Button"); + + html.append("").append(label).append(""); + } + html.append("
    "); + } + + // Partners + if (left.containsKey("partners")) { + Map partners = (Map) left.get("partners"); + html.append("
    ").append(getString(partners, "label", "")) + .append("
    "); + + List> logos = (List>) partners.get("logos"); + for (Map logo : logos) { + html.append("\"")"); + } + html.append("
    "); + } + + html.append("
    "); // end left + + // --- RIGHT COLUMN --- + html.append("
    "); + if (right.containsKey("illustration")) { + Map illus = (Map) right.get("illustration"); + Map styleMap = (Map) illus.get("style"); + + StringBuilder style = new StringBuilder(); + if (styleMap != null) { + style.append("border-radius:").append(getString(styleMap, "borderRadius", "0")).append("; "); + style.append("background:").append(getString(styleMap, "backgroundColor", "#fff")).append("; "); + style.append("padding:").append(getString(styleMap, "padding", "0")).append(";"); + } + + html.append("\"")"); + } + + if (right.containsKey("caption")) { + Map cap = (Map) right.get("caption"); + html.append("

    ") + .append(getString(cap, "text", "")).append("

    "); + } + html.append("
    "); // end right + + html.append("
    "); + + // Decorations + if (section.containsKey("decorations")) { + List> shapes = (List>) section.get("decorations"); + for (Map shape : shapes) { + html.append("
    "); + } + } + + // Scroll Indicator + if (section.containsKey("scrollIndicator")) { + Map si = (Map) section.get("scrollIndicator"); + html.append("
    "); + } + + return html.toString(); + } + + private static String renderTwoColumnHeroSection(Map section) { + String bg = getString(section, "background", "#fff"); + String font = getString(section, "fontFamily", "sans-serif"); + + Map left = (Map) section.get("leftColumn"); + Map right = (Map) section.get("rightColumn"); + + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Left Column + html.append("
    "); + + if (left.containsKey("heading")) { + html.append("

    ") + .append(getString(left, "heading", "")).append("

    "); + } + + if (left.containsKey("description")) { + html.append("

    ") + .append(getString(left, "description", "")).append("

    "); + } + + if (left.containsKey("buttons")) { + html.append(renderButtons(left.get("buttons"))); + } + html.append("
    "); + + // Right Column + html.append("
    "); + if (right != null && "image".equalsIgnoreCase(getString(right, "type", ""))) { + html.append("\"")"); + } + html.append("
    "); + + html.append("
    "); + return html.toString(); + } + + private static String renderHeroLeftCards(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + html.append("
    "); + + // Left Column + if (section.containsKey("leftColumn")) { + Map left = (Map) section.get("leftColumn"); + html.append("
    "); + + if (left.containsKey("logo")) { + Map logo = (Map) left.get("logo"); + html.append("\"").append(logo.get("alt"))"); + } + + if (left.containsKey("label")) { + html.append("").append(left.get("label")).append(""); + } + + if (left.containsKey("title")) { + Map title = (Map) left.get("title"); + html.append("

    ").append(title.get("text")).append("

    "); + } + + html.append("
    "); + } + + // Right Column + if (section.containsKey("rightColumn")) { + Map right = (Map) section.get("rightColumn"); + List> cards = (List>) right.get("cards"); + + html.append("
    "); + for (Map card : cards) { + html.append("
    "); + + if (card.containsKey("title")) { + html.append("

    ").append(card.get("title")).append("

    "); + } + + if (card.containsKey("image")) { + Map img = (Map) card.get("image"); + html.append("\"").append(img.get("alt"))"); + } + + if (card.containsKey("buttons")) { + html.append("
    "); + List> buttons = (List>) card.get("buttons"); + for (Map btn : buttons) { + String btnClass = getString(btn, "class", "btn"); + html.append("").append(btn.get("label")).append(""); + } + html.append("
    "); + } + + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderHeroCenteredWithArt(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Artworks + if (section.containsKey("artwork")) { + Map art = (Map) section.get("artwork"); + + if (art.containsKey("left")) { + Map left = (Map) art.get("left"); + html.append("\"")"); + } + if (art.containsKey("right")) { + Map right = (Map) art.get("right"); + html.append("\"")"); + } + } + + // Heading + if (section.containsKey("heading")) { + Map heading = (Map) section.get("heading"); + html.append("

    ").append(getString(heading, "text", "").replace("\n", "
    ")) + .append("

    "); + } + + // CTA + if (section.containsKey("ctaButton")) { + Map btn = (Map) section.get("ctaButton"); + html.append("") + .append(btn.get("label")).append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderSubSectionCentered(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + if (section.containsKey("title")) { + html.append("

    ").append(section.get("title")).append("

    "); + } + + if (section.containsKey("description")) { + html.append("

    ").append(section.get("description")).append("

    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderSimpleTestimonial(Map data) { + StringBuilder html = new StringBuilder(); + String theme = getString(data, "theme", "light"); + html.append("
    "); + + // Heading + if (data.containsKey("heading")) { + html.append("

    ").append(data.get("heading")).append("

    "); + } + + // Check for multiple cards + if (data.containsKey("cards")) { + List> cards = (List>) data.get("cards"); + html.append("
    "); + + for (Map card : cards) { + html.append("
    "); + html.append("
    ★★★★★
    "); + html.append("

    ").append(card.get("quote")).append("

    "); + + if (card.containsKey("author")) { + Map author = (Map) card.get("author"); + html.append("
    "); + + if (author.containsKey("image")) { + html.append("\"")"); + } + + html.append("").append(author.get("name")).append(""); + html.append("

    ").append(author.get("position")).append("

    "); + html.append("
    "); + } + + html.append("
    "); + } + + html.append("
    "); + } + // Fallback: single quote + author + optional logo + else { + if (data.containsKey("logo")) { + Map logo = (Map) data.get("logo"); + html.append("
    ").append("\"").append(logo.get("alt")).append("\"").append("
    "); + } + + html.append("
    ").append(data.getOrDefault("quote", "")) + .append("
    "); + + if (data.containsKey("author")) { + Map author = (Map) data.get("author"); + html.append("
    "); + + if (author.containsKey("image")) { + html.append("\"author\""); + } + + html.append("
    ").append("").append(author.get("name")) + .append("
    ").append("").append(author.get("position")).append("") + .append("
    ").append("
    "); + } + } + + html.append("
    "); + return html.toString(); + } + + private static String renderClientTestimonial(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Background image + if (data.containsKey("backgroundImage")) { + html.append("
    "); + } + + // Logo + if (data.containsKey("logo")) { + html.append("\"logo\"/"); + } + + // Title + html.append("

    ").append(data.get("title")).append("

    "); + + // Cards + if (data.containsKey("testimonials")) { + List> testimonials = (List>) data.get("testimonials"); + html.append("
    "); + for (Map t : testimonials) { + html.append("
    "); + html.append("\"")"); + html.append("
    ").append(t.get("quote")).append("
    "); + html.append("
    "); + html.append("").append(t.get("name")).append("
    "); + html.append("").append("★★★★★".substring(0, (int) t.get("rating"))) + .append(""); + html.append("
    "); + } + html.append("
    "); + } + + // CTA + if (data.containsKey("cta")) { + Map cta = (Map) data.get("cta"); + html.append(""); + } + + // Contact Info + if (data.containsKey("contactInfo")) { + Map contact = (Map) data.get("contactInfo"); + html.append("
    ").append("

    ").append(contact.get("phone")).append("

    ") + .append("

    ") + .append(contact.get("email")).append("

    ").append("

    ").append(contact.get("website")) + .append("

    ").append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTestimonialLanding(Map data) { + StringBuilder html = new StringBuilder(); + String theme = getString(data, "theme", "orange"); + + html.append("
    "); + + // Title + html.append("

    ").append(data.get("title")).append("

    "); + + // Description + if (data.containsKey("description")) { + html.append("

    ").append(data.get("description")).append("

    "); + } + + // Testimonials + if (data.containsKey("testimonials")) { + List> testimonials = (List>) data.get("testimonials"); + html.append("
    "); + for (Map t : testimonials) { + boolean highlight = Boolean.TRUE.equals(t.get("highlight")); + html.append("
    "); + html.append("
    ").append(t.get("quote")).append("
    "); + html.append("

    — ").append(t.get("name")).append("

    "); + html.append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderFaqSection(Map section) { + StringBuilder html = new StringBuilder(); + + html.append("
    "); + + // Title + if (section.containsKey("title")) { + html.append("

    ").append(section.get("title")).append("

    "); + } + + // Subtitle + if (section.containsKey("subtitle")) { + html.append("

    ") + .append(section.get("subtitle")).append("

    "); + } + + // Questions + if (section.containsKey("questions")) { + List> questions = (List>) section.get("questions"); + html.append("
    "); + + for (Map qa : questions) { + html.append("
    "); + html.append("

    ").append(qa.get("question")).append("

    "); + html.append("

    ").append(qa.get("answer")).append("

    "); + html.append("
    "); + } + + html.append("
    "); + } + + // CTA + if (section.containsKey("cta")) { + Map cta = (Map) section.get("cta"); + + html.append("
    "); + html.append("

    ").append(cta.get("title")).append("

    "); + html.append("

    ").append(cta.get("subtitle")).append("

    "); + + if (cta.containsKey("button")) { + Map btn = (Map) cta.get("button"); + html.append("") + .append(btn.get("label")).append(""); + } + + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderFaqTwoColumn(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Title + html.append("

    ").append(getString(section, "title", "FAQs")).append("

    "); + + // Description + html.append("

    ") + .append(getString(section, "description", "")).append("

    "); + + // FAQ Grid + List> questions = (List>) section.get("questions"); + html.append( + "
    "); + + for (Map qa : questions) { + html.append("
    ") + .append("

    ").append(qa.get("question")).append("

    ") + .append("

    ").append(qa.get("answer")).append("

    ").append("
    "); + } + + html.append("
    "); + + // CTA + if (section.containsKey("cta")) { + Map cta = (Map) section.get("cta"); + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderFaqIllustrated(Map section) { + StringBuilder html = new StringBuilder(); + html.append( + "
    "); + + // Title + html.append("

    ") + .append(getString(section, "title", "FAQs")).append("

    "); + + // Search + if (section.containsKey("searchPlaceholder")) { + html.append("
    ") + .append("") + .append("
    "); + } + + // Illustration + if (section.containsKey("illustration")) { + html.append("
    ").append("\"FAQ").append("
    "); + } + + // Questions + List> questions = (List>) section.get("questions"); + html.append("
    "); + + for (Map qa : questions) { + html.append("
    ") + .append("

    ").append(qa.get("question")).append("

    ") + .append("

    ").append(qa.get("answer")).append("

    ").append("
    "); + } + + html.append("
    "); + html.append("
    "); + return html.toString(); + } + + private static String renderDashboardLayout(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Sidebar + if (section.containsKey("sidebar")) { + Map sidebar = (Map) section.get("sidebar"); + List items = (List) sidebar.get("items"); + int active = (int) sidebar.getOrDefault("activeIndex", 0); + + html.append(""); + } + + // Main content + if (section.containsKey("mainContent")) { + List> main = (List>) section.get("mainContent"); + html.append("
    "); + for (Map item : main) { + html.append("
    ").append("

    ") + .append(item.get("title")).append("

    ").append("
    "); + } + html.append("
    "); + } + + // Right panel + if (section.containsKey("rightPanel")) { + Map right = (Map) section.get("rightPanel"); + List> sections = (List>) right.get("sections"); + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderEcommerceFAQs(Map data) { + StringBuilder html = new StringBuilder(); + + html.append("
    "); + + // Title + html.append("

    ").append(getString(data, "title", "FAQs")) + .append("

    "); + + // Categories + List> categories = (List>) data.get("categories"); + html.append( + "
    "); + + for (Map category : categories) { + html.append("
    "); + html.append("

    ").append(category.get("title")).append("

    "); + + List questions = (List) category.get("questions"); + html.append("
      "); + for (String q : questions) { + html.append("
    • ").append(q).append("
    • "); + } + html.append("
    "); + + html.append("
    "); + } + + html.append("
    "); + html.append("
    "); + return html.toString(); + } + + @SuppressWarnings("unchecked") + private static String renderLogoCloud(Map data) { + StringBuilder html = new StringBuilder(); + + String sectionClass = getString(data, "class", "logo-cloud"); + String theme = getString(data, "theme", ""); + + html.append("
    "); + + List> children = (List>) data.get("children"); + if (children != null) { + for (Map child : children) { + String childClass = getString(child, "class", ""); + String childType = getString(child, "type", ""); + + if ("div".equals(childType)) { + html.append(""); + + List> innerChildren = (List>) child.get("children"); + if (innerChildren != null) { + for (Map inner : innerChildren) { + String innerType = getString(inner, "type", ""); + String innerClass = getString(inner, "class", ""); + String content = getString(inner, "content", ""); + + if ("h2".equals(innerType)) { + html.append("

    ").append(content).append("

    "); + } + + if ("div".equals(innerType)) { + // 🎯 Call reusable method + html.append("
    ") + .append(renderImageDiv(inner)).append("
    "); + } + } + } + + html.append(""); + } + } + } + + html.append("
    "); + return html.toString(); + } + + @SuppressWarnings("unchecked") + private static String renderLogoShowcase(Map data) { + StringBuilder html = new StringBuilder(); + + String sectionClass = getString(data, "class", "logo-showcase"); + String theme = getString(data, "theme", ""); + + html.append("
    "); + + List> children = (List>) data.get("children"); + if (children != null) { + for (Map child : children) { + String childClass = getString(child, "class", ""); + String childType = getString(child, "type", ""); + + if ("div".equals(childType)) { + html.append(""); + + List> innerChildren = (List>) child.get("children"); + if (innerChildren != null) { + for (Map inner : innerChildren) { + String innerType = getString(inner, "type", ""); + String innerClass = getString(inner, "class", ""); + String href = getString(inner, "href", ""); + String content = getString(inner, "content", ""); + + if ("div".equals(innerType)) { + // 🎯 Use reusable image method here + html.append(renderImageDiv(inner)); + } + if ("a".equals(innerType)) { + html.append("").append(content).append(""); + } + } + } + + html.append(""); + } + } + } + + html.append("
    "); + return html.toString(); + } + + private static String renderBrandGuideline(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Project Info + Map project = (Map) data.get("project"); + html.append("
    ") + .append("

    ").append(getString(project, "name", "")).append("

    ") + .append("

    Designer: ").append(getString(project, "designer", "")).append("

    ") + .append("

    Client: ").append(getString(project, "client", "")).append("

    ") + .append("

    Website: ").append(getString(project, "website", "")).append("

    ") + .append("

    Logo Date: ").append(getString(project, "logoDate", "")).append("

    ") + .append("
    "); + + // Logos + Map logo = (Map) data.get("logo"); + html.append("
    ").append("

    Logo Variants

    "); + + html.append("

    Primary Logo:

    \"Primary

    "); + + html.append("

    Icon Logo:

    \"Icon

    "); + + List mono = (List) logo.get("monochrome"); + if (mono != null && mono.size() == 2) { + html.append("

    Monochrome Logos:

    ").append("\"Black").append("\"White

    "); + } + + Map social = (Map) logo.get("social"); + html.append("

    Social Logos:

    ").append("\"Social").append("\"Social") + .append("
    "); + + // Colors + List> colors = (List>) data.get("colors"); + html.append("
    ").append("

    Brand Colors

    ") + .append("
    "); + + for (Map color : colors) { + String hex = getString(color, "hex", "#000"); + html.append("
    ").append("
    ") + .append("

    ").append(getString(color, "name", "")) + .append("

    ").append("

    ") + .append(getString(color, "usage", "")).append("

    ").append("
    "); + } + html.append("
    "); + + // Typography + Map typography = (Map) data.get("typography"); + html.append("
    ").append("

    Typography

    "); + + Map headline = (Map) typography.get("headline"); + html.append("

    Headline: ").append(getString(headline, "fontFamily", "")).append(" - ") + .append(getString(headline, "weight", "")).append("

    "); + + Map body = (Map) typography.get("body"); + html.append("

    Body: ").append(getString(body, "fontFamily", "")).append(" - ") + .append(getString(body, "weight", "")).append("

    "); + + html.append("
    "); + return html.toString(); + } + + private static String renderLogoGrid(List> data) { + StringBuilder html = new StringBuilder(); + html.append("
    ") + .append("

    Logo Grid

    ") + .append("
    "); + + for (Map logo : data) { + html.append( + "
    ") + .append("

    ").append(getString(logo, "title", "")) + .append("

    ").append("

    Category: ") + .append(getString(logo, "category", "")).append("

    ") + .append("

    Style: ") + .append(getString(logo, "style", "")).append("

    ").append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderLogoGuidelines(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Header info + html.append("

    ").append(getString(data, "templateName", "Logo Guidelines")) + .append("

    ").append("

    Created in ") + .append(getString(data, "createdIn", "")).append(" • ").append(getString(data, "date", "")) + .append("

    "); + + // Sections + List> sections = (List>) data.get("sections"); + if (sections != null) { + for (Map section : sections) { + html.append("
    ").append("

    ") + .append(getString(section, "title", "")).append("

    ").append("

    ") + .append(getString(section, "description", "")).append("

    "); + + // If Cover section + if ("Cover".equalsIgnoreCase(getString(section, "title", "")) && section.containsKey("content")) { + Map content = (Map) section.get("content"); + html.append( + "
    ") + .append("

    Version: ").append(getString(content, "version", "")) + .append("

    ").append("

    ").append(getString(content, "title", "")).append("

    ") + .append("

    ").append(getString(content, "subtitle", "")).append("

    ").append("
    "); + } + + // If Typography section + if ("Typography".equalsIgnoreCase(getString(section, "title", "")) && section.containsKey("font")) { + Map font = (Map) section.get("font"); + html.append("
    Aa
    ") + .append("

    ") + .append(getString(font, "name", "")).append(" - ") + .append(getString(font, "usage", "")).append("

    "); + } + + html.append("
    "); + } + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTeamSection(Map data) { + StringBuilder html = new StringBuilder(); + html.append( + "
    "); + + // Title & Description + html.append("

    ").append(getString(data, "title", "Our Team")).append("

    "); + html.append("

    ") + .append(getString(data, "description", "")).append("

    "); + + // Team Members + List> members = (List>) data.get("members"); + if (members != null && !members.isEmpty()) { + html.append( + "
    "); + for (Map member : members) { + html.append("
    ") + .append("\"")") + .append("

    ").append(getString(member, "name", "")) + .append("

    ").append("

    ") + .append(getString(member, "role", "")).append("

    "); + + // Socials + List socials = (List) member.get("socials"); + if (socials != null && !socials.isEmpty()) { + html.append( + "
    "); + for (String social : socials) { + html.append("") + .append(""); + } + html.append("
    "); + } + + html.append("
    "); + } + html.append("
    "); + } + + // CTA Button + if (data.containsKey("button")) { + Map button = (Map) data.get("button"); + html.append(""); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTeamSectionTemplate(Map data) { + StringBuilder html = new StringBuilder(); + String title = getString(data, "title", "Team"); + html.append("
    ") + .append("

    ").append(title).append("

    "); + + List> variations = (List>) data.get("variations"); + if (variations != null) { + for (Map variation : variations) { + String layout = getString(variation, "layout", "grid"); + String sectionTitle = getString(variation, "sectionTitle", ""); + + html.append("
    "); + html.append("

    ").append(sectionTitle).append("

    "); + + if ("highlighted-center".equals(layout)) { + // Highlighted member at top + Map highlighted = (Map) variation.get("highlightedMember"); + if (highlighted != null) { + html.append( + "
    ") + .append("\"")").append("

    ") + .append(highlighted.get("name")).append("

    ").append("

    ") + .append(highlighted.get("role")).append("

    ") + .append("

    ") + .append(highlighted.get("bio")).append("

    "); + + List socials = (List) highlighted.get("socials"); + if (socials != null) { + html.append("
    "); + for (String soc : socials) { + html.append(""); + } + html.append("
    "); + } + + html.append("
    "); + } + } + + // Team grid + List> members = (List>) variation.get("members"); + if (members != null && !members.isEmpty()) { + html.append( + "
    "); + for (Map member : members) { + html.append("
    ") + .append("\"")") + .append("

    ").append(member.get("name")).append("

    ") + .append("

    ").append(member.get("role")) + .append("

    ").append("
    "); + } + html.append("
    "); + } + + html.append("
    "); + } + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTeamSlider(Map data) { + StringBuilder html = new StringBuilder(); + String title = getString(data, "title", "Our Team"); + String subtitle = getString(data, "subtitle", ""); + + html.append("
    ").append("

    ").append(title).append("

    ") + .append("

    ").append(subtitle).append("

    ").append("
    "); + + List> members = (List>) data.get("members"); + if (members != null) { + for (Map member : members) { + html.append("
    ").append("\"").append(member.get("name")).append("\"").append("

    ") + .append(member.get("name")).append("

    ").append("

    ").append(member.get("role")) + .append("

    ").append("

    ").append(member.get("bio")).append("

    "); + + List> socials = (List>) member.get("socials"); + if (socials != null) { + html.append("
    "); + for (Map soc : socials) { + String platform = getString(soc, "platform", ""); + String link = getString(soc, "link", "#"); + html.append("") + .append(""); + } + html.append("
    "); + } + + String profileLink = getString(member, "profileLink", ""); + if (!profileLink.isEmpty()) { + html.append(""); + } + + html.append("
    "); + } + } + + html.append("
    "); + return html.toString(); + } + + private static String renderSmartHeader(Map node) { + if (node.containsKey("buttons")) { + return renderHeaderWithButtons(node); // Case: logo + nav + buttons + } else if (node.containsKey("navMenu") || node.containsKey("icons")) { + return renderCustomHeader(node); // Case: navMenu with dropdowns/icons + } else { + return wrapTag("header", "navbar-1", node); // Fallback to generic header wrapper + } + } + + private static String renderSmartHeroSection(Map node) { + String layout = getString(node, "layout", "").toLowerCase(); + + if ((layout.contains("centered") || layout.equals("")) && node.containsKey("heading")) { + return renderHeroCenteredSection(node); // hero-centered + } + + if (layout.contains("left-text-right-cards")) { + return renderHeroLeftCards(node); + } + + if (layout.contains("two-column") || node.containsKey("rightImage") || node.containsKey("leftColumn")) { + return renderHeroTwoColumn(node); // 🔁 Standardized to use this one + } + + return wrapTag("section", "hero-section", node); // fallback + } + + private static String renderHeroTwoColumn(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Left Content + html.append("
    "); + + Map heading = (Map) data.get("heading"); + html.append("

    ").append(heading.get("text")) + .append("

    "); + + Map subheading = (Map) data.get("subheading"); + html.append("

    ").append(subheading.get("text")) + .append("

    "); + + List> ctaButtons = (List>) data.get("ctaButtons"); + html.append("
    "); + for (Map btn : ctaButtons) { + html.append(""); + } + html.append("
    "); + + // Right Image + Map image = (Map) data.get("rightImage"); + html.append("
    ").append("\"").append(image.get("alt")).append("\"").append("
    "); + + html.append("
    "); + return html.toString(); + } + + private static String renderCenteredSectionWithImage(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    \n"); + + // Tagline + Map tagline = (Map) data.get("tagline"); + if (tagline != null) { + html.append("

    " + tagline.get("text") + "

    \n"); + } + + // Heading + Map heading = (Map) data.get("heading"); + if (heading != null) { + html.append("

    " + heading.get("text") + "

    \n"); + } + + // Description + Map desc = (Map) data.get("description"); + if (desc != null) { + html.append("

    " + desc.get("text") + "

    \n"); + } + + // Buttons + List> buttons = (List>) data.get("buttons"); + if (buttons != null && !buttons.isEmpty()) { + html.append("
    \n"); + for (Map btn : buttons) { + String label = (String) btn.get("label"); + String style = (String) btn.get("style"); + String cssClass = "filled".equalsIgnoreCase(style) ? "btn-filled" : "btn-outlined"; + html.append("" + label + "\n"); + } + html.append("
    \n"); + } + + // Image + Map image = (Map) data.get("image"); + if (image != null) { + html.append("\""\n"); + } + + html.append("
    \n"); + return html.toString(); + } + + @SuppressWarnings("unchecked") + private static List> getChildren(Map node) { + Object children = node.get("children"); + if (children instanceof List) { + return (List>) children; + } + return Collections.emptyList(); + } + + private static String renderFeatureSection(Map node) { + StringBuilder sb = new StringBuilder(); + sb.append("
    "); + + List> children = getChildren(node); + + for (Map child : children) { + String type = getString(child, "type", ""); + String className = get(child, "class"); + + if ("img".equalsIgnoreCase(type)) { + sb.append("\"")"); + } + if ("img".equals(type)) { + sb.append(renderImageDiv(child)); + } else if ("div".equals(type) && "placeholder-img".equals(className)) { + sb.append(renderImageDiv(child)); + } else if ("div".equalsIgnoreCase(type)) { + sb.append("
    "); + + List> divChildren = getChildren(child); + for (Map inner : divChildren) { + String innerType = getString(inner, "type", ""); + + if ("h2".equalsIgnoreCase(innerType)) { + sb.append("

    ").append(getString(inner, "content", "")) + .append("

    "); + } else if ("p".equalsIgnoreCase(innerType)) { + sb.append("

    ").append(getString(inner, "content", "")) + .append("

    "); + } else if ("ul".equalsIgnoreCase(innerType)) { + sb.append("
      "); + List> items = getChildren(inner); + for (Map li : items) { + sb.append("
    • ").append(getString(li, "content", "")).append("
    • "); + } + sb.append("
    "); + } + } + + sb.append("
    "); + } + } + + sb.append("
    "); + return sb.toString(); + } + + private static String renderHeroCenteredHeadingSplit(Map section) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Heading with split text + Map heading = (Map) section.get("heading"); + if (heading != null && heading.containsKey("textParts")) { + html.append("

    "); + List> parts = (List>) heading.get("textParts"); + for (Map part : parts) { + String text = (String) part.getOrDefault("text", ""); + String spanClass = (String) part.getOrDefault("class", ""); + html.append("").append(text).append(" "); + } + html.append("

    "); + } + + // Description + Map description = (Map) section.get("description"); + if (description != null) { + html.append("

    ").append(description.get("text")).append("

    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderHeaderWithButtons(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Logo + Map logo = (Map) data.get("logo"); + html.append("
    \"")
    "); + + // Nav Links + Map navLinks = (Map) data.get("navLinks"); + List> items = (List>) navLinks.get("items"); + html.append(""); + + // Buttons + html.append("
    "); + List> buttons = (List>) data.get("buttons"); + for (Map btn : buttons) { + html.append(""); + } + html.append("
    "); + + html.append("
    "); + return html.toString(); + } + + private static String renderCustomHeader(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + // Logo + if (data.containsKey("logo")) { + Map logo = (Map) data.get("logo"); + html.append("
    ").append(logo.get("text")).append("
    "); + } + + // Site Info + if (data.containsKey("siteInfo")) { + Map site = (Map) data.get("siteInfo"); + html.append("
    "); + html.append("

    ").append(site.get("title")).append("

    "); + html.append("

    ").append(site.get("description")).append("

    "); + html.append("
    "); + } + + // Navigation + if (data.containsKey("navMenu")) { + Map nav = (Map) data.get("navMenu"); + List> links = (List>) nav.get("links"); + + html.append("
      "); + for (Map link : links) { + boolean isActive = Boolean.TRUE.equals(link.get("active")); + boolean isDropdown = Boolean.TRUE.equals(link.get("dropdown")); + String label = (String) link.get("label"); + String href = (String) link.getOrDefault("href", "#"); + + if (isDropdown) { + html.append("
    • ").append(label) + .append("
      ") + .append("

      Menu

      • 📦Dropdown

        Sample

      ") + .append("
    • "); + } else { + html.append("
    • ") + .append(label).append("
    • "); + } + } + html.append("
    "); + } + + // Icons + if (data.containsKey("icons")) { + html.append("
    "); + List> icons = (List>) data.get("icons"); + for (Map icon : icons) { + html.append("").append(icon.get("symbol")).append(" "); + } + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String renderTeamShowcase(Map data) { + StringBuilder html = new StringBuilder(); + html.append("
    "); + + html.append("

    ").append(data.get("title")).append("

    "); + html.append("

    ").append(data.get("subtitle")).append("

    "); + + List> groups = (List>) data.get("groups"); + for (Map group : groups) { + html.append("
    "); + html.append("

    ").append(group.get("groupName")).append("

    "); + html.append("
    "); + + List> members = (List>) group.get("members"); + for (Map member : members) { + html.append("
    "); + html.append("\"").append(member.get("name"))"); + html.append("
    ").append(member.get("name")).append("
    "); + html.append("
    ").append(member.get("role")).append("
    "); + html.append("
    "); + } + + html.append("
    "); + } + + html.append("
    "); + return html.toString(); + } + + private static String formatKey(String key) { + key = key.replaceAll("([a-z])([A-Z])", "$1 $2"); // camelCase to space + key = key.substring(0, 1).toUpperCase() + key.substring(1); // capitalize first + return key.replace("-", " "); + } + + private static String getIconEmoji(String label) { + label = label.toLowerCase(); + if (label.contains("facebook")) + return "📘"; + if (label.contains("instagram")) + return "📷"; + if (label.equals("x")) + return "𝕏"; + if (label.contains("search")) + return "🔍"; + if (label.contains("profile")) + return "👤"; + if (label.contains("twitter")) + return "🐦"; + + if (label.contains("linkedin")) + return "🔗"; + if (label.contains("youtube")) + return "▶️"; + return "📦"; + } + + private static void appendStyle(StringBuilder style, String key, Object value) { + if (value != null) { + style.append(key).append(":").append(value).append("; "); + } + } + + private static String getWidgetIcon(String widget) { + widget = widget.toLowerCase(); + if (widget.contains("search")) + return "🔍"; + if (widget.contains("recent")) + return "📝"; + if (widget.contains("newsletter")) + return "📬"; + return "📦"; + } + + private static String getString(Map map, String key, String defaultValue) { + Object val = map.get(key); + return val instanceof String ? (String) val : defaultValue; + } + + private static String renderImageDiv(Map data) { + StringBuilder html = new StringBuilder(); + + // Get attributes from JSON +// String className = getString(data, "class", "placeholder-img"); + String className = "placeholder-img"; + String src = getString(data, "src", "/src/assets/images/placeholder.png"); + String width = getString(data, "width", ""); // optional + String height = getString(data, "height", ""); // optional + + // Fallback to default image if src is missing or blank + if (src.isEmpty()) { + src = "/src/assets/images/placeholder.png"; + } + + // Build style + StringBuilder style = new StringBuilder(); + style.append("background-image: url('").append(src).append("');"); + + // Add inline height/width only if provided, else CSS will handle default + if (!width.isEmpty()) { + style.append(" width: ").append(width).append(";"); + } + if (!height.isEmpty()) { + style.append(" height: ").append(height).append(";"); + } + + // Return final div + html.append("
    "); + + return html.toString(); + } + +} diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java new file mode 100644 index 0000000..9be71dc --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java @@ -0,0 +1,100 @@ +package com.realnet.dlf.Controllers; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.realnet.dlf.Entity.Design_lbrary; +import com.realnet.dlf.Services.Design_lbraryService; +import com.realnet.dlf.Services.DlfService; +import com.realnet.fnd.response.EntityResponse; + +@RequestMapping(value = "/Design_lbrary") +@CrossOrigin("*") +@RestController +public class Design_lbraryController { + @Autowired + private Design_lbraryService designLibraryService; + + @Autowired + private DlfService dlfService; + + @Value("${projectPath}") + private String projectPath; + + @PostMapping("/Design_lbrary") + public Design_lbrary Savedata(@RequestBody Design_lbrary data) { + Design_lbrary save = designLibraryService.Savedata(data); + + System.out.println("data saved..." + save); + + return save; + } + + @PutMapping("/Design_lbrary/{id}") + public Design_lbrary update(@RequestBody Design_lbrary data, @PathVariable Integer id) { + Design_lbrary update = designLibraryService.update(data, id); + System.out.println("data update..." + update); + return update; + } + +// get all with pagination + @GetMapping("/Design_lbrary/getall/page") + public Page getall(@RequestParam(value = "page", required = false) Integer page, + @RequestParam(value = "size", required = false) Integer size) { + Pageable paging = PageRequest.of(page, size); + Page get = designLibraryService.getAllWithPagination(paging); + + return get; + + } + + @GetMapping("/Design_lbrary") + public List getdetails() { + List get = designLibraryService.getdetails(); + return get; + } +// get all without authentication + + @GetMapping("/token/Design_lbrary") + public List getallwioutsec() { + List get = designLibraryService.getdetails(); + return get; + } + + @GetMapping("/Design_lbrary/{id}") + public Design_lbrary getdetailsbyId(@PathVariable Integer id) { + Design_lbrary get = designLibraryService.getdetailsbyId(id); + return get; + } + + @DeleteMapping("/Design_lbrary/{id}") + public ResponseEntity delete_by_id(@PathVariable Integer id) { + designLibraryService.delete_by_id(id); + return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); + + } + + @GetMapping("/preview/{id}") + public ResponseEntity getDesignPreview(@PathVariable Integer id) { + String htmlWithCss = dlfService.generateHtmlWithCss(id); + return ResponseEntity.ok(htmlWithCss); + } + +} \ No newline at end of file diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java new file mode 100644 index 0000000..c15bd23 --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java @@ -0,0 +1,46 @@ +package com.realnet.dlf.Entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Lob; + +import com.realnet.WhoColumn.Entity.Extension; + +import lombok.Data; + +@Entity +@Data +public class Design_lbrary extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + private String name; + + @Column(length = 2000) + private String description; + + private boolean active; + + @Lob + private String htmljson; + + @Column(length = 2000) + private String css; + + @Column(columnDefinition = "TEXT") + private String javacode; + + private String templatetype; + + private String uitype; + +} diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java new file mode 100644 index 0000000..2d9cd06 --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java @@ -0,0 +1,36 @@ +package com.realnet.dlf.Repository; + + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import org.springframework.stereotype.Repository; +import java.util.*; + + + + + + + + + + + + + + + +import com.realnet.dlf.Entity.Design_lbrary; + +@Repository +public interface Design_lbraryRepository extends JpaRepository { + +@Query(value = "select * from design_lbrary where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + +@Query(value = "select * from design_lbrary where created_by=?1", nativeQuery = true) + Page findAll(Pageable page, Long creayedBy); +} \ No newline at end of file diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java new file mode 100644 index 0000000..af889ba --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java @@ -0,0 +1,100 @@ +package com.realnet.dlf.Services; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import com.realnet.OpenAi.Services.HtmlBuilder3; +import com.realnet.dlf.Entity.Design_lbrary; +import com.realnet.dlf.Repository.Design_lbraryRepository; +import com.realnet.realm.Entity.Realm; +import com.realnet.realm.Services.RealmService; +import com.realnet.users.entity1.AppUser; +import com.realnet.users.service1.AppUserServiceImpl; + +@Service +public class Design_lbraryService { + @Autowired + private Design_lbraryRepository designLibraryRepository; + @Autowired + private AppUserServiceImpl userService; + @Autowired + private RealmService realmService; + + public Design_lbrary Savedata(Design_lbrary data) { + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); + Design_lbrary save = designLibraryRepository.save(data); + return save; + } + +// get all with pagination + public Page getAllWithPagination(Pageable page) { + return designLibraryRepository.findAll(page, getUser().getUserId()); + } + + public List getdetails() { + List realm = realmService.findByUserId(getUser().getUserId()); + List all = designLibraryRepository.findAll(getUser().getUserId()); + + return all; + } + + public Design_lbrary getdetailsbyId(Integer id) { + return designLibraryRepository.findById(id).get(); + } + + public void delete_by_id(Integer id) { + designLibraryRepository.deleteById(id); + } + + public Design_lbrary update(Design_lbrary data, Integer id) { + Design_lbrary old = designLibraryRepository.findById(id).get(); + old.setName(data.getName()); + + old.setDescription(data.getDescription()); + + old.setActive(data.isActive()); + + old.setHtmljson(data.getHtmljson()); + + old.setCss(data.getCss()); + + old.setJavacode(data.getJavacode()); + + old.setTemplatetype(data.getTemplatetype()); + + old.setUitype(data.getUitype()); + + final Design_lbrary test = designLibraryRepository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test; + } + + public String generatePreviewHtml(Integer id) { + // 1. Record uthao + Design_lbrary design = designLibraryRepository.findById(id) + .orElseThrow(() -> new RuntimeException("Design not found with ID: " + id)); + + // 2. JSON se HTML banao + String htmljson = design.getHtmljson(); + String generatedHtml = HtmlBuilder3.buildHtml(htmljson); // Tumhara existing method ka call + + // 3. CSS inject karo + String css = design.getCss(); + String finalHtml = "" + generatedHtml + ""; + + return finalHtml; + } + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + } +} diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/DlfService.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/DlfService.java new file mode 100644 index 0000000..7454741 --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/DlfService.java @@ -0,0 +1,281 @@ +package com.realnet.dlf.Services; + +import java.util.Collections; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.realnet.dlf.Entity.Design_lbrary; +import com.realnet.dlf.Repository.Design_lbraryRepository; + +@Service +public class DlfService { + + @Autowired + private Design_lbraryRepository designLibraryRepository; + + public String generateHtmlWithCss(Integer id) { + Design_lbrary design = designLibraryRepository.findById(id) + .orElseThrow(() -> new RuntimeException("Design not found with id: " + id)); + + String htmlJson = design.getHtmljson(); + String javacode = design.getJavacode(); + String css = design.getCss(); + + Map dataMap = parseJsonToMap(htmlJson); + + String generatedHtml = replacePlaceholders(javacode, dataMap); + + String finalHtml = "" + generatedHtml + ""; + + return finalHtml; + } + + private Map parseJsonToMap(String json) { + try { + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(json, new TypeReference>() { + }); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyMap(); + } + } + + private String replacePlaceholders(String template, Map dataMap) { + if (template == null || dataMap == null) { + return template; + } + + String result = template; + + for (Map.Entry entry : dataMap.entrySet()) { + String placeholder = "{{" + entry.getKey() + "}}"; + String value = entry.getValue() != null ? entry.getValue().toString() : ""; + result = result.replace(placeholder, value); + } + + return result; + } + +// public static String buildHtml(Object node) { +// if (node instanceof Map) { +// Map map = (Map) node; +// +// // Handle raw section container +// if (!map.containsKey("type") && !map.containsKey("tag")) { +// StringBuilder html = new StringBuilder(); +// for (Map.Entry entry : map.entrySet()) { +// String sectionName = entry.getKey(); +// Object sectionContent = entry.getValue(); +// +// if ("teamSlider".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderTeamSlider((Map) sectionContent)); +// continue; +// } +// +// if ("teamSectionTemplate".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderTeamSectionTemplate((Map) sectionContent)); +// continue; +// } +// +// if ("teamSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderTeamSection((Map) sectionContent)); +// continue; +// } +// +// if ("logoGuidelines".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderLogoGuidelines((Map) sectionContent)); +// continue; +// } +// +// if ("logoGrid".equalsIgnoreCase(sectionName) && sectionContent instanceof List) { +// html.append(renderLogoGrid((List>) sectionContent)); +// continue; +// } +// +// if ("brandGuideline".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBrandGuideline((Map) sectionContent)); +// continue; +// } +// +// if ("logoShowcase".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderLogoShowcase((Map) sectionContent)); +// continue; +// } +// +// if ("logoCloud".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderLogoCloud((Map) sectionContent)); +// continue; +// } +// +// if ("ecommerceFAQs".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderEcommerceFAQs((Map) sectionContent)); +// continue; +// } +// +// if ("dashboardLayout".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderDashboardLayout((Map) sectionContent)); +// continue; +// } +// +// if ("FAQIllustratedSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderFaqIllustrated((Map) sectionContent)); +// continue; +// } +// +// if ("FAQSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderFaqSection((Map) sectionContent)); +// continue; +// } +// if ("FAQTwoColumn".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderFaqTwoColumn((Map) sectionContent)); +// continue; +// } +// +// if ("TestimonialLanding".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderTestimonialLanding((Map) sectionContent)); +// continue; +// } +// +// if ("ClientTestimonialSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderClientTestimonial((Map) sectionContent)); +// continue; +// } +// if ("TestimonialSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderSimpleTestimonial((Map) sectionContent)); +// continue; +// } +// +// if ("SubSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderSubSectionCentered((Map) sectionContent)); +// continue; +// } +// if ("HeroSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// Map heroMap = (Map) sectionContent; +// +// if ("centered".equalsIgnoreCase(getString(heroMap, "layout", "")) +// && heroMap.containsKey("artwork")) { +// html.append(renderHeroCenteredWithArt(heroMap)); +// continue; +// } +// if ("left-text-right-cards".equalsIgnoreCase(getString(heroMap, "layout", ""))) { +// html.append(renderHeroLeftCards(heroMap)); +// continue; +// } +// // Smart internal layout-based routing to correct renderer +// String layout = getString(heroMap, "layout", "").toLowerCase(); +// +// if (layout.equals("two-column") || heroMap.containsKey("leftColumn")) { +// html.append(renderTwoColumnHeroSection(heroMap)); +// } else if (layout.equals("centered") || heroMap.containsKey("heading")) { +// html.append(renderCenteredHeroSection(heroMap)); +// } else { +// // fallback to older generic renderHeroSection +// html.append(renderHeroSection(heroMap)); +// } +// continue; +// } +// +// if ("Blog".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogCardSection((Map) sectionContent)); +// continue; +// } +// +// if ("blogPage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogPage((Map) sectionContent)); +// continue; +// } +// +// if ("blogPreviewSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogPreviewSection((Map) sectionContent)); +// continue; +// } +// if ("blogHomePage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogHomePage((Map) sectionContent)); +// continue; +// } +// +// if ("blogListSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogListSection((Map) sectionContent)); +// continue; +// } +// +// if ("ContactSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderContactSection((Map) sectionContent)); +// continue; +// } +// +// if ("Navbar".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderNavbarBlock((Map) sectionContent)); +// continue; +// } +// if ("Footer".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// Map footerMap = (Map) sectionContent; +// +// // Smart switch based on keys like 'columns', 'topBar', 'bottom' +// if (footerMap.containsKey("columns") || footerMap.containsKey("topBar") +// || footerMap.containsKey("bottom")) { +// html.append(renderMdBootstrapFooter(footerMap)); +// } else if (footerMap.containsKey("linkColumns") || footerMap.containsKey("socialIcons")) { +// html.append(renderCompactFooter(footerMap)); +// } else { +// html.append(renderFooterBlock(footerMap)); +// } +// continue; +// } +// if ("how-to-blog-post".equalsIgnoreCase(getString(map, "type", ""))) { +// html.append(renderHowToBlogPost(map)); +// return html.toString(); +// } +// +// if ("blogThumbnailGrid".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogThumbnailGrid((Map) sectionContent)); +// continue; +// } +// if ("blogSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogSection((Map) sectionContent)); +// continue; +// } +// if ("articlePage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderArticlePage((Map) sectionContent)); +// continue; +// } +// if ("templateLibrary".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderTemplateLibrary((Map) sectionContent)); +// continue; +// } +// if ("blogHeader".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) { +// html.append(renderBlogHeader((Map) sectionContent)); +// continue; +// } +// +// // Wrap each section in a
    tag with class derived from key +// html.append("
    "); +// +// html.append(buildHtml(sectionContent)); +// +// html.append("
    "); +// } +// return html.toString(); +// } +// // Check if a universal TYPE_RENDERER exists for this block +// String type = getString(map, "type", ""); +// if (TYPE_RENDERERS.containsKey(type.toLowerCase())) { +// return TYPE_RENDERERS.get(type.toLowerCase()).apply(map); +// } +// // Normal map block +// return renderFromMap(map); +// } else if (node instanceof List) { +// return renderFromList((List) node); +// } else if (node != null) { +// return node.toString(); +// } else { +// return ""; +// } +// } + +} diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/utils/PortConstant.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/utils/PortConstant.java index cb779ee..a77e9be 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/utils/PortConstant.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/utils/PortConstant.java @@ -9,7 +9,6 @@ import org.springframework.web.client.RestTemplate; @Component public class PortConstant { - public static String LOCAL_HOST; public final static String FRONTEND_PORT_9191 = "30165"; public final static String GITEA_IP_ADDRESS = "try.gitea"; @@ -36,6 +35,8 @@ public class PortConstant { public static String GITEA_DOMAIN; public static String GITEA_USERNAME; public static String SITE_BUILDER; + public static String LOCAL_HOST; + public static String PROTOCOL;