Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,58 +60,42 @@ selected_template = templates[presentation_type]
|
|
| 60 |
|
| 61 |
# Title slide configuration
|
| 62 |
st.sidebar.header("Title Slide")
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
'date': st.sidebar.text_input("Date", "Presentation Date")
|
| 70 |
-
}
|
| 71 |
-
else:
|
| 72 |
-
# Add more presets as needed
|
| 73 |
-
if title_slide_preset == "Preset 1":
|
| 74 |
-
title_slide_info = {
|
| 75 |
-
'title': "Preset Title 1",
|
| 76 |
-
'subtitle': "Preset Subtitle 1",
|
| 77 |
-
'institution': "Preset Institution 1",
|
| 78 |
-
'date': "Preset Date 1"
|
| 79 |
-
}
|
| 80 |
-
elif title_slide_preset == "Preset 2":
|
| 81 |
-
title_slide_info = {
|
| 82 |
-
'title': "Preset Title 2",
|
| 83 |
-
'subtitle': "Preset Subtitle 2",
|
| 84 |
-
'institution': "Preset Institution 2",
|
| 85 |
-
'date': "Preset Date 2"
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
# Main page for sections and subsections configuration
|
| 89 |
-
st.title('Customize Your Presentation')
|
| 90 |
-
sections = OrderedDict()
|
| 91 |
|
| 92 |
-
#
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
for
|
| 97 |
-
bullets = st.text_area(f"Subsection: {content_title} (Enter bullet points separated by newlines)", height=150).split('\n')
|
| 98 |
-
subsections[content_title] = bullets
|
| 99 |
-
sections[section['title']] = {'title': section['title'], 'subsections': subsections}
|
| 100 |
|
| 101 |
-
# Option to add more sections
|
| 102 |
if st.sidebar.button("Add More Section"):
|
| 103 |
new_section_title = st.sidebar.text_input("New Section Title", "New Section")
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
# Generate and download presentation
|
| 113 |
if st.button('Generate Presentation'):
|
| 114 |
-
file_path = create_presentation(title_slide_info, sections)
|
| 115 |
with open(file_path, "rb") as file:
|
| 116 |
st.download_button(
|
| 117 |
label="Download Presentation",
|
|
|
|
| 60 |
|
| 61 |
# Title slide configuration
|
| 62 |
st.sidebar.header("Title Slide")
|
| 63 |
+
title_slide_info = {
|
| 64 |
+
'title': st.sidebar.text_input("Title", "Your Presentation Title"),
|
| 65 |
+
'subtitle': st.sidebar.text_input("Subtitle", "Your Name"),
|
| 66 |
+
'institution': st.sidebar.text_input("Institution", "Your Institution"),
|
| 67 |
+
'date': st.sidebar.text_input("Date", "Presentation Date")
|
| 68 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
# Maintain session state for dynamically added sections
|
| 71 |
+
if 'sections' not in st.session_state:
|
| 72 |
+
st.session_state.sections = OrderedDict()
|
| 73 |
+
for section in selected_template:
|
| 74 |
+
st.session_state.sections[section['title']] = OrderedDict((content, []) for content in section['content'])
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
# Option to add more sections dynamically
|
| 77 |
if st.sidebar.button("Add More Section"):
|
| 78 |
new_section_title = st.sidebar.text_input("New Section Title", "New Section")
|
| 79 |
+
if new_section_title and new_section_title not in st.session_state.sections:
|
| 80 |
+
st.session_state.sections[new_section_title] = OrderedDict()
|
| 81 |
+
st.session_state.sections[new_section_title]["New Subsection"] = []
|
| 82 |
+
|
| 83 |
+
# Main page for sections and subsections configuration
|
| 84 |
+
st.title('Customize Your Presentation')
|
| 85 |
+
|
| 86 |
+
for section_title, subsections in st.session_state.sections.items():
|
| 87 |
+
with st.expander(f"Section: {section_title}"):
|
| 88 |
+
for subsection_title, bullet_points in subsections.items():
|
| 89 |
+
bullets = st.text_area(f"Subsection: {subsection_title} (Enter bullet points separated by newlines)", value="\n".join(bullet_points), height=150).split('\n')
|
| 90 |
+
st.session_state.sections[section_title][subsection_title] = bullets
|
| 91 |
+
if st.button(f"Add Subsection to {section_title}"):
|
| 92 |
+
new_subsection_title = st.text_input(f"New Subsection Title for {section_title}", "New Subsection")
|
| 93 |
+
if new_subsection_title and new_subsection_title not in st.session_state.sections[section_title]:
|
| 94 |
+
st.session_state.sections[section_title][new_subsection_title] = []
|
| 95 |
|
| 96 |
# Generate and download presentation
|
| 97 |
if st.button('Generate Presentation'):
|
| 98 |
+
file_path = create_presentation(title_slide_info, st.session_state.sections)
|
| 99 |
with open(file_path, "rb") as file:
|
| 100 |
st.download_button(
|
| 101 |
label="Download Presentation",
|