diff --git a/blueprints/now.py b/blueprints/now.py index 3066edb..d6e4208 100644 --- a/blueprints/now.py +++ b/blueprints/now.py @@ -2,7 +2,7 @@ from flask import Blueprint, render_template, make_response, request, jsonify import datetime import os from tools import getHandshakeScript, error_response, isCLI -from curl import get_header +from curl import get_header, MAX_WIDTH from bs4 import BeautifulSoup import re @@ -96,6 +96,21 @@ def render_curl(date=None): # Extract any links in the paragraph links = [a.get("href") for a in p.find_all("a", href=True)] # type: ignore + # Set max width for text wrapping + + # Wrap text manually + wrapped_lines = [] + for line in text.splitlines(): + while len(line) > MAX_WIDTH: + # Find last space within max_width + split_at = line.rfind(' ', 0, MAX_WIDTH) + if split_at == -1: + split_at = MAX_WIDTH + wrapped_lines.append(line[:split_at].rstrip()) + line = line[split_at:].lstrip() + wrapped_lines.append(line) + text = "\n".join(wrapped_lines) + if links: text += "\nLinks: " + ", ".join(links) # type: ignore diff --git a/curl.py b/curl.py index f8d767e..e1ec9b6 100644 --- a/curl.py +++ b/curl.py @@ -6,6 +6,8 @@ import requests from blueprints.spotify import get_spotify_track +MAX_WIDTH = 80 + def clean_path(path:str): path = path.strip("/ ").lower() # Strip any .html extension diff --git a/templates/header.ascii b/templates/header.ascii index e349bed..e7f21ab 100644 --- a/templates/header.ascii +++ b/templates/header.ascii @@ -9,4 +9,5 @@ Contact [/contact] Projects [/projects] Tools [/tools] Donate [/donate] +Now [/now] diff --git a/templates/index.ascii b/templates/index.ascii index 902e608..51afe40 100644 --- a/templates/index.ascii +++ b/templates/index.ascii @@ -9,6 +9,7 @@ Contact [/contact] Projects [/projects] Tools [/tools] Donate [/donate] +Now [/now] API [/api/v1] ───────────────────────────────────────────────