Spaces:
Runtime error
Runtime error
Commit Β·
53c5d8a
1
Parent(s): ef22508
Render SVG Logo
Browse filesFiles changed (5)
123445from .authors import authorsfrom .logout import logoutfrom .login import loginfrom .user_greetings import user_greetingsfrom .user_greetings import user_greetingsfrom .logo import add_logo1 unmodified line234556747 unmodified lines55565759585960611 unmodified lineimport requests
import streamlit as st
def login():
47 unmodified lines st.error("Signup Failed")
st.divider() st.subheader(":rainbow[Our Prototype in Action π¬]") st.subheader(":rainbow[Our Prototype in Action ]π¬") with st.expander("Demo video π¬",expanded=True): st.video("frontend/images/Showcase.mp4")
1234567789910101112131415161712181920211 unmodified line2324252021222627282930312732333435363738394041424344454647484950515253545556import streamlit as st
import reimport base64import validatorsfrom pathlib import Path
def add_logo(logo_url: str, height: int = 120):def add_logo(logo_url: str, height: int = 100, svg=False):
if validators.url(logo_url) is True: logo = f"url({logo_url})" if svg: svg_logo = read_svg(logo_url) b64 = base64.b64encode(svg_logo.encode("utf-8")).decode("utf-8") logo = f'url("data:image/svg+xml;base64,{b64}")'
elif validators.url(logo_url): logo = f'url({logo_url})' else: logo = f"url(data:image/png;base64,{base64.b64encode(Path(logo_url).read_bytes()).decode()})" logo = f'url("data:image/png;base64,{base64.b64encode(Path(logo_url).read_bytes()).decode()}")'
st.markdown( f"""1 unmodified line [data-testid="stSidebarNav"] {{ background-image: {logo}; background-repeat: no-repeat; background-size: contain; padding-top: {height - 40}px; background-position: 20px 20px background-position: center top; /* Center the logo at the top */ background-size: auto {height}px; /* Set the logo height */ }} </style> """, unsafe_allow_html=True, ) )
def read_svg(path_svg): try: with open(path_svg, "r") as file: svg_logo = file.read().splitlines() _maped_list = map(str, svg_logo) svg_logo = "".join(_maped_list) temp_svg_logo = re.findall("<svg.*</svg>", svg_logo, flags=re.IGNORECASE) svg_logo = temp_svg_logo[0] except: svg_logo = '<svg xmlns="http://www.w3.org/2000/svg" width="150px" height="1px" viewBox="0 0 150 1"></svg>' return svg_logo
def render_svg(svg): b64 = base64.b64encode(svg.encode("utf-8")).decode("utf-8") html = ( r""" <div align="center"> <img src="data:image/svg+xml;base64,%s" alt="Techdocs Logo" style="width: 60em;"/> </div> """ % b64 ) st.markdown(html, unsafe_allow_html=True)4 unmodified lines56789101111121314151616171819204 unmodified lines
@mainlayoutdef instructions():
with open("frontend/content/installation.md", "r",encoding='utf-8') as f: instructions = f.read()
with open("frontend/content/working.md", "r",encoding='utf-8') as f: with open("content/working.md", "r",encoding='utf-8') as f: working = f.read()
st.markdown("### π :rainbow[Using Techdocs via the CLI]") st.info("Please use the CLI to generate the documentation for your project. The Streamlit app is just a demo to give the user an idea of the project.") st.info("Please use the CLI to generate the documentation for your project. The Streamlit app is just a demo to give the user an idea of the project.") with st.expander("βοΈ Installation and setup"): st.markdown(instructions)frontend/components/__init__.py+2-1
frontend/components/login.py+1-2
frontend/components/logo.py+37-8
frontend/images/techdocslogo.svgAdded
frontend/pages/2_π_Instructions.py+3-2