Files
kennethreitz.org/tuftecms/core/content.py
T
kennethreitz 2ee4b57d77 Clean up dependencies and move docs to root directory
- Reduced dependencies from 13 to 5 packages (66% reduction)
- Removed unused packages: pydantic, fastapi, uvicorn, pygments, boto3, pillow, background, markdown
- Kept essential packages: flask, gunicorn, gevent, mistune, pyyaml
- Moved docs/ from data/docs/ to root directory for better organization
- Updated all internal documentation links to reflect new location

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-27 04:54:57 -04:00

37 lines
1.0 KiB
Python

"""Content processing core functionality."""
import random
from pathlib import Path
class ContentProcessor:
"""Process and manage content operations."""
def __init__(self, data_dir="data"):
"""Initialize content processor."""
self.data_dir = Path(data_dir)
def get_random_post(self):
"""Get a random post from essays."""
essays_dir = self.data_dir / "essays"
if not essays_dir.exists():
return None
md_files = list(essays_dir.glob("*.md"))
if md_files:
return random.choice(md_files)
return None
def get_random_from_collection(self, collection):
"""Get a random post from a specific collection."""
collection_dir = self.data_dir / collection
if not collection_dir.exists():
return None
md_files = list(collection_dir.glob("**/*.md"))
md_files = [f for f in md_files if f.name != "index.md"]
if md_files:
return random.choice(md_files)
return None