Overview
Theplantilla.html file uses a simple variable replacement system. The Python script searches for placeholders wrapped in double curly braces and replaces them with generated content.
All replacements happen in memory using Python’s built-in
str.replace() method.Available Variables
{{TITULO}}
The story title generated by the AI.Location in template: Line 117 (inside
<h1> tag)Source: Extracted from AI response using regex pattern <TITULO>(.*?)</TITULO>Fallback: "Historia sin título" if extraction fails{{HISTORIA}}
The main story text (2-3 paragraphs) generated by the AI.Location in template: Line 120 (inside
<p> tag within .historia-texto div)Source: Extracted from AI response using regex pattern <HISTORIA>(.*?)</HISTORIA>Fallback: "Error al generar la historia." if extraction failsThe story content may include line breaks and special characters. The template preserves all formatting.
{{IMAGEN_URL}}
A Picsum.photos URL with a unique UUID seed for reproducible random images.Location in template: Line 118 (
src attribute of <img> tag)Format: https://picsum.photos/seed/{uuid}/600/350Dimensions: 600×350 pixels{{MENU}}
Dynamically generated HTML for the sidebar navigation menu.Location in template: Line 113 (inside
<nav id="sidebar">)Source: Built from historial.json data structureStructure: Month headers with lists of story linksReplacement Process
The script replaces variables in a specific order:The replacement order doesn’t matter in this case since no variable contains another variable.
HTML Structure
The template includes several key structural elements:Page Layout
CSS Classes Reference
Menu Classes
Menu Classes
Content Classes
Content Classes
.container: Main content card with shadow and rounded corners.imagen-dia: Story image styling.historia-texto: Story text container with paragraph styling.footer: Small footer text
JavaScript Functions
Toggles the sidebar visibility by adding/removing the
abierto class.Called by: Menu button (#menu-btn) and close button (#close-btn)Implementation:Styling Overview
The template includes embedded CSS with these design features:Color Scheme
- Background:
#f0f2f5 - Card:
#ffffff - Text:
#2d3748(headings),#4a5568(body) - Links:
#4a5568(default),#3182ce(hover)
Layout
- Flexbox centering for main content
- Fixed positioning for sidebar
- Responsive max-width (600px)
- Smooth slide-in animation (0.3s)
Typography
- Font: Segoe UI (fallback to system fonts)
- Title: 2rem
- Body: 1.15rem
- Line height: 1.7
Effects
- Box shadows on buttons and cards
- Rounded corners (8px-16px)
- Hover underlines on links
- Slide-in sidebar animation
Customization Tips
Related Resources
Script Reference
How variables are generated in the Python script
History JSON
Data structure behind the variable
Customization Guide
Modify styles, colors, and layout