mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 11:14:28 +00:00
Add debug mode to help debug thread issues
This commit is contained in:
parent
d5ee0e3fa5
commit
6d8097d112
2 changed files with 35 additions and 2 deletions
14
app.py
14
app.py
|
@ -232,8 +232,13 @@ def _get_file_url(url, size, kind):
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
def remove_mongo_id(dat):
|
def remove_mongo_id(dat):
|
||||||
|
if isinstance(dat, list):
|
||||||
|
return [remove_mongo_id(item) for item in dat]
|
||||||
if "_id" in dat:
|
if "_id" in dat:
|
||||||
dat["_id"] = str(dat["_id"])
|
dat["_id"] = str(dat["_id"])
|
||||||
|
for k, v in dat.items():
|
||||||
|
if isinstance(v, dict):
|
||||||
|
dat[k] = remove_mongo_id(dat[k])
|
||||||
return dat
|
return dat
|
||||||
|
|
||||||
|
|
||||||
|
@ -1329,7 +1334,10 @@ def admin_thread():
|
||||||
abort(410)
|
abort(410)
|
||||||
thread = _build_thread(data)
|
thread = _build_thread(data)
|
||||||
|
|
||||||
return render_template("note.html", thread=thread, note=data)
|
tpl = "note.html"
|
||||||
|
if request.args.get("debug"):
|
||||||
|
tpl = "note_debug.html"
|
||||||
|
return render_template(tpl, thread=thread, note=data)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/admin/new", methods=["GET"])
|
@app.route("/admin/new", methods=["GET"])
|
||||||
|
@ -1539,7 +1547,9 @@ def admin_stream():
|
||||||
if request.args.get("debug_inbox"):
|
if request.args.get("debug_inbox"):
|
||||||
q = {}
|
q = {}
|
||||||
|
|
||||||
inbox_data, older_than, newer_than = paginated_query(DB.activities, q, limit=int(request.args.get('limit', 25)))
|
inbox_data, older_than, newer_than = paginated_query(
|
||||||
|
DB.activities, q, limit=int(request.args.get("limit", 25))
|
||||||
|
)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
tpl, inbox_data=inbox_data, older_than=older_than, newer_than=newer_than
|
tpl, inbox_data=inbox_data, older_than=older_than, newer_than=newer_than
|
||||||
|
|
23
templates/note_debug.html
Normal file
23
templates/note_debug.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% import 'utils.html' as utils %}
|
||||||
|
{% block title %}{{ config.NAME }}: "{{ note.activity.object.content | html2plaintext | truncate(50) }}"{% endblock %}
|
||||||
|
{% block header %}
|
||||||
|
<meta content="article" property="og:type" />
|
||||||
|
<meta content="{{ note.activity.object.url }}" property="og:url" />
|
||||||
|
|
||||||
|
<meta content="{{ config.USERNAME }}" property="og:site_name" />
|
||||||
|
<meta content="{{ config.USERNAME }}" property="og:title" />
|
||||||
|
<meta content="{{ note.activity.object.content | html2plaintext | truncate(50) }}" property="og:description" />
|
||||||
|
<meta content="{{ me.icon.url }}" property="og:image" />
|
||||||
|
<meta content="200" property="og:image:width" />
|
||||||
|
<meta content="200" property="og:image:height" />
|
||||||
|
<meta content="summary" property="twitter:card" />
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div id="container">
|
||||||
|
{% include "header.html" %}
|
||||||
|
<pre><code>{{ thread | remove_mongo_id | tojson(indent=4) }}</code></pre>
|
||||||
|
{{ utils.display_thread(thread, likes=likes, shares=shares) }}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
{% block links %}<link rel="alternate" href="{{ note.activity.object.id}}" type="application/activity+json">{% endblock %}
|
Loading…
Reference in a new issue