ajout de formatage et de valeurs par défaut pour chacun des formats
This commit is contained in:
parent
f628bf9c95
commit
0d48c70ad6
2 changed files with 43 additions and 11 deletions
51
main.py
51
main.py
|
@ -3,6 +3,8 @@ import datetime
|
|||
import streamlit as st
|
||||
import requests
|
||||
from pydantic import BaseModel
|
||||
import mdformat
|
||||
import os
|
||||
|
||||
|
||||
class DocumentSpecs(BaseModel):
|
||||
|
@ -20,7 +22,8 @@ class DocumentSpecs(BaseModel):
|
|||
extension: str
|
||||
|
||||
|
||||
import os
|
||||
if 'options' not in st.session_state:
|
||||
st.session_state['options'] = ""
|
||||
|
||||
st.title("Fabrique à documents")
|
||||
|
||||
|
@ -29,7 +32,15 @@ fabriquedoc_endpoint = os.environ.get("FABRIQUEDOC_ENDPOINT", "http://0.0.0.0:80
|
|||
tab1, tab2, tab3 = st.tabs(["Markdown", "Aperçu", "Paramètres"])
|
||||
|
||||
with tab1:
|
||||
content = st.text_area("Enter Markdown text to send:", "# Titre\n## sous-titre\nContenu\n> Citation\n", height=450)
|
||||
def button1_callback():
|
||||
st.session_state['markdown'] = mdformat.text(st.session_state['markdown'],
|
||||
options={"number": True})
|
||||
|
||||
|
||||
content = st.text_area("Enter Markdown text to send:", "# Titre\n## sous-titre\nContenu\n> Citation\n",
|
||||
height=450,
|
||||
key='markdown')
|
||||
st.button("Formater le texte", on_click=button1_callback)
|
||||
|
||||
with tab2:
|
||||
st.write("Aperçu")
|
||||
|
@ -45,15 +56,35 @@ with tab3:
|
|||
response_formats = requests.get(f"{fabriquedoc_endpoint}/formats/{selected_style}/")
|
||||
formats = response_formats.json()["formats"]
|
||||
selected_format = st.selectbox("Select a format:", formats)
|
||||
|
||||
# Autres paramètres
|
||||
linkcolor = st.text_input("Link color:", value="blue")
|
||||
tocdepth = st.number_input("Table of Contents depth:", value=2, min_value=1, max_value=5, step=1)
|
||||
pdfengine = st.text_input("PDF engine:", value="lualatex")
|
||||
fontsize = st.number_input("Font size:", value=14, step=1)
|
||||
paperwidth = st.number_input("Paper width:", value=1080, step=30)
|
||||
paperheight = st.number_input("Paper height:", value=1080, step=30)
|
||||
margin = st.number_input("Margin:", value=180, step=10)
|
||||
vmargin = st.number_input("Vertical margin:", value=180, step=10)
|
||||
response_format_parameters = requests.get(f"{fabriquedoc_endpoint}/format_parameters/{selected_style}/{selected_format}")
|
||||
format_parameters = response_format_parameters.json()
|
||||
st.write(format_parameters)
|
||||
linkcolor = st.text_input("Link color:",
|
||||
value=format_parameters.get("linkcolor"))
|
||||
tocdepth = st.number_input("Table of Contents depth:",
|
||||
value=int(format_parameters.get("tocdepth")),
|
||||
min_value=1,
|
||||
max_value=5,
|
||||
step=1)
|
||||
pdfengine = st.text_input("PDF engine:",
|
||||
value=format_parameters.get("pdfengine"))
|
||||
fontsize = st.number_input("Font size:",
|
||||
value=int(format_parameters.get("fontsize")),
|
||||
step=1)
|
||||
paperwidth = st.number_input("Paper width:",
|
||||
value=int(format_parameters.get("paperwidth")),
|
||||
step=30)
|
||||
paperheight = st.number_input("Paper height:",
|
||||
value=int(format_parameters.get("paperheight")),
|
||||
step=30)
|
||||
margin = st.number_input("Margin:",
|
||||
value=int(format_parameters.get("margin")),
|
||||
step=10)
|
||||
vmargin = st.number_input("Vertical margin:",
|
||||
value=int(format_parameters.get("vmargin")),
|
||||
step=10)
|
||||
extension = st.selectbox("Extension:", ["png", "jpg", "pdf"])
|
||||
# Envoi
|
||||
if st.button("Generate post"):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
streamlit~=1.16.0
|
||||
requests~=2.28.1
|
||||
pydantic~=1.10.2
|
||||
pydantic~=1.10.2
|
||||
mdformat~=0.7.16
|
Reference in a new issue