Ubuntu commited on
Commit ·
780f697
1
Parent(s): 3e912aa
feat: Simplify login page - Remove marketing content, show only logo and form
Browse files- Replace app.py with simplified version (app_simple_login.py)
- Remove carousel, tabs, videos, gallery
- Show only: Logo + Email + Password + Sign In button
- Backup saved as: app_backup_20260712_150929.py
- After login, full interface remains the same
- app_backup_20260712_150929.py +275 -0
app_backup_20260712_150929.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AIdeaText v5 - Simple Login Page
|
| 2 |
+
# app_simple_login.py - Página simplificada con solo logo y login
|
| 3 |
+
|
| 4 |
+
import logging
|
| 5 |
+
import streamlit as st
|
| 6 |
+
import sys
|
| 7 |
+
import os
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
|
| 10 |
+
# Configuración básica
|
| 11 |
+
load_dotenv()
|
| 12 |
+
logging.basicConfig(level=logging.INFO)
|
| 13 |
+
logger = logging.getLogger(__name__)
|
| 14 |
+
|
| 15 |
+
# Configuración de la página
|
| 16 |
+
st.set_page_config(
|
| 17 |
+
page_title="AIdeaText - Login",
|
| 18 |
+
layout="centered",
|
| 19 |
+
initial_sidebar_state="collapsed"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 23 |
+
|
| 24 |
+
# Importaciones locales necesarias
|
| 25 |
+
from session_state import initialize_session_state
|
| 26 |
+
from modules.utils.spacy_utils import load_spacy_models
|
| 27 |
+
from modules.database.database_init import initialize_database_connections
|
| 28 |
+
from modules.database.sql_db import get_user, record_login
|
| 29 |
+
from modules.ui.ui import user_page # Para después del login
|
| 30 |
+
from modules.admin.admin_ui import admin_page # Para administradores
|
| 31 |
+
from translations import get_translations
|
| 32 |
+
|
| 33 |
+
@st.cache_resource(show_spinner=False)
|
| 34 |
+
def initialize_nlp_models():
|
| 35 |
+
logger.info("Cargando modelos de spaCy")
|
| 36 |
+
models = load_spacy_models()
|
| 37 |
+
logger.info("Modelos de spaCy cargados exitosamente")
|
| 38 |
+
return models
|
| 39 |
+
|
| 40 |
+
def authenticate_user(username, password):
|
| 41 |
+
"""Autentica un usuario contra la base de datos"""
|
| 42 |
+
try:
|
| 43 |
+
user = get_user(username)
|
| 44 |
+
if user and user['password'] == password:
|
| 45 |
+
# Registrar login
|
| 46 |
+
record_login(username)
|
| 47 |
+
return True, user.get('role', 'Student')
|
| 48 |
+
return False, None
|
| 49 |
+
except Exception as e:
|
| 50 |
+
logger.error(f"Error en autenticación: {str(e)}")
|
| 51 |
+
return False, None
|
| 52 |
+
|
| 53 |
+
def simple_login_page():
|
| 54 |
+
"""Página simplificada con solo logo y login"""
|
| 55 |
+
|
| 56 |
+
# CSS personalizado para centrado y diseño limpio
|
| 57 |
+
st.markdown("""
|
| 58 |
+
<style>
|
| 59 |
+
/* Ocultar elementos default de Streamlit */
|
| 60 |
+
#MainMenu {visibility: hidden;}
|
| 61 |
+
footer {visibility: hidden;}
|
| 62 |
+
header {visibility: hidden;}
|
| 63 |
+
|
| 64 |
+
/* Contenedor principal */
|
| 65 |
+
.main {
|
| 66 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 67 |
+
min-height: 100vh;
|
| 68 |
+
display: flex;
|
| 69 |
+
align-items: center;
|
| 70 |
+
justify-content: center;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/* Card de login */
|
| 74 |
+
.login-container {
|
| 75 |
+
background: white;
|
| 76 |
+
padding: 40px;
|
| 77 |
+
border-radius: 20px;
|
| 78 |
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
| 79 |
+
max-width: 400px;
|
| 80 |
+
width: 100%;
|
| 81 |
+
margin: 0 auto;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/* Logo centrado */
|
| 85 |
+
.logo-container {
|
| 86 |
+
text-align: center;
|
| 87 |
+
margin-bottom: 30px;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.logo-container img {
|
| 91 |
+
max-width: 200px;
|
| 92 |
+
height: auto;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/* Título */
|
| 96 |
+
.login-title {
|
| 97 |
+
text-align: center;
|
| 98 |
+
color: #1E3A8A;
|
| 99 |
+
font-size: 1.8em;
|
| 100 |
+
font-weight: 700;
|
| 101 |
+
margin-bottom: 30px;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/* Inputs de Streamlit */
|
| 105 |
+
.stTextInput > div > div > input {
|
| 106 |
+
border-radius: 10px;
|
| 107 |
+
border: 2px solid #e5e7eb;
|
| 108 |
+
padding: 12px;
|
| 109 |
+
font-size: 16px;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.stTextInput > div > div > input:focus {
|
| 113 |
+
border-color: #667eea;
|
| 114 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/* Botón de login */
|
| 118 |
+
.stButton > button {
|
| 119 |
+
width: 100%;
|
| 120 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 121 |
+
color: white;
|
| 122 |
+
border: none;
|
| 123 |
+
border-radius: 10px;
|
| 124 |
+
padding: 12px;
|
| 125 |
+
font-size: 16px;
|
| 126 |
+
font-weight: 600;
|
| 127 |
+
cursor: pointer;
|
| 128 |
+
transition: transform 0.2s;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.stButton > button:hover {
|
| 132 |
+
transform: translateY(-2px);
|
| 133 |
+
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/* Footer */
|
| 137 |
+
.footer-text {
|
| 138 |
+
text-align: center;
|
| 139 |
+
margin-top: 20px;
|
| 140 |
+
color: #6b7280;
|
| 141 |
+
font-size: 14px;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.footer-text a {
|
| 145 |
+
color: #667eea;
|
| 146 |
+
text-decoration: none;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.footer-text a:hover {
|
| 150 |
+
text-decoration: underline;
|
| 151 |
+
}
|
| 152 |
+
</style>
|
| 153 |
+
""", unsafe_allow_html=True)
|
| 154 |
+
|
| 155 |
+
# Contenedor de login
|
| 156 |
+
col1, col2, col3 = st.columns([1, 2, 1])
|
| 157 |
+
|
| 158 |
+
with col2:
|
| 159 |
+
# Logo
|
| 160 |
+
st.markdown("""
|
| 161 |
+
<div class="logo-container">
|
| 162 |
+
<img src="https://huggingface.co/spaces/AIdeaText/v5Prod/resolve/main/assets/img/Logo_300x300.png"
|
| 163 |
+
alt="AIdeaText Logo">
|
| 164 |
+
</div>
|
| 165 |
+
""", unsafe_allow_html=True)
|
| 166 |
+
|
| 167 |
+
# Título
|
| 168 |
+
st.markdown('<h1 class="login-title">Welcome to AIdeaText</h1>', unsafe_allow_html=True)
|
| 169 |
+
|
| 170 |
+
# Formulario de login
|
| 171 |
+
with st.form("login_form", clear_on_submit=False):
|
| 172 |
+
username = st.text_input(
|
| 173 |
+
"Email",
|
| 174 |
+
placeholder="your.email@university.edu",
|
| 175 |
+
key="login_email"
|
| 176 |
+
)
|
| 177 |
+
password = st.text_input(
|
| 178 |
+
"Password",
|
| 179 |
+
type="password",
|
| 180 |
+
placeholder="Enter your password",
|
| 181 |
+
key="login_password"
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
st.write("") # Espacio
|
| 185 |
+
submit_button = st.form_submit_button("🔐 Sign In")
|
| 186 |
+
|
| 187 |
+
# Procesar login
|
| 188 |
+
if submit_button:
|
| 189 |
+
if not username or not password:
|
| 190 |
+
st.error("⚠️ Please enter both email and password")
|
| 191 |
+
else:
|
| 192 |
+
with st.spinner("Authenticating..."):
|
| 193 |
+
success, role = authenticate_user(username, password)
|
| 194 |
+
|
| 195 |
+
if success:
|
| 196 |
+
st.session_state.logged_in = True
|
| 197 |
+
st.session_state.username = username
|
| 198 |
+
st.session_state.role = role
|
| 199 |
+
|
| 200 |
+
if role == 'Administrador':
|
| 201 |
+
st.session_state.page = 'Admin'
|
| 202 |
+
else:
|
| 203 |
+
st.session_state.page = 'user'
|
| 204 |
+
|
| 205 |
+
logger.info(f"Usuario autenticado: {username}, Rol: {role}")
|
| 206 |
+
st.success("✅ Login successful!")
|
| 207 |
+
st.rerun()
|
| 208 |
+
else:
|
| 209 |
+
st.error("❌ Invalid email or password")
|
| 210 |
+
|
| 211 |
+
# Footer
|
| 212 |
+
st.markdown("""
|
| 213 |
+
<div class="footer-text">
|
| 214 |
+
Need access? <a href="https://aideatext.ai/#contact" target="_blank">Contact us</a><br>
|
| 215 |
+
<small>© 2026 AIdeaText. All rights reserved.</small>
|
| 216 |
+
</div>
|
| 217 |
+
""", unsafe_allow_html=True)
|
| 218 |
+
|
| 219 |
+
def app_main():
|
| 220 |
+
"""Función principal de la aplicación"""
|
| 221 |
+
try:
|
| 222 |
+
logger.info("Iniciando aplicación AIdeaText")
|
| 223 |
+
|
| 224 |
+
# Inicializar el estado de la sesión
|
| 225 |
+
if 'initialized' not in st.session_state:
|
| 226 |
+
initialize_session_state()
|
| 227 |
+
st.session_state.initialized = True
|
| 228 |
+
|
| 229 |
+
# Inicializar conexiones a bases de datos
|
| 230 |
+
if 'db_initialized' not in st.session_state:
|
| 231 |
+
st.session_state.db_initialized = initialize_database_connections()
|
| 232 |
+
|
| 233 |
+
# Cargar modelos NLP
|
| 234 |
+
if 'nlp_models' not in st.session_state:
|
| 235 |
+
logger.info("Inicializando modelos NLP")
|
| 236 |
+
st.session_state.nlp_models = initialize_nlp_models()
|
| 237 |
+
logger.info("Modelos NLP inicializados")
|
| 238 |
+
|
| 239 |
+
# Configurar página inicial
|
| 240 |
+
if 'page' not in st.session_state:
|
| 241 |
+
st.session_state.page = 'login'
|
| 242 |
+
|
| 243 |
+
logger.info(f"Página actual: {st.session_state.page}")
|
| 244 |
+
logger.info(f"Logged in: {st.session_state.get('logged_in', False)}")
|
| 245 |
+
|
| 246 |
+
# Routing
|
| 247 |
+
if not st.session_state.get('logged_in', False):
|
| 248 |
+
# Mostrar página de login simple
|
| 249 |
+
simple_login_page()
|
| 250 |
+
elif st.session_state.page == 'user':
|
| 251 |
+
# Usuario autenticado - mostrar interfaz completa
|
| 252 |
+
if st.session_state.role == 'Administrador':
|
| 253 |
+
st.session_state.page = 'Admin'
|
| 254 |
+
st.rerun()
|
| 255 |
+
else:
|
| 256 |
+
lang_code = st.session_state.get('lang_code', 'en')
|
| 257 |
+
t = get_translations(lang_code)
|
| 258 |
+
user_page(lang_code, t)
|
| 259 |
+
elif st.session_state.page == 'Admin':
|
| 260 |
+
# Página de administrador
|
| 261 |
+
admin_page()
|
| 262 |
+
else:
|
| 263 |
+
logger.error(f"Página no reconocida: {st.session_state.page}")
|
| 264 |
+
st.session_state.page = 'login'
|
| 265 |
+
st.rerun()
|
| 266 |
+
|
| 267 |
+
except Exception as e:
|
| 268 |
+
logger.error(f"Error en app_main: {str(e)}", exc_info=True)
|
| 269 |
+
st.error("Se ha producido un error. Por favor, inténtelo de nuevo.")
|
| 270 |
+
if st.button("Reiniciar"):
|
| 271 |
+
st.session_state.clear()
|
| 272 |
+
st.rerun()
|
| 273 |
+
|
| 274 |
+
if __name__ == "__main__":
|
| 275 |
+
app_main()
|