clemmy/pretty.sh

24 lines
1.2 KiB
Bash
Raw Normal View History

2023-01-17 01:07:40 +11:00
# Please don't abuse jq like this
full_post_jq='(.post | (.id | tostring)+" "+(.name | tostring)),
2023-01-17 01:07:40 +11:00
(.post.url)+", "+(.creator.display_name // .creator.name)+":",
((.comment // .post) | .published,
(.body // .content))'
short_post_jq='(.post | (.id | tostring)+" "+(.name | tostring)),
2023-01-17 01:07:40 +11:00
(.post.url)+", "+(.creator.display_name // .creator.name)+":",
((.comment // .post) | .published)'
comment_jq='(.comment | .path[2:])+", "+(.creator.display_name // .creator.name)+":",
2023-01-17 01:07:40 +11:00
((.comment // .post) | .published,
(.body // .content))'
2023-01-17 01:07:40 +11:00
#Split this out because I specifically do want to include post IDs in some places. Or rather, I only don't want to include them on the comments view.
notif_jq='(.comment | (.parent_id | tostring)+"->"+(.id | tostring))+" ("+(.post | (.id | tostring))+"), "+(.creator.display_name // .creator.name)+":",
2023-01-17 01:07:40 +11:00
((.comment // .post) | .published,
(.body // .content))'
community_jq='(.community | (.id | tostring)+" "+.actor_id,.description),
.subscribed,
(.counts | [.subscribers,.posts,.comments,.users_active_week] | join(" "))'
2023-01-17 01:07:40 +11:00
multi_jq(){ echo '.[] | '"$1"',""'; }
comments_jq=$(multi_jq "$comment_jq")
posts_jq=$(multi_jq "$full_post_jq")
notifs_jq=$(multi_jq "$notif_jq")
communities_jq=$(multi_jq "$community_jq")