mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Only show public stuff on the homepage
This commit is contained in:
parent
6ab59d2e41
commit
152bcf2b26
3 changed files with 8 additions and 7 deletions
11
app.py
11
app.py
|
@ -86,8 +86,8 @@ from config import VERSION_DATE
|
|||
from config import _drop_db
|
||||
from poussetaches import PousseTaches
|
||||
from tasks import Tasks
|
||||
from utils import parse_datetime
|
||||
from utils import opengraph
|
||||
from utils import parse_datetime
|
||||
from utils.key import get_secret_key
|
||||
from utils.lookup import lookup
|
||||
from utils.media import Kind
|
||||
|
@ -143,13 +143,13 @@ def inject_config():
|
|||
notes_count = DB.activities.find(
|
||||
{"box": Box.OUTBOX.value, "$or": [q, {"type": "Announce", "meta.undo": False}]}
|
||||
).count()
|
||||
# FIXME(tsileo): rename to all_count, and remove poll answers from it
|
||||
with_replies_count = DB.activities.find(
|
||||
{
|
||||
"box": Box.OUTBOX.value,
|
||||
"type": {"$in": [ActivityType.CREATE.value, ActivityType.ANNOUNCE.value]},
|
||||
"meta.undo": False,
|
||||
"meta.deleted": False,
|
||||
"meta.public": True,
|
||||
}
|
||||
).count()
|
||||
liked_count = DB.activities.count(
|
||||
|
@ -875,6 +875,7 @@ def index():
|
|||
"activity.object.inReplyTo": None,
|
||||
"meta.deleted": False,
|
||||
"meta.undo": False,
|
||||
"meta.public": True,
|
||||
"$or": [{"meta.pinned": False}, {"meta.pinned": {"$exists": False}}],
|
||||
}
|
||||
print(list(DB.activities.find(q)))
|
||||
|
@ -887,6 +888,7 @@ def index():
|
|||
"type": ActivityType.CREATE.value,
|
||||
"meta.deleted": False,
|
||||
"meta.undo": False,
|
||||
"meta.public": True,
|
||||
"meta.pinned": True,
|
||||
}
|
||||
pinned = list(DB.activities.find(q_pinned))
|
||||
|
@ -906,14 +908,13 @@ def index():
|
|||
return resp
|
||||
|
||||
|
||||
@app.route("/with_replies")
|
||||
@app.route("/all")
|
||||
@login_required
|
||||
def with_replies():
|
||||
def all():
|
||||
q = {
|
||||
"box": Box.OUTBOX.value,
|
||||
"type": {"$in": [ActivityType.CREATE.value, ActivityType.ANNOUNCE.value]},
|
||||
"meta.deleted": False,
|
||||
"meta.public": True,
|
||||
"meta.undo": False,
|
||||
}
|
||||
outbox_data, older_than, newer_than = paginated_query(DB.activities, q)
|
||||
|
|
2
tasks.py
2
tasks.py
|
@ -2,8 +2,8 @@ import os
|
|||
from datetime import datetime
|
||||
from datetime import timezone
|
||||
|
||||
from utils import parse_datetime
|
||||
from poussetaches import PousseTaches
|
||||
from utils import parse_datetime
|
||||
|
||||
p = PousseTaches(
|
||||
os.getenv("MICROBLOGPUB_POUSSETACHES_HOST", "http://localhost:7991"),
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="menu">
|
||||
<ul>
|
||||
<li><a href="/" {% if request.path == "/" %}class="selected"{% endif %}>Notes <small class="badge">{{ notes_count }}</small></a></li>
|
||||
{% if session.logged_in %}<li><a href="/with_replies" {% if request.path == "/with_replies" %}class="selected"{% endif %}>With replies <small class="badge">{{ with_replies_count }}</small></a></li>
|
||||
{% if session.logged_in %}<li><a href="/all" {% if request.path == url_for("all") %}class="selected"{% endif %}>All <small class="badge">{{ with_replies_count }}</small></a></li>
|
||||
{% endif %}
|
||||
<li><a href="/liked" {% if request.path == "/liked" %}class="selected"{% endif %}>Liked <small class="badge">{{ liked_count }}</small></a></li>
|
||||
<li><a href="/followers"{% if request.path == "/followers" %} class="selected" {% endif %}>Followers <small class="badge">{{ followers_count }}</small></a></li>
|
||||
|
|
Loading…
Reference in a new issue