import streamlit as st
import os
import random
from generate_jokes import generate_inside_jokes, generate_motivation
from generate_quote_card import create_quote_card
# Page Config
st.set_page_config(
page_title="Memory Forever",
page_icon="💛",
layout="wide"
)
# Custom CSS
st.markdown("""
""", unsafe_allow_html=True)
# Header
st.title("💛 Memory Forever 👩✈️")
st.markdown("---")
# Layout: 2 Columns
col1, col2 = st.columns([1, 2])
with col1:
st.header("📸 Past Gallery")
# Load images from 'sarah' directory
image_dir = "src/sarah"
if os.path.exists(image_dir):
images = [f for f in os.listdir(image_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))]
if images:
# Display a random image or a grid
selected_image = random.choice(images)
st.image(os.path.join(image_dir, selected_image), caption="Classic Sarah Moment", use_container_width=True)
# Optional: Show more images in an expander
with st.expander("See more photos"):
for img in images:
st.image(os.path.join(image_dir, img), use_container_width=True)
else:
st.info("No images found in 'sarah' folder. Add some photos to see them here!")
else:
st.warning("Folder 'sarah' not found. Please create it and add images.")
st.markdown("---")
st.subheader("⚙️ Settings")
count = st.slider("How many jokes?", 1, 10, 3)
st.markdown("---")
st.subheader("💪 Daily Boost")
if st.button("Need a quick motivation ✨"):
with st.spinner("Finding the right words..."):
motivation = generate_motivation()
st.markdown(f'
{motivation}
', unsafe_allow_html=True)
# Download button for motivation
card_buffer = create_quote_card(motivation, card_type="motivation", title="Daily Motivation")
st.download_button(
label="📥 Download Card",
data=card_buffer,
file_name="motivation_card.png",
mime="image/png",
key="download_motivation"
)
with col2:
st.header("✨ Memory jokes fusion")
if st.button("Generate 🎲"):
with st.spinner("Cooking up some humor..."):
try:
jokes_text = generate_inside_jokes(count)
# Parse the output to separate jokes and memory
if "MEMORY FOR SARAH:" in jokes_text:
parts = jokes_text.split("MEMORY FOR SARAH:")
jokes_section = parts[0].replace("INSIDE JOKES:", "").strip()
memory_section = parts[1].strip().strip('"')
else:
jokes_section = jokes_text
memory_section = "Remember that time..."
# Display Jokes
st.markdown("### 🎭 Inside Jokes")
jokes_list = [line.strip() for line in jokes_section.split('\n') if line.strip()]
for idx, joke in enumerate(jokes_list):
col_joke, col_download = st.columns([4, 1])
with col_joke:
st.markdown(f'{joke}
', unsafe_allow_html=True)
with col_download:
card_buffer = create_quote_card(joke, card_type="joke", title="Inside Joke")
st.download_button(
label="📥",
data=card_buffer,
file_name=f"joke_card_{idx+1}.png",
mime="image/png",
key=f"download_joke_{idx}"
)
# Display Memory
st.markdown("### 💌 A Memory to Cherish")
col_mem, col_mem_download = st.columns([4, 1])
with col_mem:
st.markdown(f'"{memory_section}"
', unsafe_allow_html=True)
with col_mem_download:
mem_card_buffer = create_quote_card(memory_section, card_type="memory", title="A Memory")
st.download_button(
label="📥",
data=mem_card_buffer,
file_name="memory_card.png",
mime="image/png",
key="download_memory"
)
except Exception as e:
st.error(f"Oof! Something went wrong: {e}")
# Footer
st.markdown("---")
st.markdown("Made with 💖 by Aman
", unsafe_allow_html=True)