add: forum posts timeline

This commit is contained in:
trisua 2025-08-04 14:24:25 -04:00
parent 8c779b2f2e
commit d4ff681310
10 changed files with 159 additions and 17 deletions

View file

@ -2636,8 +2636,18 @@
(text "{%- endif %}")
(text "{%- endmacro %}")
(text "{% macro topic_post_display(post, owner, is_pinned=false) -%}")
(text "{% macro topic_post_display(post, owner, is_pinned=false, community=false) -%}")
(tr
(text "{% if community %}")
(td
(a
("href" "/community/{{ community.title }}/topic/{{ post.topic }}")
("class" "flex gap_1 items_center")
(text "{{ self::community_avatar(id=post.community, community=community) }}")
(span
(text "{% if community.context.display_name -%} {{ community.context.display_name }} {% else %} {{ community.title }} {%- endif %}"))))
(text "{%- endif %}")
(td
("class" "flex gap_1")
(a

View file

@ -165,7 +165,7 @@
(text "{%- endif %}")))
(text "{%- endmacro %}")
(text "{% macro timelines_nav(selected=\"\", posts=\"\", questions=\"\", secondary_selected=\"posts\") -%}")
(text "{% macro timelines_nav(selected=\"\", posts=\"\", questions=\"\", secondary_selected=\"posts\", forum_posts=\"\") -%}")
(div
("class" "mobile_nav mobile")
; primary nav
@ -184,7 +184,7 @@
(text "{% if posts and questions -%}")
; secondary nav
(text "{{ macros::timelines_secondary_nav(posts=posts, questions=questions, selected=secondary_selected) }}")
(text "{{ macros::timelines_secondary_nav(posts=posts, questions=questions, selected=secondary_selected, forum_posts=forum_posts) }}")
(text "{%- endif %}"))
(div
@ -194,7 +194,7 @@
; secondary nav desktop only
(text "{% if posts and questions -%}")
(text "{{ macros::timelines_secondary_nav(posts=posts, questions=questions, selected=secondary_selected) }}")
(text "{{ macros::timelines_secondary_nav(posts=posts, questions=questions, selected=secondary_selected, forum_posts=forum_posts) }}")
(text "{%- endif %}"))
(text "{%- endmacro %}")
@ -252,7 +252,7 @@
(text "{%- endif %}")))
(text "{%- endmacro %}")
(text "{% macro timelines_secondary_nav(posts=\"\", questions=\"\", selected=\"posts\") -%} {% if user -%}")
(text "{% macro timelines_secondary_nav(posts=\"\", questions=\"\", selected=\"posts\", forum_posts=\"\") -%} {% if user -%}")
(div
("class" "pillmenu w_full")
(a
@ -261,6 +261,14 @@
(icon (text "newspaper"))
(span (str (text "communities:label.posts"))))
(text "{% if forum_posts|length > 0 -%}")
(a
("href" "{{ forum_posts }}")
("class" "{% if selected == 'forum_posts' -%}active{%- endif %}")
(icon (text "list-tree"))
(span (str (text "communities:label.forum_posts"))))
(text "{%- endif %}")
(a
("href" "{{ questions }}")
("class" "{% if selected == 'questions' -%}active{%- endif %}")

View file

@ -1,11 +1,10 @@
(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "Latest posts - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
(main
("class" "flex flex_col gap_2")
(text "{{ macros::timelines_nav(selected=\"all\", posts=\"/all\", questions=\"/all/questions\") }} {% if not user -%}")
(text "{{ macros::timelines_nav(selected=\"all\", posts=\"/all\", questions=\"/all/questions\", forum_posts=\"/all/forum_posts\") }} {% if not user -%}")
(div
("class" "card_nest")
(div
@ -32,11 +31,9 @@
("class" "card w_full flex flex_col gap_2")
("ui_ident" "io_data_load")
(div ("ui_ident" "io_data_marker"))))
(text "{% set paged = user and user.settings.paged_timelines %}")
(script
(text "setTimeout(() => {
trigger(\"ui::io_data_load\", [\"/_swiss_army_timeline?tl=AllPosts&before=$1$&page=\", Number.parseInt(\"{{ page }}\") - 1, \"{{ paged }}\" === \"true\"]);
});"))
(text "{% endblock %}")

View file

@ -0,0 +1,24 @@
(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "Latest forum posts - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
(main
("class" "flex flex_col gap_2")
(text "{{ macros::timelines_nav(selected=\"all\", posts=\"/all\", questions=\"/all/questions\", secondary_selected=\"forum_posts\", forum_posts=\"/all/forum_posts\") }}")
(div
("class" "card w_full flex flex_col gap_2")
(div
("class" "w_full")
("style" "overflow: auto")
(table
("class" "w_full")
(thead
(th (text "In"))
(th (text "Title"))
(th (text "Replies"))
(th (text "Score"))
(th (text "Created")))
(tbody
(text "{% for post in feed %} {{ components::topic_post_display(post=post[0], owner=post[1], community=post[2]) }} {% endfor %}"))))
(text "{{ components::pagination(page=page, items=feed|length) }}")))
(text "{% endblock %}")

View file

@ -1,13 +1,11 @@
(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "Latest questions - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
(main
("class" "flex flex_col gap_2")
(text "{{ macros::timelines_nav(selected=\"all\", posts=\"/all\", questions=\"/all/questions\", secondary_selected=\"questions\") }}")
(text "{{ macros::timelines_nav(selected=\"all\", posts=\"/all\", questions=\"/all/questions\", secondary_selected=\"questions\", forum_posts=\"/all/forum_posts\") }}")
(div
("class" "card w_full flex flex_col gap_2")
(text "{% for question in list %} {{ components::global_question(question=question, can_manage_questions=false, secondary=true) }} {% endfor %} {{ components::pagination(page=page, items=list|length) }}")))
(text "{% endblock %}")