From 74e7f63ad50b1a7c396f25becbcdff6d69ba6c6f Mon Sep 17 00:00:00 2001 From: mi Date: Thu, 20 Nov 2025 11:36:30 +1000 Subject: [PATCH] :sparkles: generate pages --- .gitignore | 6 +- content/about.md | 1 + content/comics.md | 0 content/contact.md | 0 content/links.md | 0 content/now.md | 0 content/projects.md | 0 content/uses.md | 0 requirements.txt | 1 + scripts/build.py | 191 ++++++++++++++++++++++++++++++++++++++++++++ site/index.html | 14 ++-- site/styles.css | 24 ------ 12 files changed, 205 insertions(+), 32 deletions(-) create mode 100644 content/about.md create mode 100644 content/comics.md create mode 100644 content/contact.md create mode 100644 content/links.md create mode 100644 content/now.md create mode 100644 content/projects.md create mode 100644 content/uses.md create mode 100644 requirements.txt create mode 100755 scripts/build.py diff --git a/.gitignore b/.gitignore index ef891e5..608bc18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .venv .idea -.DS_Store \ No newline at end of file +.DS_Store + +# Generated HTML files from markdown +site/*.html +!site/index.html \ No newline at end of file diff --git a/content/about.md b/content/about.md new file mode 100644 index 0000000..ca1e30b --- /dev/null +++ b/content/about.md @@ -0,0 +1 @@ +# About \ No newline at end of file diff --git a/content/comics.md b/content/comics.md new file mode 100644 index 0000000..e69de29 diff --git a/content/contact.md b/content/contact.md new file mode 100644 index 0000000..e69de29 diff --git a/content/links.md b/content/links.md new file mode 100644 index 0000000..e69de29 diff --git a/content/now.md b/content/now.md new file mode 100644 index 0000000..e69de29 diff --git a/content/projects.md b/content/projects.md new file mode 100644 index 0000000..e69de29 diff --git a/content/uses.md b/content/uses.md new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9d5c1a3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +markdown>=3.4.0 diff --git a/scripts/build.py b/scripts/build.py new file mode 100755 index 0000000..5e561c4 --- /dev/null +++ b/scripts/build.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python3 +""" +Markdown to HTML converter for Puercito Fiction site. +Converts markdown files from content/ directory to HTML files in site/ directory. +""" + +import os +from pathlib import Path +import markdown + + +# HTML template for generated pages +HTML_TEMPLATE = """ + + + + + {title} - Puercito Fiction + + + + + + + +
+ ← Back to Home +
+ {content} +
+
+ + +""" + +# Page background colors +PAGE_COLORS = { + 'comics': '#ffffff', + 'about': '#f5e6d3', + 'projects': '#e8dfd0', + 'links': '#d9e8d8', + 'contact': '#e8d8d8', + 'now': '#d8e3e8', + 'uses': '#e8e0d8', +} + + +def convert_markdown_to_html(markdown_file: Path, output_dir: Path): + """ + Convert a single markdown file to HTML. + + Args: + markdown_file: Path to the markdown file + output_dir: Directory to save the HTML file + """ + # Read markdown content + with open(markdown_file, 'r', encoding='utf-8') as f: + md_content = f.read() + + # Convert markdown to HTML + md = markdown.Markdown(extensions=['extra', 'codehilite', 'meta']) + html_content = md.convert(md_content) + + # Extract title from filename or first heading + title = markdown_file.stem.capitalize() + + # Get background color for this page (default to white if not specified) + page_name = markdown_file.stem + bg_color = PAGE_COLORS.get(page_name, '#ffffff') + + # Fill template + full_html = HTML_TEMPLATE.format( + title=title, + content=html_content, + bg_color=bg_color + ) + + # Output file path + output_file = output_dir / f"{markdown_file.stem}.html" + + # Write HTML file + with open(output_file, 'w', encoding='utf-8') as f: + f.write(full_html) + + print(f"✓ Converted {markdown_file.name} → {output_file.name}") + + +def main(): + """Main build script.""" + # Define directories + content_dir = Path('content') + site_dir = Path('site') + + # Ensure directories exist + if not content_dir.exists(): + print(f"Error: {content_dir} directory not found") + return + + if not site_dir.exists(): + print(f"Creating {site_dir} directory...") + site_dir.mkdir(parents=True) + + # Find all markdown files + md_files = list(content_dir.glob('*.md')) + + if not md_files: + print(f"No markdown files found in {content_dir}") + return + + print(f"Found {len(md_files)} markdown file(s)") + print("-" * 50) + + # Convert each markdown file + for md_file in md_files: + convert_markdown_to_html(md_file, site_dir) + + print("-" * 50) + print(f"Build complete! HTML files saved to {site_dir}/") + + +if __name__ == '__main__': + main() diff --git a/site/index.html b/site/index.html index f2e76bf..b1a3fb1 100644 --- a/site/index.html +++ b/site/index.html @@ -16,14 +16,14 @@
diff --git a/site/styles.css b/site/styles.css index 6562de4..88222bb 100644 --- a/site/styles.css +++ b/site/styles.css @@ -9,30 +9,6 @@ body { line-height: 1.6; color: #191919; background-color: #e8e4d8; - background-image: - /* Halftone dot pattern for newsprint effect */ - radial-gradient(circle at 25% 25%, rgba(0,0,0,0.03) 1px, transparent 1px), - radial-gradient(circle at 75% 75%, rgba(0,0,0,0.03) 1px, transparent 1px), - /* Subtle noise texture */ - url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"), - /* Subtle weathered stains */ - radial-gradient(ellipse at 20% 30%, rgba(139,119,101,0.08) 0%, transparent 50%), - radial-gradient(ellipse at 80% 70%, rgba(139,119,101,0.06) 0%, transparent 50%), - radial-gradient(ellipse at 50% 90%, rgba(139,119,101,0.05) 0%, transparent 40%); - background-size: - 4px 4px, - 4px 4px, - 400px 400px, - 60% 60%, - 50% 50%, - 70% 70%; - background-position: - 0 0, - 2px 2px, - 0 0, - 20% 30%, - 80% 70%, - 50% 90%; min-height: 100vh; display: flex; align-items: center;