feat: Add relative timestamps and permalinks to comments
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -14,6 +14,8 @@ import json
|
||||
import threading
|
||||
import traceback
|
||||
import time
|
||||
import datetime
|
||||
import humanize
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
import settings
|
||||
@@ -39,6 +41,11 @@ def new_id():
|
||||
nid = gen_rand_id()
|
||||
return nid
|
||||
|
||||
|
||||
def fromnow(ts):
|
||||
return humanize.naturaltime(datetime.datetime.fromtimestamp(ts))
|
||||
|
||||
|
||||
build_folder = './build'
|
||||
|
||||
css_file = None
|
||||
@@ -52,6 +59,7 @@ except FileNotFoundError:
|
||||
logging.warning('CSS file not found. Run webclient build.')
|
||||
|
||||
flask_app = Flask(__name__, template_folder=build_folder, static_folder=build_folder, static_url_path='')
|
||||
flask_app.jinja_env.filters['fromnow'] = fromnow
|
||||
cors = CORS(flask_app)
|
||||
|
||||
@flask_app.route('/api')
|
||||
|
||||
Reference in New Issue
Block a user