Spaces:
Running
Running
Build a web application named "StyleScript" that allows users (especially students) to generate a PDF document from their code output or text files using a prompt. Core features: 1. A simple UI where user uploads a text file or enters output text manually. 2. User can enter a natural language prompt like: "Generate PDF of my output with dark background, Courier font, and title 'My Python Result'" 3. Parse the prompt to extract styling preferences (font, theme, title). 4. Generate a formatted PDF based on the prompt using Python (e.g., ReportLab, FPDF, pdfkit). 5. Provide a preview of the PDF and option to customize further (change font size, theme, alignment). 6. Allow download of the final PDF. 7. Bonus (optional): Save prompt history for logged-in users. Frontend Stack: HTML, CSS (Tailwind or Bootstrap), JavaScript Backend Stack: Python with Flask (or FastAPI) PDF Generator: Use libraries like ReportLab, WeasyPrint, or pdfkit Add comments and modular code structure so it's easy to expand in future. - Initial Deployment
Browse files- README.md +7 -5
- index.html +489 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: stylescript
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,489 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>StyleScript - Code to PDF Generator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
/* Custom styles that can't be done with Tailwind */
|
| 11 |
+
.code-display {
|
| 12 |
+
font-family: 'Courier New', monospace;
|
| 13 |
+
tab-size: 4;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.theme-dark {
|
| 17 |
+
background-color: #1e293b;
|
| 18 |
+
color: #f8fafc;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.theme-light {
|
| 22 |
+
background-color: #ffffff;
|
| 23 |
+
color: #1e293b;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.theme-solarized {
|
| 27 |
+
background-color: #fdf6e3;
|
| 28 |
+
color: #657b83;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.pdf-preview {
|
| 32 |
+
width: 100%;
|
| 33 |
+
height: 500px;
|
| 34 |
+
border: 1px solid #e2e8f0;
|
| 35 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/* Animation for loading */
|
| 39 |
+
@keyframes pulse {
|
| 40 |
+
0%, 100% {
|
| 41 |
+
opacity: 1;
|
| 42 |
+
}
|
| 43 |
+
50% {
|
| 44 |
+
opacity: 0.5;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.animate-pulse {
|
| 49 |
+
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
| 50 |
+
}
|
| 51 |
+
</style>
|
| 52 |
+
</head>
|
| 53 |
+
<body class="bg-gray-50 min-h-screen">
|
| 54 |
+
<!-- Navigation -->
|
| 55 |
+
<nav class="bg-indigo-600 text-white shadow-lg">
|
| 56 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 57 |
+
<div class="flex justify-between h-16 items-center">
|
| 58 |
+
<div class="flex items-center">
|
| 59 |
+
<div class="flex-shrink-0 flex items-center">
|
| 60 |
+
<i class="fas fa-code text-2xl mr-2"></i>
|
| 61 |
+
<span class="text-xl font-bold">StyleScript</span>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
<div class="hidden md:block">
|
| 65 |
+
<div class="ml-10 flex items-baseline space-x-4">
|
| 66 |
+
<a href="#" class="px-3 py-2 rounded-md text-sm font-medium bg-indigo-700">Home</a>
|
| 67 |
+
<a href="#" class="px-3 py-2 rounded-md text-sm font-medium hover:bg-indigo-500">History</a>
|
| 68 |
+
<a href="#" class="px-3 py-2 rounded-md text-sm font-medium hover:bg-indigo-500">About</a>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
<div class="md:hidden">
|
| 72 |
+
<button class="mobile-menu-button p-2 rounded-md hover:bg-indigo-500 focus:outline-none">
|
| 73 |
+
<i class="fas fa-bars"></i>
|
| 74 |
+
</button>
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
</nav>
|
| 79 |
+
|
| 80 |
+
<!-- Hero Section -->
|
| 81 |
+
<div class="bg-indigo-700 text-white">
|
| 82 |
+
<div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
|
| 83 |
+
<div class="text-center">
|
| 84 |
+
<h1 class="text-4xl font-extrabold tracking-tight sm:text-5xl md:text-6xl">
|
| 85 |
+
<span class="block">Transform Your Code</span>
|
| 86 |
+
<span class="block text-indigo-200">Into Beautiful PDFs</span>
|
| 87 |
+
</h1>
|
| 88 |
+
<p class="mt-3 max-w-md mx-auto text-base text-indigo-100 sm:text-lg md:mt-5 md:text-xl md:max-w-3xl">
|
| 89 |
+
Upload your code or text, describe how you want it styled, and get a professional PDF instantly.
|
| 90 |
+
</p>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
</div>
|
| 94 |
+
|
| 95 |
+
<!-- Main Content -->
|
| 96 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 97 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
| 98 |
+
<!-- Input Section -->
|
| 99 |
+
<div class="bg-white rounded-lg shadow-md p-6">
|
| 100 |
+
<h2 class="text-2xl font-bold text-gray-800 mb-4">Create Your PDF</h2>
|
| 101 |
+
|
| 102 |
+
<!-- File Upload -->
|
| 103 |
+
<div class="mb-6">
|
| 104 |
+
<label class="block text-sm font-medium text-gray-700 mb-2">Upload Text/Code File</label>
|
| 105 |
+
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
| 106 |
+
<div class="space-y-1 text-center">
|
| 107 |
+
<div class="flex text-sm text-gray-600">
|
| 108 |
+
<label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none">
|
| 109 |
+
<span>Upload a file</span>
|
| 110 |
+
<input id="file-upload" name="file-upload" type="file" class="sr-only" accept=".txt,.py,.js,.java,.c,.cpp,.html,.css">
|
| 111 |
+
</label>
|
| 112 |
+
<p class="pl-1">or drag and drop</p>
|
| 113 |
+
</div>
|
| 114 |
+
<p class="text-xs text-gray-500">TXT, PY, JS, JAVA, C, CPP, HTML, CSS up to 10MB</p>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
|
| 119 |
+
<!-- Or Enter Text Directly -->
|
| 120 |
+
<div class="mb-6">
|
| 121 |
+
<label for="code-input" class="block text-sm font-medium text-gray-700 mb-2">Or enter your text/code directly</label>
|
| 122 |
+
<textarea id="code-input" rows="10" class="code-display shadow-sm focus:ring-indigo-500 focus:border-indigo-500 mt-1 block w-full sm:text-sm border border-gray-300 rounded-md p-3"></textarea>
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
+
<!-- Styling Prompt -->
|
| 126 |
+
<div class="mb-6">
|
| 127 |
+
<label for="styling-prompt" class="block text-sm font-medium text-gray-700 mb-2">How should we style your PDF?</label>
|
| 128 |
+
<div class="mt-1 relative rounded-md shadow-sm">
|
| 129 |
+
<textarea id="styling-prompt" rows="3" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border border-gray-300 rounded-md p-3" placeholder="Example: 'Generate PDF with dark background, Courier font, title "My Python Result", and line numbers'"></textarea>
|
| 130 |
+
</div>
|
| 131 |
+
<p class="mt-2 text-sm text-gray-500">Describe your desired styling in natural language</p>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<!-- Quick Style Options -->
|
| 135 |
+
<div class="mb-6">
|
| 136 |
+
<label class="block text-sm font-medium text-gray-700 mb-2">Quick Style Options</label>
|
| 137 |
+
<div class="grid grid-cols-3 gap-2">
|
| 138 |
+
<button onclick="applyQuickStyle('dark')" class="theme-dark py-2 px-3 rounded text-sm font-medium">Dark Theme</button>
|
| 139 |
+
<button onclick="applyQuickStyle('light')" class="theme-light py-2 px-3 rounded text-sm font-medium border border-gray-300">Light Theme</button>
|
| 140 |
+
<button onclick="applyQuickStyle('solarized')" class="theme-solarized py-2 px-3 rounded text-sm font-medium border border-gray-300">Solarized</button>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
|
| 144 |
+
<!-- Generate Button -->
|
| 145 |
+
<button onclick="generatePDF()" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-4 rounded-md flex items-center justify-center">
|
| 146 |
+
<i class="fas fa-magic mr-2"></i> Generate PDF
|
| 147 |
+
</button>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<!-- Preview Section -->
|
| 151 |
+
<div class="bg-white rounded-lg shadow-md p-6">
|
| 152 |
+
<div class="flex justify-between items-center mb-4">
|
| 153 |
+
<h2 class="text-2xl font-bold text-gray-800">PDF Preview</h2>
|
| 154 |
+
<div id="download-section" class="hidden">
|
| 155 |
+
<button onclick="downloadPDF()" class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-md flex items-center">
|
| 156 |
+
<i class="fas fa-download mr-2"></i> Download PDF
|
| 157 |
+
</button>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
<!-- Preview Container -->
|
| 162 |
+
<div id="preview-container" class="pdf-preview rounded-md flex items-center justify-center bg-gray-100">
|
| 163 |
+
<div class="text-center p-6">
|
| 164 |
+
<i class="fas fa-file-pdf text-5xl text-gray-400 mb-4"></i>
|
| 165 |
+
<p class="text-gray-500">Your PDF preview will appear here</p>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
|
| 169 |
+
<!-- Loading State -->
|
| 170 |
+
<div id="loading-state" class="hidden mt-4">
|
| 171 |
+
<div class="flex items-center justify-center space-x-2">
|
| 172 |
+
<div class="w-4 h-4 rounded-full bg-indigo-600 animate-pulse"></div>
|
| 173 |
+
<div class="w-4 h-4 rounded-full bg-indigo-600 animate-pulse delay-100"></div>
|
| 174 |
+
<div class="w-4 h-4 rounded-full bg-indigo-600 animate-pulse delay-200"></div>
|
| 175 |
+
</div>
|
| 176 |
+
<p class="text-center mt-2 text-gray-600">Generating your PDF...</p>
|
| 177 |
+
</div>
|
| 178 |
+
|
| 179 |
+
<!-- Customization Options (shown after generation) -->
|
| 180 |
+
<div id="customization-options" class="hidden mt-6">
|
| 181 |
+
<h3 class="text-lg font-medium text-gray-800 mb-3">Customize Further</h3>
|
| 182 |
+
|
| 183 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 184 |
+
<!-- Font Family -->
|
| 185 |
+
<div>
|
| 186 |
+
<label for="font-family" class="block text-sm font-medium text-gray-700 mb-1">Font Family</label>
|
| 187 |
+
<select id="font-family" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
|
| 188 |
+
<option value="Courier">Courier</option>
|
| 189 |
+
<option value="Arial">Arial</option>
|
| 190 |
+
<option value="Times New Roman">Times New Roman</option>
|
| 191 |
+
<option value="Helvetica">Helvetica</option>
|
| 192 |
+
</select>
|
| 193 |
+
</div>
|
| 194 |
+
|
| 195 |
+
<!-- Font Size -->
|
| 196 |
+
<div>
|
| 197 |
+
<label for="font-size" class="block text-sm font-medium text-gray-700 mb-1">Font Size</label>
|
| 198 |
+
<select id="font-size" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
|
| 199 |
+
<option value="10">10pt</option>
|
| 200 |
+
<option value="11">11pt</option>
|
| 201 |
+
<option value="12" selected>12pt</option>
|
| 202 |
+
<option value="14">14pt</option>
|
| 203 |
+
<option value="16">16pt</option>
|
| 204 |
+
</select>
|
| 205 |
+
</div>
|
| 206 |
+
|
| 207 |
+
<!-- Line Numbers -->
|
| 208 |
+
<div>
|
| 209 |
+
<label for="line-numbers" class="block text-sm font-medium text-gray-700 mb-1">Line Numbers</label>
|
| 210 |
+
<select id="line-numbers" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
|
| 211 |
+
<option value="true">Show</option>
|
| 212 |
+
<option value="false">Hide</option>
|
| 213 |
+
</select>
|
| 214 |
+
</div>
|
| 215 |
+
|
| 216 |
+
<!-- Page Size -->
|
| 217 |
+
<div>
|
| 218 |
+
<label for="page-size" class="block text-sm font-medium text-gray-700 mb-1">Page Size</label>
|
| 219 |
+
<select id="page-size" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
|
| 220 |
+
<option value="A4">A4</option>
|
| 221 |
+
<option value="Letter">Letter</option>
|
| 222 |
+
<option value="Legal">Legal</option>
|
| 223 |
+
</select>
|
| 224 |
+
</div>
|
| 225 |
+
</div>
|
| 226 |
+
|
| 227 |
+
<button onclick="updatePreview()" class="mt-4 bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-md flex items-center">
|
| 228 |
+
<i class="fas fa-sync-alt mr-2"></i> Update Preview
|
| 229 |
+
</button>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
</div>
|
| 234 |
+
|
| 235 |
+
<!-- Features Section -->
|
| 236 |
+
<div class="bg-gray-100 py-12">
|
| 237 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 238 |
+
<div class="lg:text-center">
|
| 239 |
+
<h2 class="text-base text-indigo-600 font-semibold tracking-wide uppercase">Features</h2>
|
| 240 |
+
<p class="mt-2 text-3xl leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
|
| 241 |
+
Why Choose StyleScript
|
| 242 |
+
</p>
|
| 243 |
+
</div>
|
| 244 |
+
|
| 245 |
+
<div class="mt-10">
|
| 246 |
+
<div class="grid grid-cols-1 gap-10 sm:grid-cols-2 lg:grid-cols-3">
|
| 247 |
+
<div class="bg-white overflow-hidden shadow rounded-lg">
|
| 248 |
+
<div class="px-4 py-5 sm:p-6">
|
| 249 |
+
<div class="flex items-center">
|
| 250 |
+
<div class="flex-shrink-0 bg-indigo-500 rounded-md p-3">
|
| 251 |
+
<i class="fas fa-language text-white text-xl"></i>
|
| 252 |
+
</div>
|
| 253 |
+
<div class="ml-5 w-0 flex-1">
|
| 254 |
+
<h3 class="text-lg font-medium text-gray-900">Natural Language Processing</h3>
|
| 255 |
+
<p class="mt-1 text-sm text-gray-500">
|
| 256 |
+
Describe your desired styling in plain English and let our AI do the work.
|
| 257 |
+
</p>
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
</div>
|
| 261 |
+
</div>
|
| 262 |
+
|
| 263 |
+
<div class="bg-white overflow-hidden shadow rounded-lg">
|
| 264 |
+
<div class="px-4 py-5 sm:p-6">
|
| 265 |
+
<div class="flex items-center">
|
| 266 |
+
<div class="flex-shrink-0 bg-indigo-500 rounded-md p-3">
|
| 267 |
+
<i class="fas fa-file-code text-white text-xl"></i>
|
| 268 |
+
</div>
|
| 269 |
+
<div class="ml-5 w-0 flex-1">
|
| 270 |
+
<h3 class="text-lg font-medium text-gray-900">Code Highlighting</h3>
|
| 271 |
+
<p class="mt-1 text-sm text-gray-500">
|
| 272 |
+
Automatic syntax highlighting for multiple programming languages.
|
| 273 |
+
</p>
|
| 274 |
+
</div>
|
| 275 |
+
</div>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
|
| 279 |
+
<div class="bg-white overflow-hidden shadow rounded-lg">
|
| 280 |
+
<div class="px-4 py-5 sm:p-6">
|
| 281 |
+
<div class="flex items-center">
|
| 282 |
+
<div class="flex-shrink-0 bg-indigo-500 rounded-md p-3">
|
| 283 |
+
<i class="fas fa-sliders-h text-white text-xl"></i>
|
| 284 |
+
</div>
|
| 285 |
+
<div class="ml-5 w-0 flex-1">
|
| 286 |
+
<h3 class="text-lg font-medium text-gray-900">Customization</h3>
|
| 287 |
+
<p class="mt-1 text-sm text-gray-500">
|
| 288 |
+
Fine-tune every aspect of your PDF after generation.
|
| 289 |
+
</p>
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
</div>
|
| 295 |
+
</div>
|
| 296 |
+
</div>
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<!-- Footer -->
|
| 300 |
+
<footer class="bg-gray-800 text-white">
|
| 301 |
+
<div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
|
| 302 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
| 303 |
+
<div>
|
| 304 |
+
<h3 class="text-lg font-semibold mb-4">StyleScript</h3>
|
| 305 |
+
<p class="text-gray-300 text-sm">
|
| 306 |
+
Transform your code and text into beautifully styled PDF documents with just a few clicks.
|
| 307 |
+
</p>
|
| 308 |
+
</div>
|
| 309 |
+
<div>
|
| 310 |
+
<h3 class="text-lg font-semibold mb-4">Quick Links</h3>
|
| 311 |
+
<ul class="space-y-2">
|
| 312 |
+
<li><a href="#" class="text-gray-300 hover:text-white text-sm">Home</a></li>
|
| 313 |
+
<li><a href="#" class="text-gray-300 hover:text-white text-sm">Documentation</a></li>
|
| 314 |
+
<li><a href="#" class="text-gray-300 hover:text-white text-sm">API</a></li>
|
| 315 |
+
</ul>
|
| 316 |
+
</div>
|
| 317 |
+
<div>
|
| 318 |
+
<h3 class="text-lg font-semibold mb-4">Connect</h3>
|
| 319 |
+
<div class="flex space-x-4">
|
| 320 |
+
<a href="#" class="text-gray-300 hover:text-white"><i class="fab fa-twitter"></i></a>
|
| 321 |
+
<a href="#" class="text-gray-300 hover:text-white"><i class="fab fa-github"></i></a>
|
| 322 |
+
<a href="#" class="text-gray-300 hover:text-white"><i class="fab fa-discord"></i></a>
|
| 323 |
+
</div>
|
| 324 |
+
</div>
|
| 325 |
+
</div>
|
| 326 |
+
<div class="mt-8 pt-8 border-t border-gray-700 text-sm text-gray-400 text-center">
|
| 327 |
+
© 2023 StyleScript. All rights reserved.
|
| 328 |
+
</div>
|
| 329 |
+
</div>
|
| 330 |
+
</footer>
|
| 331 |
+
|
| 332 |
+
<script>
|
| 333 |
+
// Global variables
|
| 334 |
+
let currentPDFData = null;
|
| 335 |
+
|
| 336 |
+
// Apply quick style presets
|
| 337 |
+
function applyQuickStyle(style) {
|
| 338 |
+
let promptText = '';
|
| 339 |
+
|
| 340 |
+
switch(style) {
|
| 341 |
+
case 'dark':
|
| 342 |
+
promptText = 'Generate PDF with dark background, Courier font, white text, and line numbers';
|
| 343 |
+
break;
|
| 344 |
+
case 'light':
|
| 345 |
+
promptText = 'Generate PDF with light background, Arial font, black text, and no line numbers';
|
| 346 |
+
break;
|
| 347 |
+
case 'solarized':
|
| 348 |
+
promptText = 'Generate PDF with solarized light background, Consolas font, and line numbers';
|
| 349 |
+
break;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
document.getElementById('styling-prompt').value = promptText;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
// Generate PDF based on user input
|
| 356 |
+
function generatePDF() {
|
| 357 |
+
const codeInput = document.getElementById('code-input').value;
|
| 358 |
+
const stylingPrompt = document.getElementById('styling-prompt').value;
|
| 359 |
+
|
| 360 |
+
if (!codeInput && !document.getElementById('file-upload').files[0]) {
|
| 361 |
+
alert('Please enter some text/code or upload a file first');
|
| 362 |
+
return;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
if (!stylingPrompt) {
|
| 366 |
+
alert('Please describe how you want your PDF styled');
|
| 367 |
+
return;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
// Show loading state
|
| 371 |
+
document.getElementById('loading-state').classList.remove('hidden');
|
| 372 |
+
document.getElementById('preview-container').innerHTML = '';
|
| 373 |
+
|
| 374 |
+
// Hide download button and customization options during generation
|
| 375 |
+
document.getElementById('download-section').classList.add('hidden');
|
| 376 |
+
document.getElementById('customization-options').classList.add('hidden');
|
| 377 |
+
|
| 378 |
+
// In a real app, this would be an API call to your Python backend
|
| 379 |
+
// For demo purposes, we'll simulate the API call with setTimeout
|
| 380 |
+
setTimeout(() => {
|
| 381 |
+
// Simulate API response
|
| 382 |
+
const mockResponse = {
|
| 383 |
+
success: true,
|
| 384 |
+
pdfData: "data:application/pdf;base64,...", // In real app, this would be the actual PDF data
|
| 385 |
+
settings: {
|
| 386 |
+
fontFamily: 'Courier',
|
| 387 |
+
fontSize: '12',
|
| 388 |
+
lineNumbers: true,
|
| 389 |
+
theme: 'dark',
|
| 390 |
+
title: 'My Generated PDF'
|
| 391 |
+
}
|
| 392 |
+
};
|
| 393 |
+
|
| 394 |
+
// Process the response
|
| 395 |
+
if (mockResponse.success) {
|
| 396 |
+
currentPDFData = mockResponse.pdfData;
|
| 397 |
+
|
| 398 |
+
// Show PDF preview (in real app, this would be the actual PDF)
|
| 399 |
+
document.getElementById('preview-container').innerHTML = `
|
| 400 |
+
<div class="w-full h-full flex items-center justify-center">
|
| 401 |
+
<div class="text-center">
|
| 402 |
+
<i class="fas fa-file-pdf text-6xl text-indigo-600 mb-4"></i>
|
| 403 |
+
<h3 class="text-xl font-bold mb-2">PDF Preview</h3>
|
| 404 |
+
<p class="text-gray-600">In a real application, the actual PDF would be displayed here</p>
|
| 405 |
+
<p class="mt-2 text-sm text-gray-500">Font: ${mockResponse.settings.fontFamily}, Size: ${mockResponse.settings.fontSize}pt</p>
|
| 406 |
+
<p class="text-sm text-gray-500">Theme: ${mockResponse.settings.theme}, Line Numbers: ${mockResponse.settings.lineNumbers ? 'Yes' : 'No'}</p>
|
| 407 |
+
</div>
|
| 408 |
+
</div>
|
| 409 |
+
`;
|
| 410 |
+
|
| 411 |
+
// Show download button and customization options
|
| 412 |
+
document.getElementById('download-section').classList.remove('hidden');
|
| 413 |
+
document.getElementById('customization-options').classList.remove('hidden');
|
| 414 |
+
|
| 415 |
+
// Set the customization options to match the generated PDF
|
| 416 |
+
document.getElementById('font-family').value = mockResponse.settings.fontFamily;
|
| 417 |
+
document.getElementById('font-size').value = mockResponse.settings.fontSize;
|
| 418 |
+
document.getElementById('line-numbers').value = mockResponse.settings.lineNumbers;
|
| 419 |
+
} else {
|
| 420 |
+
alert('Failed to generate PDF. Please try again.');
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
// Hide loading state
|
| 424 |
+
document.getElementById('loading-state').classList.add('hidden');
|
| 425 |
+
}, 2000);
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
// Download the generated PDF
|
| 429 |
+
function downloadPDF() {
|
| 430 |
+
if (!currentPDFData) {
|
| 431 |
+
alert('No PDF generated yet');
|
| 432 |
+
return;
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
// In a real app, this would use the actual PDF data
|
| 436 |
+
alert('In a real application, this would download the PDF file');
|
| 437 |
+
|
| 438 |
+
// For demo purposes, we'll create a dummy download
|
| 439 |
+
const link = document.createElement('a');
|
| 440 |
+
link.href = '#'; // In real app, this would be currentPDFData
|
| 441 |
+
link.download = 'styled_code.pdf';
|
| 442 |
+
document.body.appendChild(link);
|
| 443 |
+
link.click();
|
| 444 |
+
document.body.removeChild(link);
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
// Update the PDF preview with new customization settings
|
| 448 |
+
function updatePreview() {
|
| 449 |
+
const fontFamily = document.getElementById('font-family').value;
|
| 450 |
+
const fontSize = document.getElementById('font-size').value;
|
| 451 |
+
const lineNumbers = document.getElementById('line-numbers').value === 'true';
|
| 452 |
+
|
| 453 |
+
// Show loading state
|
| 454 |
+
document.getElementById('loading-state').classList.remove('hidden');
|
| 455 |
+
|
| 456 |
+
// In a real app, this would send the updated settings to the backend
|
| 457 |
+
// For demo, we'll just update the displayed info
|
| 458 |
+
setTimeout(() => {
|
| 459 |
+
document.getElementById('preview-container').innerHTML = `
|
| 460 |
+
<div class="w-full h-full flex items-center justify-center">
|
| 461 |
+
<div class="text-center">
|
| 462 |
+
<i class="fas fa-file-pdf text-6xl text-indigo-600 mb-4"></i>
|
| 463 |
+
<h3 class="text-xl font-bold mb-2">Updated PDF Preview</h3>
|
| 464 |
+
<p class="text-gray-600">Settings updated successfully</p>
|
| 465 |
+
<p class="mt-2 text-sm text-gray-500">Font: ${fontFamily}, Size: ${fontSize}pt</p>
|
| 466 |
+
<p class="text-sm text-gray-500">Line Numbers: ${lineNumbers ? 'Yes' : 'No'}</p>
|
| 467 |
+
</div>
|
| 468 |
+
</div>
|
| 469 |
+
`;
|
| 470 |
+
|
| 471 |
+
// Hide loading state
|
| 472 |
+
document.getElementById('loading-state').classList.add('hidden');
|
| 473 |
+
}, 1000);
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
// Handle file upload
|
| 477 |
+
document.getElementById('file-upload').addEventListener('change', function(e) {
|
| 478 |
+
const file = e.target.files[0];
|
| 479 |
+
if (!file) return;
|
| 480 |
+
|
| 481 |
+
const reader = new FileReader();
|
| 482 |
+
reader.onload = function(e) {
|
| 483 |
+
document.getElementById('code-input').value = e.target.result;
|
| 484 |
+
};
|
| 485 |
+
reader.readAsText(file);
|
| 486 |
+
});
|
| 487 |
+
</script>
|
| 488 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=mhzftech/stylescript" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 489 |
+
</html>
|