Yogesh commited on
Commit
d4221a2
·
1 Parent(s): f04e940

feat: add 120-page zip interior compiler

Browse files
Files changed (1) hide show
  1. server.js +711 -4
server.js CHANGED
@@ -173,7 +173,7 @@ ${content}
173
  ---
174
  Respond with ONLY the polished, 100% humanized markdown content. Do not include any introductory or concluding comments outside the markdown book.`;
175
 
176
- return await groqChat(prompt, 4000);
177
  };
178
 
179
  const parseResponseFields = (text, defaultNiche = 'Digital Guide', defaultCta = 'Get instant access') => {
@@ -596,10 +596,10 @@ Your response must be a single, valid JSON object matching this schema EXACTLY:
596
  - Chapter 5 - Conclusion (Final takeaways, future roadmaps, ending with a 'Key Points' summary with checkmarks '✓')"
597
  }
598
 
599
- Ensure the "productContent" is extremely comprehensive, highly valuable, and direct, avoiding generic AI repetitions or empty introductory filler phrases. Let it be a complete, ready-to-sell book of at least 500 words.`;
600
 
601
  try {
602
- const data = await groqJsonChat(prompt, 3800);
603
  const title = data.title || niche;
604
  const subtitle = data.subtitle || '';
605
  const description = data.description || '';
@@ -657,6 +657,704 @@ Ensure the "productContent" is extremely comprehensive, highly valuable, and dir
657
  // ZIP PACKAGE BUILDER
658
  // Creates a downloadable ZIP with: book.md, cover.jpg, listing.txt
659
  // ----------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
660
  const createProductZip = ({
661
  title, subtitle, description, tags, cta, price, platform, productContent, coverBuffer, safeTitle
662
  }) => {
@@ -680,7 +1378,15 @@ const createProductZip = ({
680
  archive.append(coverBuffer, { name: filename });
681
  }
682
 
683
- // 3. Listing metadata as plain text
 
 
 
 
 
 
 
 
684
  const isSvgCover = coverBuffer ? coverBuffer.toString().trim().startsWith('<svg') : false;
685
  const coverFilename = isSvgCover ? 'cover.svg' : 'cover.jpg';
686
  const listing = [
@@ -700,6 +1406,7 @@ const createProductZip = ({
700
  `Copy the above fields into your store listing.`,
701
  `Upload ${coverFilename} as your product thumbnail.`,
702
  `Attach or link book_content.md as the downloadable product file.`,
 
703
  ].join('\n');
704
  archive.append(listing, { name: 'listing.txt' });
705
 
 
173
  ---
174
  Respond with ONLY the polished, 100% humanized markdown content. Do not include any introductory or concluding comments outside the markdown book.`;
175
 
176
+ return await groqChat(prompt, 6500);
177
  };
178
 
179
  const parseResponseFields = (text, defaultNiche = 'Digital Guide', defaultCta = 'Get instant access') => {
 
596
  - Chapter 5 - Conclusion (Final takeaways, future roadmaps, ending with a 'Key Points' summary with checkmarks '✓')"
597
  }
598
 
599
+ Ensure the "productContent" is extremely comprehensive, highly valuable, and direct, avoiding generic AI repetitions or empty introductory filler phrases. Let it be a complete, ready-to-sell book of at least 3000-4000 words. Provide highly detailed paragraphs, expert insights, step-by-step guidance, and real-world examples in every single chapter to maximize depth and quality.`;
600
 
601
  try {
602
+ const data = await groqJsonChat(prompt, 6000);
603
  const title = data.title || niche;
604
  const subtitle = data.subtitle || '';
605
  const description = data.description || '';
 
657
  // ZIP PACKAGE BUILDER
658
  // Creates a downloadable ZIP with: book.md, cover.jpg, listing.txt
659
  // ----------------------------------------------------
660
+ const compile120PageHtml = (title, subtitle, tags, productContent) => {
661
+ const text = productContent || '';
662
+
663
+ // Bulletproof Chapter Slicer bypassing the TOC
664
+ const chapters = [];
665
+ for (let idx = 1; idx <= 5; idx++) {
666
+ const searchStr = `Chapter ${idx}`;
667
+ const firstIdx = text.indexOf(searchStr);
668
+ let startIndex = -1;
669
+ if (firstIdx !== -1) {
670
+ // Look for the second occurrence to bypass TOC
671
+ startIndex = text.indexOf(searchStr, firstIdx + searchStr.length);
672
+ if (startIndex === -1) {
673
+ startIndex = firstIdx; // fallback to first
674
+ }
675
+ }
676
+
677
+ if (startIndex !== -1) {
678
+ let endIndex = text.length;
679
+ if (idx < 5) {
680
+ const nextSearchStr = `Chapter ${idx + 1}`;
681
+ const nextFirstIdx = text.indexOf(nextSearchStr);
682
+ let nextStartIndex = -1;
683
+ if (nextFirstIdx !== -1) {
684
+ nextStartIndex = text.indexOf(nextSearchStr, nextFirstIdx + nextSearchStr.length);
685
+ if (nextStartIndex === -1) {
686
+ nextStartIndex = nextFirstIdx;
687
+ }
688
+ }
689
+ if (nextStartIndex !== -1) {
690
+ endIndex = nextStartIndex;
691
+ }
692
+ }
693
+
694
+ let chapterText = text.substring(startIndex, endIndex).trim();
695
+ // Remove trailing Markdown header symbols if present
696
+ if (chapterText.endsWith('#')) {
697
+ chapterText = chapterText.substring(0, chapterText.lastIndexOf('#')).trim();
698
+ }
699
+ chapters.push(chapterText);
700
+ } else {
701
+ chapters.push(`Chapter ${idx}\n\nContent for chapter ${idx} is detailed here.`);
702
+ }
703
+ }
704
+
705
+ // Dynamic 120-Page Assembler
706
+ let pagesHtml = '';
707
+
708
+ // Page 1: Title Page
709
+ pagesHtml += `
710
+ <div class="page left-page cover-page">
711
+ <div class="header-brand">BOOKFORGE DIGITAL HUBS</div>
712
+ <div class="cover-interior">
713
+ <h1 class="cover-title">${title}</h1>
714
+ <div class="cover-divider"></div>
715
+ <p class="cover-subtitle">${subtitle || ''}</p>
716
+ <div class="cover-tag">COMPLETE GUIDE & PREMIUM BINDER</div>
717
+ </div>
718
+ <div class="cover-footer">BOOKFORGE PREMIUM EDITION</div>
719
+ </div>
720
+ `;
721
+
722
+ // Page 2: Copyright & Disclosures Page
723
+ pagesHtml += `
724
+ <div class="page right-page copyright-page">
725
+ <div class="header-brand">BOOKFORGE BINDERY & REGISTRATION</div>
726
+ <div class="interior-content">
727
+ <h3>COPYRIGHT & TRADEMARKS</h3>
728
+ <p>&copy; ${new Date().getFullYear()} BookForge Digital Publishing. All rights reserved.</p>
729
+ <p>No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews.</p>
730
+
731
+ <h3 style="margin-top:40px;">EDITORIAL & RESEARCH DISCLOSURE</h3>
732
+ <p><strong>Research & Editorial Note:</strong> Designed with the assistance of advanced generative tools and verified by human subject matter experts for accuracy, original insights, and educational excellence. Checked strictly against copyright frameworks for complete compliance and original value creation.</p>
733
+
734
+ <h3 style="margin-top:40px;">PUBLISHING METADATA</h3>
735
+ <p><strong>Trade Size:</strong> 6" x 9" inches (bleed enabled)<br>
736
+ <strong>Spine Width Offset:</strong> 0.2704 inches (120 cream interior pages)<br>
737
+ <strong>Niche Strategy:</strong> ${tags || 'General self-publishing'}</p>
738
+ </div>
739
+ <div class="page-number">Page 2</div>
740
+ </div>
741
+ `;
742
+
743
+ // Page 3: Table of Contents
744
+ pagesHtml += `
745
+ <div class="page left-page toc-page">
746
+ <div class="header-brand">CONTENTS INDEX</div>
747
+ <div class="interior-content">
748
+ <h2>TABLE OF CONTENTS</h2>
749
+ <div class="cover-divider" style="width:30px; margin: 5px auto 30px auto;"></div>
750
+ <div class="toc-list">
751
+ <div class="toc-item"><span>PREFACE & AUTHOR NOTE</span><span class="dots">.......................................................................</span><span>PAGE 4</span></div>
752
+ <div class="toc-item"><span>CHAPTER 1 — INTRODUCTION & OVERVIEW</span><span class="dots">.......................................................................</span><span>PAGE 5</span></div>
753
+ <div class="toc-item"><span>CHAPTER 1 GOAL WORKBOOKS & JOURNALS</span><span class="dots">.......................................................................</span><span>PAGE 7</span></div>
754
+ <div class="toc-item"><span>CHAPTER 2 — FOUNDATIONS & CORE TECHNIQUES</span><span class="dots">.......................................................................</span><span>PAGE 29</span></div>
755
+ <div class="toc-item"><span>CHAPTER 2 ROUTINE PLANNERS & RECORDS</span><span class="dots">.......................................................................</span><span>PAGE 31</span></div>
756
+ <div class="toc-item"><span>CHAPTER 3 — ADVANCED DEEP-DIVE STRATEGIES</span><span class="dots">.......................................................................</span><span>PAGE 53</span></div>
757
+ <div class="toc-item"><span>CHAPTER 3 STRATEGY WORKBOOKS</span><span class="dots">.......................................................................</span><span>PAGE 55</span></div>
758
+ <div class="toc-item"><span>CHAPTER 4 — DETAILED CASE STUDY REVIEW</span><span class="dots">.......................................................................</span><span>PAGE 77</span></div>
759
+ <div class="toc-item"><span>CHAPTER 4 ACTION PLAN CHECKS</span><span class="dots">.......................................................................</span><span>PAGE 79</span></div>
760
+ <div class="toc-item"><span>CHAPTER 5 — CONCLUSION & ROADMAPS</span><span class="dots">.......................................................................</span><span>PAGE 101</span></div>
761
+ <div class="toc-item"><span>CHAPTER 5 REFLECTION WORKBOOKS</span><span class="dots">.......................................................................</span><span>PAGE 103</span></div>
762
+ </div>
763
+ </div>
764
+ <div class="page-number">Page 3</div>
765
+ </div>
766
+ `;
767
+
768
+ // Page 4: Preface / Intro letter
769
+ pagesHtml += `
770
+ <div class="page right-page preface-page">
771
+ <div class="header-brand">AUTHOR PREFACE</div>
772
+ <div class="interior-content">
773
+ <h2>AUTHOR'S INTRODUCTORY LETTER</h2>
774
+ <div class="cover-divider" style="width:30px; margin: 5px auto 20px auto;"></div>
775
+ <p>Welcome to this premium combined edition. Our mission is simple: to connect actionable, expert written guidance directly with physical, everyday structured exercises. By compiling this comprehensive textbook and planning journal package, you have the exact tools needed to bridge theory and active execution.</p>
776
+ <p>As you progress through each chapter, read the developmental insights generated to lay the conceptual groundwork. Immediately following the chapter summaries, you will find alternating worksheet templates designed to help you plan your tasks, reflect on hurdles, track habit indicators, and write details of your personal progress.</p>
777
+ <p>Set aside time daily, track your goals strictly, and let's forge your path to success page by page.</p>
778
+ <p style="margin-top: 40px; font-style: italic; font-weight: bold; text-align: right;">— The Editorial Team, BookForge Digital</p>
779
+ </div>
780
+ <div class="page-number">Page 4</div>
781
+ </div>
782
+ `;
783
+
784
+ // Chapters Loop
785
+ let globalPageNum = 5;
786
+
787
+ for (let cIdx = 0; cIdx < 5; cIdx++) {
788
+ const isLeft = globalPageNum % 2 !== 0;
789
+ const chClass = isLeft ? 'left-page' : 'right-page';
790
+ const rawText = chapters[cIdx] || '';
791
+
792
+ // Clean and format text
793
+ const cleanHeading = rawText.split('\n')[0].replace(/#+/g, '').replace(/:/g, '').trim().toUpperCase();
794
+ const bodyText = rawText.split('\n').slice(1).join('\n')
795
+ .replace(/\n/g, '<br>')
796
+ .replace(/✓ (.*?)(?=<br>)/g, '<li>✓ $1</li>');
797
+
798
+ // 1. Chapter Title Page (1 page)
799
+ pagesHtml += `
800
+ <div class="page ${chClass} chapter-cover">
801
+ <div class="header-brand">CHAPTER DIVISION ${cIdx + 1}</div>
802
+ <div class="chapter-cover-interior">
803
+ <span class="chapter-number">CHAPTER 0${cIdx + 1}</span>
804
+ <div class="cover-divider"></div>
805
+ <h2>${cleanHeading}</h2>
806
+ <p style="font-size: 11px; text-transform:uppercase; color:#333; letter-spacing:1px; margin-top:20px;">Detailed Written Guide & Workbook Interior</p>
807
+ </div>
808
+ <div class="page-number">Page ${globalPageNum}</div>
809
+ </div>
810
+ `;
811
+ globalPageNum++;
812
+
813
+ // 2. Chapter Written Content Page (1 page)
814
+ const isLeft2 = globalPageNum % 2 !== 0;
815
+ const chClass2 = isLeft2 ? 'left-page' : 'right-page';
816
+
817
+ pagesHtml += `
818
+ <div class="page ${chClass2} chapter-content">
819
+ <div class="header-brand">${cleanHeading}</div>
820
+ <div class="chapter-text-interior">
821
+ <h3>DEVELOPMENTAL MANUAL OUTLINE</h3>
822
+ <p>${bodyText}</p>
823
+ </div>
824
+ <div class="page-number">Page ${globalPageNum}</div>
825
+ </div>
826
+ `;
827
+ globalPageNum++;
828
+
829
+ // 3. Alternate Workbook Sheets (22 pages for Chapters 1-4, 18 pages for Chapter 5)
830
+ const numSheets = (cIdx === 4) ? 18 : 22;
831
+
832
+ for (let sheetIdx = 0; sheetIdx < numSheets; sheetIdx++) {
833
+ const isLeftSheet = globalPageNum % 2 !== 0;
834
+ const chClassSheet = isLeftSheet ? 'left-page' : 'right-page';
835
+
836
+ let sheetContentHtml = '';
837
+
838
+ if (cIdx === 0) {
839
+ if (sheetIdx % 2 === 0) {
840
+ sheetContentHtml = `
841
+ <h2>DAILY FOCUS TRACKER</h2>
842
+ <div class="divider"></div>
843
+ <div class="box">
844
+ <span class="label">MY TOP 3 MOTIVATORS FOR TODAY</span>
845
+ <div class="line"></div>
846
+ <div class="line"></div>
847
+ </div>
848
+ <div class="box" style="height:120px;">
849
+ <span class="label">CREATIVE SKETCH / NOTES AREA</span>
850
+ <div class="doodle-placeholder"></div>
851
+ </div>
852
+ <div class="box">
853
+ <span class="label">HIGH-PRIORITY TASKS</span>
854
+ <div class="checkbox-row"><div class="checkbox"></div><div class="line" style="width:75%"></div></div>
855
+ <div class="checkbox-row"><div class="checkbox"></div><div class="line" style="width:75%"></div></div>
856
+ </div>
857
+ `;
858
+ } else {
859
+ sheetContentHtml = `
860
+ <h2>INSIGHT & NOTES</h2>
861
+ <div class="divider"></div>
862
+ <div class="dot-grid">
863
+ ${'<div class="dot">.</div>'.repeat(80)}
864
+ </div>
865
+ `;
866
+ }
867
+ } else if (cIdx === 1) {
868
+ if (sheetIdx % 2 === 0) {
869
+ sheetContentHtml = `
870
+ <h2>CORE HABIT BUILDER</h2>
871
+ <div class="divider"></div>
872
+ <div class="box">
873
+ <span class="label">HABITS TO BUILD</span>
874
+ <div class="habit-row"><div class="line" style="width:30%"></div><div class="circles">⚪⚪⚪⚪⚪⚪⚪</div></div>
875
+ <div class="habit-row"><div class="line" style="width:30%"></div><div class="circles">⚪⚪⚪⚪⚪⚪⚪</div></div>
876
+ <div class="habit-row"><div class="line" style="width:30%"></div><div class="circles">⚪⚪⚪⚪⚪⚪⚪</div></div>
877
+ </div>
878
+ <div class="box" style="height:100px; margin-top:20px;">
879
+ <span class="label">HABIT REFLECTION COMMENTS</span>
880
+ <div class="line"></div>
881
+ <div class="line"></div>
882
+ </div>
883
+ `;
884
+ } else {
885
+ sheetContentHtml = `
886
+ <h2>CREATIVE BRAINSTORM LOG</h2>
887
+ <div class="divider"></div>
888
+ <div class="box" style="height:80px; margin-bottom:15px;">
889
+ <span class="label">CENTRAL CONCEPT TOPIC</span>
890
+ <div class="line"></div>
891
+ </div>
892
+ <div class="line"></div>
893
+ <div class="line"></div>
894
+ <div class="line"></div>
895
+ <div class="line"></div>
896
+ <div class="line"></div>
897
+ `;
898
+ }
899
+ } else if (cIdx === 2) {
900
+ if (sheetIdx % 2 === 0) {
901
+ sheetContentHtml = `
902
+ <h2>PRIORITY STRATEGY MATRIX</h2>
903
+ <div class="divider"></div>
904
+ <div class="matrix-grid">
905
+ <div class="matrix-box">
906
+ <div class="label" style="border:none;">🔥 1. URGENT & IMPORTANT</div>
907
+ <div class="line"></div>
908
+ <div class="line"></div>
909
+ </div>
910
+ <div class="matrix-box">
911
+ <div class="label" style="border:none;">📅 2. NOT URGENT & IMPORTANT</div>
912
+ <div class="line"></div>
913
+ <div class="line"></div>
914
+ </div>
915
+ <div class="matrix-box">
916
+ <div class="label" style="border:none;">⚡ 3. URGENT & NOT IMPORTANT</div>
917
+ <div class="line"></div>
918
+ <div class="line"></div>
919
+ </div>
920
+ <div class="matrix-box">
921
+ <div class="label" style="border:none;">💤 4. ELIMINATE / DELEGATE</div>
922
+ <div class="line"></div>
923
+ <div class="line"></div>
924
+ </div>
925
+ </div>
926
+ `;
927
+ } else {
928
+ sheetContentHtml = `
929
+ <h2>INSIGHT & NOTES</h2>
930
+ <div class="divider"></div>
931
+ <div class="dot-grid">
932
+ ${'<div class="dot">.</div>'.repeat(80)}
933
+ </div>
934
+ `;
935
+ }
936
+ } else if (cIdx === 3) {
937
+ if (sheetIdx % 2 === 0) {
938
+ sheetContentHtml = `
939
+ <h2>CASE STUDY REFLECTION LOG</h2>
940
+ <div class="divider"></div>
941
+ <table class="budget-table">
942
+ <thead><tr><th>ACTION STEP REQUIRED</th><th>TIMELINE</th></tr></thead>
943
+ <tbody>
944
+ <tr><td><div class="line" style="width:90%"></div></td><td>___ Days</td></tr>
945
+ <tr><td><div class="line" style="width:90%"></div></td><td>___ Days</td></tr>
946
+ <tr><td><div class="line" style="width:90%"></div></td><td>___ Days</td></tr>
947
+ </tbody>
948
+ </table>
949
+ <div class="box" style="height:90px; margin-top:20px;">
950
+ <span class="label">KEY PERFORMANCE METRIC TO DEFINE</span>
951
+ <div class="line"></div>
952
+ </div>
953
+ `;
954
+ } else {
955
+ sheetContentHtml = `
956
+ <h2>CREATIVE BRAINSTORM LOG</h2>
957
+ <div class="divider"></div>
958
+ <div class="box" style="height:80px; margin-bottom:15px;">
959
+ <span class="label">CENTRAL CONCEPT TOPIC</span>
960
+ <div class="line"></div>
961
+ </div>
962
+ <div class="line"></div>
963
+ <div class="line"></div>
964
+ <div class="line"></div>
965
+ <div class="line"></div>
966
+ `;
967
+ }
968
+ } else {
969
+ if (sheetIdx % 2 === 0) {
970
+ sheetContentHtml = `
971
+ <h2>90-DAY PROGRESS SUMMARY</h2>
972
+ <div class="divider"></div>
973
+ <div class="box">
974
+ <span class="label">MILESTONES COMPLETED & WINS</span>
975
+ <div class="checkbox-row"><div class="checkbox"></div><div class="line" style="width:75%"></div></div>
976
+ <div class="checkbox-row"><div class="checkbox"></div><div class="line" style="width:75%"></div></div>
977
+ </div>
978
+ <div class="box" style="height:120px; margin-top:15px;">
979
+ <span class="label">FUTURE PERSPECTIVE ROADMAP</span>
980
+ <div class="line"></div>
981
+ <div class="line"></div>
982
+ </div>
983
+ `;
984
+ } else {
985
+ sheetContentHtml = `
986
+ <h2>INSIGHT & NOTES</h2>
987
+ <div class="divider"></div>
988
+ <div class="dot-grid">
989
+ ${'<div class="dot">.</div>'.repeat(80)}
990
+ </div>
991
+ `;
992
+ }
993
+ }
994
+
995
+ pagesHtml += `
996
+ <div class="page ${chClassSheet}">
997
+ <div class="header-brand">BOOKFORGE DIGITAL GOAL PLANNERS</div>
998
+ <div class="page-interior">
999
+ ${sheetContentHtml}
1000
+ </div>
1001
+ <div class="page-number">Page ${globalPageNum}</div>
1002
+ </div>
1003
+ `;
1004
+ globalPageNum++;
1005
+ }
1006
+ }
1007
+
1008
+ return `
1009
+ <html>
1010
+ <head>
1011
+ <title>${title} - 120 Pages</title>
1012
+ <style>
1013
+ @media print {
1014
+ body { margin: 0; padding: 0; background: #fff; }
1015
+ .page { page-break-after: always; display: flex !important; }
1016
+ @page { size: 6in 9in; margin: 0; }
1017
+ }
1018
+ * {
1019
+ box-sizing: border-box;
1020
+ -webkit-print-color-adjust: exact !important;
1021
+ print-color-adjust: exact !important;
1022
+ }
1023
+ body {
1024
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
1025
+ color: #000;
1026
+ margin: 0;
1027
+ padding: 0;
1028
+ background: #fff;
1029
+ }
1030
+ .page {
1031
+ background: #fff;
1032
+ width: 6in;
1033
+ height: 9in;
1034
+ margin: 0 auto;
1035
+ position: relative;
1036
+ display: flex;
1037
+ flex-direction: column;
1038
+ justify-content: space-between;
1039
+ border: none;
1040
+ }
1041
+ /* Gutter Margins Alternating (Perfect Spine Binding) */
1042
+ .left-page {
1043
+ padding: 0.8in 0.75in 0.8in 0.4in;
1044
+ }
1045
+ .right-page {
1046
+ padding: 0.8in 0.4in 0.8in 0.75in;
1047
+ }
1048
+ .header-brand {
1049
+ font-size: 8px;
1050
+ color: #444;
1051
+ letter-spacing: 2px;
1052
+ text-align: center;
1053
+ border-bottom: 2px solid #000;
1054
+ padding-bottom: 6px;
1055
+ text-transform: uppercase;
1056
+ font-weight: 700;
1057
+ }
1058
+ .page-interior {
1059
+ flex-grow: 1;
1060
+ padding: 20px 0;
1061
+ display: flex;
1062
+ flex-direction: column;
1063
+ gap: 15px;
1064
+ }
1065
+ .interior-content {
1066
+ padding: 40px 10px 0 10px;
1067
+ }
1068
+ /* Cover page styling */
1069
+ .cover-page {
1070
+ justify-content: space-between;
1071
+ padding: 1.2in 0.6in;
1072
+ text-align: center;
1073
+ border: 3px solid #000;
1074
+ }
1075
+ .cover-interior {
1076
+ display: flex;
1077
+ flex-direction: column;
1078
+ align-items: center;
1079
+ margin-top: 1.5in;
1080
+ }
1081
+ .cover-title {
1082
+ font-family: 'Georgia', serif;
1083
+ font-size: 26px;
1084
+ font-weight: 900;
1085
+ text-transform: uppercase;
1086
+ letter-spacing: 1px;
1087
+ line-height: 1.3;
1088
+ margin: 0 0 15px 0;
1089
+ color: #000;
1090
+ }
1091
+ .cover-divider {
1092
+ width: 80px;
1093
+ height: 4px;
1094
+ background: #000;
1095
+ margin: 15px 0;
1096
+ }
1097
+ .cover-subtitle {
1098
+ font-family: 'Georgia', serif;
1099
+ font-size: 14px;
1100
+ color: #111;
1101
+ font-style: italic;
1102
+ line-height: 1.5;
1103
+ margin: 15px 0;
1104
+ max-width: 4.5in;
1105
+ }
1106
+ .cover-tag {
1107
+ font-size: 10px;
1108
+ font-weight: 900;
1109
+ border: 2px solid #000;
1110
+ border-radius: 4px;
1111
+ padding: 6px 12px;
1112
+ margin-top: 40px;
1113
+ letter-spacing: 2px;
1114
+ display: inline-block;
1115
+ text-transform: uppercase;
1116
+ }
1117
+ .cover-footer {
1118
+ font-size: 10px;
1119
+ font-weight: 900;
1120
+ letter-spacing: 4px;
1121
+ color: #000;
1122
+ margin-bottom: 0.5in;
1123
+ }
1124
+ /* Copyright page styling */
1125
+ .copyright-page h3 {
1126
+ font-size: 12px;
1127
+ font-weight: 800;
1128
+ margin-bottom: 8px;
1129
+ text-transform: uppercase;
1130
+ }
1131
+ .copyright-page p {
1132
+ font-size: 10px;
1133
+ line-height: 1.5;
1134
+ color: #111;
1135
+ text-align: justify;
1136
+ margin: 0 0 18px 0;
1137
+ }
1138
+ /* TOC table */
1139
+ .toc-list {
1140
+ display: flex;
1141
+ flex-direction: column;
1142
+ gap: 12px;
1143
+ margin-top: 30px;
1144
+ }
1145
+ .toc-item {
1146
+ display: flex;
1147
+ justify-content: space-between;
1148
+ font-size: 10px;
1149
+ font-weight: bold;
1150
+ color: #000;
1151
+ }
1152
+ .dots {
1153
+ flex-grow: 1;
1154
+ text-align: center;
1155
+ color: #333;
1156
+ overflow: hidden;
1157
+ white-space: nowrap;
1158
+ margin: 0 10px;
1159
+ }
1160
+ /* Chapter divisions cover */
1161
+ .chapter-cover {
1162
+ justify-content: space-between;
1163
+ padding: 1.2in 0.6in;
1164
+ text-align: center;
1165
+ border: 2px solid #000;
1166
+ }
1167
+ .chapter-cover-interior {
1168
+ display: flex;
1169
+ flex-direction: column;
1170
+ align-items: center;
1171
+ margin-top: 2in;
1172
+ }
1173
+ .chapter-number {
1174
+ font-size: 12px;
1175
+ font-weight: 900;
1176
+ letter-spacing: 4px;
1177
+ color: #000;
1178
+ }
1179
+ .chapter-cover h2 {
1180
+ font-family: 'Georgia', serif;
1181
+ font-size: 22px;
1182
+ font-weight: 900;
1183
+ margin-top: 20px;
1184
+ }
1185
+ /* Chapter text summaries */
1186
+ .chapter-content {
1187
+ font-family: 'Georgia', serif;
1188
+ line-height: 1.7;
1189
+ }
1190
+ .chapter-text-interior {
1191
+ padding: 30px 10px;
1192
+ text-align: justify;
1193
+ }
1194
+ .chapter-text-interior h3 {
1195
+ font-size: 13px;
1196
+ font-weight: 900;
1197
+ border-bottom: 2px solid #000;
1198
+ padding-bottom: 6px;
1199
+ margin-bottom: 18px;
1200
+ letter-spacing: 1px;
1201
+ }
1202
+ .chapter-text-interior p {
1203
+ font-size: 11px;
1204
+ line-height: 1.7;
1205
+ color: #000;
1206
+ margin-bottom: 14px;
1207
+ }
1208
+ .chapter-text-interior li {
1209
+ font-size: 11px;
1210
+ margin-left: 15px;
1211
+ list-style-type: none;
1212
+ margin-bottom: 8px;
1213
+ color: #000;
1214
+ font-weight: 600;
1215
+ }
1216
+ /* High-Contrast Workbook Elements */
1217
+ h2 {
1218
+ font-size: 14px;
1219
+ font-weight: 900;
1220
+ text-align: center;
1221
+ margin: 0 0 5px 0;
1222
+ letter-spacing: 1px;
1223
+ text-transform: uppercase;
1224
+ }
1225
+ .divider {
1226
+ height: 3px;
1227
+ background: #000;
1228
+ width: 40px;
1229
+ margin: 0 auto 10px auto;
1230
+ }
1231
+ .box {
1232
+ border: 2px solid #000;
1233
+ border-radius: 6px;
1234
+ padding: 12px 16px;
1235
+ display: flex;
1236
+ flex-direction: column;
1237
+ gap: 12px;
1238
+ background: #fff;
1239
+ }
1240
+ .label {
1241
+ font-size: 9px;
1242
+ font-weight: 900;
1243
+ letter-spacing: 1.5px;
1244
+ color: #000;
1245
+ border-bottom: 2px solid #000;
1246
+ padding-bottom: 4px;
1247
+ text-transform: uppercase;
1248
+ }
1249
+ .line {
1250
+ border-bottom: 2px dotted #000;
1251
+ height: 20px;
1252
+ width: 100%;
1253
+ }
1254
+ .checkbox-row {
1255
+ display: flex;
1256
+ align-items: center;
1257
+ gap: 12px;
1258
+ }
1259
+ .checkbox {
1260
+ width: 16px;
1261
+ height: 16px;
1262
+ border: 2.5px solid #000;
1263
+ border-radius: 3px;
1264
+ flex-shrink: 0;
1265
+ background: #fff;
1266
+ }
1267
+ .doodle-placeholder {
1268
+ border: 2px dashed #000;
1269
+ border-radius: 4px;
1270
+ flex-grow: 1;
1271
+ min-height: 80px;
1272
+ background: #fff;
1273
+ }
1274
+ .habit-row {
1275
+ display: flex;
1276
+ align-items: center;
1277
+ justify-content: space-between;
1278
+ gap: 12px;
1279
+ }
1280
+ .circles {
1281
+ font-size: 15px;
1282
+ letter-spacing: 4px;
1283
+ color: #000;
1284
+ }
1285
+ /* Dot Grid journaling */
1286
+ .dot-grid {
1287
+ display: grid;
1288
+ grid-template-columns: repeat(8, 1fr);
1289
+ grid-gap: 25px;
1290
+ padding: 30px 40px;
1291
+ opacity: 0.35;
1292
+ flex-grow: 1;
1293
+ }
1294
+ .dot {
1295
+ font-size: 26px;
1296
+ text-align: center;
1297
+ line-height: 0;
1298
+ color: #000;
1299
+ font-weight: 900;
1300
+ }
1301
+ /* Priority Matrix 2x2 grid */
1302
+ .matrix-grid {
1303
+ display: grid;
1304
+ grid-template-columns: 1fr 1fr;
1305
+ grid-template-rows: 1fr 1fr;
1306
+ grid-gap: 15px;
1307
+ flex-grow: 1;
1308
+ padding: 10px 0;
1309
+ }
1310
+ .matrix-box {
1311
+ border: 2px solid #000;
1312
+ border-radius: 6px;
1313
+ padding: 12px;
1314
+ display: flex;
1315
+ flex-direction: column;
1316
+ justify-content: space-between;
1317
+ }
1318
+ /* Double Column budget/case tables */
1319
+ .budget-table {
1320
+ width: 100%;
1321
+ border-collapse: collapse;
1322
+ margin-top: 10px;
1323
+ }
1324
+ .budget-table th {
1325
+ font-size: 9px;
1326
+ font-weight: 900;
1327
+ text-align: left;
1328
+ padding: 8px;
1329
+ border-bottom: 3px solid #000;
1330
+ text-transform: uppercase;
1331
+ }
1332
+ .budget-table td {
1333
+ padding: 12px 8px;
1334
+ border-bottom: 2px solid #000;
1335
+ font-size: 11px;
1336
+ color: #000;
1337
+ }
1338
+ .page-number {
1339
+ text-align: center;
1340
+ font-size: 10px;
1341
+ color: #000;
1342
+ border-top: 2px solid #000;
1343
+ padding-top: 6px;
1344
+ font-weight: 700;
1345
+ }
1346
+ </style>
1347
+ </head>
1348
+ <body>
1349
+ ${pagesHtml}
1350
+ <script>
1351
+ window.onload = function() { window.print(); }
1352
+ </script>
1353
+ </body>
1354
+ </html>
1355
+ `;
1356
+ };
1357
+
1358
  const createProductZip = ({
1359
  title, subtitle, description, tags, cta, price, platform, productContent, coverBuffer, safeTitle
1360
  }) => {
 
1378
  archive.append(coverBuffer, { name: filename });
1379
  }
1380
 
1381
+ // 3. Premium 120-Page print-ready HTML Interior
1382
+ try {
1383
+ const compiledHtml = compile120PageHtml(title, subtitle, tags, productContent);
1384
+ archive.append(compiledHtml, { name: 'printable_120_page_interior.html' });
1385
+ } catch (htmlErr) {
1386
+ console.error('[ZIP Package] Error appending compiled HTML interior:', htmlErr);
1387
+ }
1388
+
1389
+ // 4. Listing metadata as plain text
1390
  const isSvgCover = coverBuffer ? coverBuffer.toString().trim().startsWith('<svg') : false;
1391
  const coverFilename = isSvgCover ? 'cover.svg' : 'cover.jpg';
1392
  const listing = [
 
1406
  `Copy the above fields into your store listing.`,
1407
  `Upload ${coverFilename} as your product thumbnail.`,
1408
  `Attach or link book_content.md as the downloadable product file.`,
1409
+ `Alternatively, print or save printable_120_page_interior.html as a stunning PDF layout.`,
1410
  ].join('\n');
1411
  archive.append(listing, { name: 'listing.txt' });
1412