diff --git a/main.py b/main.py index fde02f4..30e51be 100644 --- a/main.py +++ b/main.py @@ -218,10 +218,11 @@ def blog(): @app.route('/blog/') +# @cache.cached(timeout=43200) def blog_post(post_id): - q_visited = "INSERT INTO posts_visited (id_post, viewed ) VALUES ( %s, %s);" - t_visited = (post_id, cur_date()) - dbUsers.update_data(q_visited, t_visited) + # q_visited = "INSERT INTO posts_visited (id_post, viewed ) VALUES ( %s, %s);" + # t_visited = (post_id, cur_date()) + # dbUsers.update_data(q_visited, t_visited) # Obtener el post q = fr""" SELECT @@ -247,6 +248,9 @@ def blog_post(post_id): return render_template(v['blog']['post'], data=data) + + + @app.route("/contact", methods=['GET', 'POST']) def contact(): form = ContactForm() @@ -524,6 +528,7 @@ def download_db(): @app.route('/user/txt-editor') @jwt_required() @validate_user_exists +@cache.cached(timeout=43200) def user_txteditor(): template_name = v['tmp_user'].get('txt_editor') return render_template(template_name, active_page='user_txteditor') @@ -537,6 +542,9 @@ def save_post(): data = request.get_json() title = data['title'] body = data['body'] + time = cur_date() + + print(time) soup = BeautifulSoup(body, 'html.parser') body_no_img = soup.get_text(separator=' ', strip=True) @@ -547,10 +555,10 @@ def save_post(): t = None if "id" in data: q = 'UPDATE posts SET updated_at = %s, title = %s, body = %s, body_no_img = %s, lista_imagenes = %s::jsonb WHERE id = %s AND id_usr = %s;' - t = (cur_date(), title, body, body_no_img, imagenes_json, data['id'], id_usr) + t = (time, title, body, body_no_img, imagenes_json, data['id'], id_usr) else: q = "INSERT INTO posts (id_usr, created_at, title, body, body_no_img, lista_imagenes) VALUES (%s, %s, %s, %s, %s, %s::jsonb);" - t = (id_usr, cur_date(), title, body, body_no_img, imagenes_json) + t = (id_usr, time, title, body, body_no_img, imagenes_json) try: dbUsers.update_data(q, t) @@ -583,7 +591,7 @@ def my_posts(): title, LEFT(body_no_img, 180), lista_imagenes->0, - array_length(regexp_split_to_array(TRIM(body_no_img), '\s+'), 1) / 375 as n_words + GREATEST(array_length(regexp_split_to_array(TRIM(body_no_img), '\s+'), 1) / 375, 1) as n_words FROM posts WHERE @@ -689,6 +697,11 @@ def metrics(): @validate_user_exists @admin_required def data_metrics(): + # SELECT pv.id_post, pv.viewed, u.id, u.nombre, u.apellido + # FROM posts_visited pv + # INNER JOIN posts p ON p.id = pv.id_post + # INNER JOIN users u ON u.id = p.id_usr; + q_contact = r""" SELECT CASE EXTRACT(MONTH FROM full_date_time AT TIME ZONE 'America/Mexico_City') diff --git a/static/e_blog/copy_url.js b/static/e_blog/copy_url.js new file mode 100644 index 0000000..46acd7b --- /dev/null +++ b/static/e_blog/copy_url.js @@ -0,0 +1,50 @@ +import { simpleNotification } from '../z_comps/notify.js'; + +const url = window.location.href; +const url_encoded = encodeURIComponent(url); + +// Función reutilizable para abrir ventanas de compartir +function openShareWindow(shareUrl) { + window.open(shareUrl, '_blank', 'width=600,height=400,noopener,noreferrer'); +} + +// Copiar al portapapeles +const btn_copy = document.querySelector("button.copy"); +if (btn_copy) { + btn_copy.addEventListener("click", async () => { + try { + await navigator.clipboard.writeText(url); + simpleNotification("URL Copiada", "URL copiada", "success"); + } catch (err) { + console.error('Error al copiar: ', err); + } + }); +} + +// LinkedIn +const btn_in = document.querySelector("button.in"); +if (btn_in) { + btn_in.addEventListener("click", () => { + const linkedInUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${url_encoded}`; + openShareWindow(linkedInUrl); + }); +} + +// Facebook +const btn_fb = document.querySelector("button.fb"); +if (btn_fb) { + btn_fb.addEventListener("click", () => { + const fbShareUrl = `https://www.facebook.com/sharer/sharer.php?u=${url_encoded}`; + openShareWindow(fbShareUrl); + }); +} + +// X / Twitter +const btn_x = document.querySelector("button.tw"); +if (btn_x) { + btn_x.addEventListener("click", () => { + const tweetText = encodeURIComponent("Mira este post interesante:"); + const xShareUrl = `https://twitter.com/intent/tweet?url=${url_encoded}&text=${tweetText}`; + openShareWindow(xShareUrl); + }); +} diff --git a/static/h_tmp_user/d_read_post/read_post.css b/static/h_tmp_user/d_read_post/read_post.css new file mode 100644 index 0000000..2ab4b32 --- /dev/null +++ b/static/h_tmp_user/d_read_post/read_post.css @@ -0,0 +1,103 @@ + +.pst-cont{ + width: 65%; + min-height: 80%; + margin: auto; + +} + +.pst-cont { + margin: 2rem auto; + padding: 2rem; + background-color: #fff; + border-radius: 8px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); + line-height: 1.6; + color: #333; + + & h1 { + font-size: 2.5rem; + margin-bottom: 1rem; + color: #2c3e50; + line-height: 1.2; + font-weight: 700; + border-bottom: 2px solid #f0f0f0; + padding-bottom: 0.5rem; + } + + & span { + display: block; + margin-bottom: 1.5rem; + color: #7f8c8d; + font-size: 0.9rem; + } + + + & span i { + margin-right: 0.3rem; + } + + & img { + max-width: 100%; + height: auto; + border-radius: 4px; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); + } + +} + +.pst-cont > div:first-of-type { + margin-bottom: 2rem; + display: flex; + gap: 1rem; +} + +/* Estilos para el contenido del post */ + +.pst-cont > div:last-of-type { + font-size: 1.1rem; + line-height: 1.8; +} + +.pst-cont p { + text-align: justify; + text-justify: inter-word; + margin-bottom: 1.5rem; +} + +.pst-cont .note-float-left, +.pst-cont .note-float-right { + margin-top: 0.5em; + margin-bottom: 1em; +} + +.pst-cont .note-float-left { + float: left; + margin-right: 1.5em; + max-width: 50%; +} + +.pst-cont .note-float-right { + float: right; + + margin-left: 1.5em; + max-width: 70%; +} + +.pst-cont iframe { + max-width: 100%; + margin-left: auto !important; + margin-right: auto !important; + border-radius: 4px; + margin: 1.5rem 0; + display: block; +} + +.pst-cont::after { + content: ""; + display: table; + clear: both; +} + + + diff --git a/static/h_tmp_user/edit-post.js b/static/h_tmp_user/edit-post.js index 037535c..3529877 100644 --- a/static/h_tmp_user/edit-post.js +++ b/static/h_tmp_user/edit-post.js @@ -72,37 +72,6 @@ document.querySelector('[name="title"]').value = title_post; // ENVIAR LOS NUEVOS CAMBIOS A LA BASE DE DATOS - -// async function a_sendpost(title, body, id) { -// try { -// let response = await fetch('/user/save-post', { -// method: 'POST', -// headers: { -// 'Content-Type': 'application/json' -// }, -// body: JSON.stringify({ "id": id, "title": title, "body": body}), -// credentials: 'include' -// }); - - -// if (!response.ok) { -// throw new Error('Error en la respuesta del servidor <-'); -// } - -// const result = await response.json(); - -// simpleNotification('Éxito', `Publicación actualizada: ${result.title_post}`, 'success'); -// // Opcional: Limpiar el editor después de guardar -// $('#summernote').summernote('code', ''); -// document.querySelector("input[name='title']").value = ''; - -// } catch (error) { -// console.error('Error al guardar:', error); -// simpleNotification('Error', 'No se pudo guardar la publicación', 'error'); -// } -// } - - async function a_sendpost(title, body, id) { try { let response = await fetch('/user/save-post', { diff --git a/static/h_tmp_user/text_editor.css b/static/h_tmp_user/text_editor.css index b0edfdf..facaaad 100644 --- a/static/h_tmp_user/text_editor.css +++ b/static/h_tmp_user/text_editor.css @@ -1,12 +1,12 @@ .form-control{ - width: 100% !important; + width: 50% !important; margin-bottom: 1em !important; margin-top: 1em !important; } .note-editor { - width: 100% !important; - min-height: 65vh !important; + width: 50% !important; + min-height: 70vh !important; } .note-editable { @@ -25,6 +25,7 @@ div.note-toolbar{ div.note-editing-area { background-color: white !important; + } /* aplica en la sección de edición del post */ @@ -39,4 +40,3 @@ div.note-modal-backdrop { } - diff --git a/templates/d_methodology/methodology.html b/templates/d_methodology/methodology.html index b523c05..e82b65e 100644 --- a/templates/d_methodology/methodology.html +++ b/templates/d_methodology/methodology.html @@ -10,12 +10,12 @@ {% block body %} -
+

Nuestra Metodología

Implementamos soluciones con enfoque humano, técnico y estratégico.

-
+
ANÁLISIS DE DATOS
@@ -24,7 +24,7 @@
-
+
PERSONALIZACIÓN
@@ -33,7 +33,7 @@
-
+
EXPERIENCIA DE SERVICIO
@@ -42,7 +42,7 @@
-
+
IMPACTO
@@ -51,7 +51,7 @@
-
+
SOSTENIBILIDAD DEL CAMBIO
diff --git a/templates/e_blog/a_all_posts.html b/templates/e_blog/a_all_posts.html index 2c433c7..7af9435 100644 --- a/templates/e_blog/a_all_posts.html +++ b/templates/e_blog/a_all_posts.html @@ -10,6 +10,8 @@ {% block body %} + +
@@ -19,91 +21,17 @@
-
- - - - -
- {% for post in data %} - -
-
- - - - -
-

- - {{ post[5] }} - -

- - - {{ post[1] }} {{ post[2] }}
- {{ post[8] }} Min. - - -
- -

{{ post[6] }}...

- -
- -
-
- {% endfor %} -
+ + +
+ + + {% for post in data %} +
+
+ + card image + +
+
+ + +
{{post[5]}}

+ + + {{ post[1] }} {{ post[2] }}
+ + {{ post[3] }}
+ + {% if post[4] is not none %} + {{ post[4] }}
+ {% endif %} + + {{ post[8] }} min.
+ +
+ + +

{{ post[6] }}...

+ +
+ +
+
+
+ {% endfor %} + + +
+ + diff --git a/templates/e_blog/b_post.html b/templates/e_blog/b_post.html index 89cc087..0b951c8 100644 --- a/templates/e_blog/b_post.html +++ b/templates/e_blog/b_post.html @@ -1,6 +1,7 @@ {% extends 'template.html' %} {% block css %} + {% endblock css %} {% block navbar %} @@ -9,73 +10,120 @@ {% block body %} + + +
+

{{data[5]}}

+ + + + Publicaciones
+ {{data[0]}} {{data[1]}} | + {{data[2]}} | + {% if data[3] is not none %} + {{data[3]}} | + {% endif %} + {{ data[4] }} Minutos | + +
+ + + +
+ {{data[6] | safe}} +
-
- {{data[6] | safe}}
- - - - - + + {% endblock body %} {% block js %} + + + + +{% include 'z_comps/arrow_to_up.html' %} {% endblock js %} \ No newline at end of file diff --git a/templates/h_tmp_usr/d_read_post.html b/templates/h_tmp_usr/d_read_post.html index 7ce9379..6041627 100644 --- a/templates/h_tmp_usr/d_read_post.html +++ b/templates/h_tmp_usr/d_read_post.html @@ -1,48 +1,13 @@ {% extends 'h_tmp_usr/z_tmp.html' %} {% block css %} - + {% endblock css %} {% block body %} - -

{{data[2]}}

@@ -56,10 +21,14 @@ Editar.
- {{data[3] | safe}} +
+ {{data[3] | safe}} +
+
+ {% endblock body %} {% block js %} @@ -67,15 +36,4 @@ {% include 'z_comps/arrow_to_up.html' %} - - - - {% endblock js %} \ No newline at end of file diff --git a/templates/h_tmp_usr/e_edit_post.html b/templates/h_tmp_usr/e_edit_post.html index e827b35..c69b831 100644 --- a/templates/h_tmp_usr/e_edit_post.html +++ b/templates/h_tmp_usr/e_edit_post.html @@ -5,6 +5,8 @@ + + @@ -22,12 +24,23 @@
Cancelar + + + + + + {% endblock body %} {% block js %} + + + + + {% include 'z_comps/arrow_to_up.html' %}