Bubble [main]

User: Viewing post/comment index by date or subspace

65ab53caf4d78e7f27561664a6879c1cafca2ca0
diff --git a/user.py b/user.py
index 76dc465..bb4ac3c 100644
--- a/user.py
+++ b/user.py
@@ -424,8 +424,8 @@ def make_dashboard_page(session):
             page += sub.subspace_link()
 
     page += '\n## Index\n'
-    page += f'=> /u/{user.name}/index/posts {plural(db.count_posts(user=user, ignore_omit_flags=True), "post")}\n'
-    page += f'=> /u/{user.name}/index/comments {plural(db.count_posts(user=user, is_comment=True), "comment")}\n'
+    page += f'=> /u/{user.name}/index/posts?feed {plural(db.count_posts(user=user, ignore_omit_flags=True), "post")}\n'
+    page += f'=> /u/{user.name}/index/comments?feed {plural(db.count_posts(user=user, is_comment=True), "comment")}\n'
 
     return page
 
@@ -435,26 +435,31 @@ def make_user_index_page(session, mode):
     user = session.c_user
     page = ''
     is_posts = not (mode == 'comments')
+    is_feed = clean_query(session.req) == 'feed'
 
     page += f'# {user.name}: {"Posts" if is_posts else "Comments"}\n'
     page += '=> /dashboard Back to Dashboard\n'
+    page += f'=> ? List by subspace\n' if is_feed else f'=> ?feed List by date\n'
+
 
     if is_posts:
-        posts = db.get_posts(user=user, draft=False, comment=False, sort_by_subspace=True)
+        posts = db.get_posts(user=user, draft=False, comment=False, sort_by_subspace=not is_feed)
         cur_sub = None
         ymd = None
         for post in posts:
-            # Headings.
-            if cur_sub != post.subspace:
-                cur_sub = post.subspace
-                ymd = None
-                page += f"\n## {post.sub_name}\n"
+            if not is_feed:
+                # Headings.
+                if cur_sub != post.subspace:
+                    cur_sub = post.subspace
+                    ymd = None
+                    page += f"\n## {post.sub_name}\n"
             post_ymd = post.ymd_date(tz=session.tz)
             if ymd != post_ymd[:7]:
                 ymd = post_ymd[:7]
                 page += f"\n### {ymd}\n"
 
             # List entry linking to post
+            prefix = f'{"u" if post.sub_owner else "s"}/{post.sub_name}: ' if is_feed else ''
             title = post.title if post.title else shorten_text(strip_links(clean_title(post.summary)), 120)
             if post.issueid:
                 title = f'[#{post.issueid}] ' + title
@@ -466,33 +471,36 @@ def make_user_index_page(session, mode):
                 meta.append(f'👍 {post.num_likes}')
             if post.tags:
                 meta.append(post.tags)
-            entry = f'=> {post.page_url()} {post_ymd} {title}{SEP + SEP.join(meta) if meta else ""}\n'
+            entry = f'=> {post.page_url()} {post_ymd} {prefix}{title}{SEP + SEP.join(meta) if meta else ""}\n'
 
             page += entry
 
     else:
         comments = db.get_posts(user=user, draft=False, comment=True,
-                                sort_by_subspace=True, sort_by_post=True)
+                                sort_by_subspace=not is_feed, sort_by_post=not is_feed)
         cur_parent = None
         cur_sub = None
         for cmt in comments:
-            # Headings.
-            if cur_sub != cmt.subspace:
-                cur_sub = cmt.subspace
-                ymd = None
-                page += f"\n## {cmt.sub_name}\n"
+            if not is_feed:
+                # Headings.
+                if cur_sub != cmt.subspace:
+                    cur_sub = cmt.subspace
+                    ymd = None
+                    page += f"\n## {cmt.sub_name}\n"
             if cur_parent != cmt.parent:
                 cur_parent = cmt.parent
                 parent_post = db.get_post(id=cur_parent)
                 if parent_post:
+                    prefix = prefix = f'{"u" if cmt.sub_owner else "s"}/{cmt.sub_name}: ' if is_feed else ''
                     parent_title = parent_post.title if parent_post.title else f'"{shorten_text(strip_links(clean_title(parent_post.summary)), 120)}"'
                     if parent_post.issueid:
                         parent_title = f'[#{parent_post.issueid}] ' + parent_title
                 else:
                     if not session.user or session.user.id != cmt.user:
                         continue # Don't show other people's comments on deleted posts.
+                    prefix = ''
                     parent_title = f"Deleted post (ID:{cur_parent})"
-                page += f"\n{parent_title}\n"
+                page += f"\n{prefix}{parent_title}\n"
             cmt_ymd = cmt.ymd_date(tz=session.tz)
             title = shorten_text(strip_links(clean_title(cmt.summary)), 120)
             entry = f'=> {cmt.page_url()} {cmt_ymd} "{title}"\n'