forked from retoor/devplacepy
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
141921d7a3 |
File diff suppressed because one or more lines are too long
@@ -42,6 +42,7 @@ def init_db():
|
||||
_index(db, "posts", "idx_posts_created_at", ["created_at"])
|
||||
_index(db, "posts", "idx_posts_topic", ["topic"])
|
||||
_index(db, "posts", "idx_posts_slug", ["slug"])
|
||||
_index(db, "posts", "idx_posts_project_uid", ["project_uid"])
|
||||
if "posts" in tables:
|
||||
posts_table = get_table("posts")
|
||||
if not posts_table.has_column("tags"):
|
||||
|
||||
@@ -44,7 +44,6 @@ from devplacepy.templating import templates, jinja_unread_count
|
||||
from devplacepy.cache import TTLCache
|
||||
from devplacepy.responses import respond, wants_json, json_error
|
||||
from devplacepy.schemas import LandingOut, ValidationErrorOut
|
||||
from devplacepy.attachments import get_attachments_batch
|
||||
from fastapi.responses import JSONResponse
|
||||
from devplacepy.utils import get_current_user, time_ago, safe_next, client_ip
|
||||
from devplacepy.seo import base_seo_context, site_url, website_schema
|
||||
@@ -672,7 +671,6 @@ def _landing_recent_posts(blocked):
|
||||
authors = get_users_by_uids(author_uids)
|
||||
comment_counts = get_comment_counts_by_post_uids(post_uids)
|
||||
upvotes, downvotes = get_vote_counts(post_uids)
|
||||
attachments_map = get_attachments_batch("post", post_uids)
|
||||
for p in raw_posts:
|
||||
posts.append(
|
||||
{
|
||||
@@ -682,7 +680,6 @@ def _landing_recent_posts(blocked):
|
||||
"comment_count": comment_counts.get(p["uid"], 0),
|
||||
"stars": upvotes.get(p["uid"], 0) - downvotes.get(p["uid"], 0),
|
||||
"slug": p.get("slug", "") or p["uid"],
|
||||
"attachments": attachments_map.get(p["uid"], []),
|
||||
}
|
||||
)
|
||||
if not blocked:
|
||||
|
||||
@@ -7,6 +7,7 @@ from devplacepy.models import ProfileForm
|
||||
from fastapi.responses import HTMLResponse, JSONResponse
|
||||
from devplacepy.database import (
|
||||
get_table,
|
||||
db,
|
||||
get_customization_prefs,
|
||||
get_notification_prefs,
|
||||
get_user_stars,
|
||||
@@ -47,7 +48,6 @@ from devplacepy.utils import (
|
||||
)
|
||||
from devplacepy.responses import respond, action_result, wants_json
|
||||
from devplacepy.schemas import ProfileOut
|
||||
from devplacepy.attachments import get_attachments_batch
|
||||
from devplacepy.avatar import avatar_url, avatar_seed
|
||||
from devplacepy.seo import (
|
||||
base_seo_context,
|
||||
@@ -188,10 +188,8 @@ async def profile_page(
|
||||
else set()
|
||||
)
|
||||
polls_map = get_polls_by_post_uids(post_uids, current_user)
|
||||
attachments_map = get_attachments_batch("post", post_uids)
|
||||
for item in posts:
|
||||
uid = item["post"]["uid"]
|
||||
item["attachments"] = attachments_map.get(uid, [])
|
||||
item["reactions"] = reactions_map.get(uid, {"counts": {}, "mine": []})
|
||||
item["bookmarked"] = uid in bookmark_set
|
||||
item["poll"] = polls_map.get(uid)
|
||||
|
||||
@@ -216,6 +216,15 @@ async def project_detail(request: Request, project_slug: str):
|
||||
if parent
|
||||
else None
|
||||
)
|
||||
posts_table = get_table("posts")
|
||||
project_posts = list(
|
||||
posts_table.find(
|
||||
project_uid=project["uid"],
|
||||
deleted_at=None,
|
||||
order_by=["-created_at"],
|
||||
)
|
||||
)
|
||||
|
||||
return respond(
|
||||
request,
|
||||
"project_detail.html",
|
||||
@@ -235,6 +244,7 @@ async def project_detail(request: Request, project_slug: str):
|
||||
"forked_from": forked_from,
|
||||
"fork_count": count_forks(project["uid"]),
|
||||
"file_count": count_files(project["uid"]),
|
||||
"project_posts": project_posts,
|
||||
},
|
||||
),
|
||||
model=ProjectDetailOut,
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from typing import Any, Optional
|
||||
|
||||
from devplacepy.schemas.base import _Out
|
||||
from devplacepy.schemas.content import AttachmentOut, UserOut
|
||||
from devplacepy.schemas.content import UserOut
|
||||
|
||||
|
||||
class AuthPageOut(_Out):
|
||||
@@ -38,7 +38,6 @@ class LandingPostOut(_Out):
|
||||
comment_count: int = 0
|
||||
stars: int = 0
|
||||
slug: str = ""
|
||||
attachments: list[AttachmentOut] = []
|
||||
|
||||
|
||||
class TrendingTopicOut(_Out):
|
||||
|
||||
@@ -163,6 +163,7 @@ class ProjectDetailOut(_Out):
|
||||
forked_from: Optional[dict] = None
|
||||
fork_count: int = 0
|
||||
file_count: int = 0
|
||||
project_posts: list[PostOut] = []
|
||||
|
||||
|
||||
class GistsOut(_Out):
|
||||
|
||||
@@ -313,3 +313,50 @@
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.project-devlog {
|
||||
margin-top: 2rem;
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.devlog-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.devlog-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.5rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.devlog-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.devlog-link {
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.devlog-link:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.devlog-date {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.devlog-empty {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
@@ -170,6 +170,22 @@
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
|
||||
<div class="project-devlog">
|
||||
<h2 class="project-section-label">Devlog</h2>
|
||||
{% if project_posts %}
|
||||
<ul class="devlog-list">
|
||||
{% for post in project_posts %}
|
||||
<li class="devlog-item">
|
||||
<a href="/posts/{{ post['slug'] }}" class="devlog-link">{{ render_title(post['title']) }}</a>
|
||||
<span class="devlog-date">{{ local_dt(post['created_at'], 'date') }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="devlog-empty">No posts yet for this project.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% with target_uid=project['uid'], target_type="project" %}
|
||||
{% include "_comment_section.html" %}
|
||||
{% endwith %}
|
||||
|
||||
Reference in New Issue
Block a user