Improve post view

Moves link below main post and adds date
This commit is contained in:
arne 2025-11-18 16:41:37 +01:00
commit 342462fd63
2 changed files with 47 additions and 18 deletions

View file

@ -103,14 +103,34 @@
list-style-type: none; list-style-type: none;
} }
ul.results li { ul.results li.result {
padding: 36px 0; padding: 36px 0;
border-top: 2px dotted #dccb8b; border-top: 2px dotted #dccb8b;
} }
.content p:last-child { .post .metadata {
display: grid;
grid-template-columns: 1fr 1fr;
}
.post .metadata .post-info {
text-align: right;
}
.post .metadata .mentions,
.post .metadata .date {
color: #777;
}
.post .content p:last-child {
margin-bottom: 0 margin-bottom: 0
} }
.post ul.controls {
margin: 18px 0 0;
padding: 0;
list-style-type: none;
}
</style> </style>
</head> </head>
<body> <body>

View file

@ -294,6 +294,13 @@
(defn user [{:keys [user]}] (defn user [{:keys [user]}]
(:username user)) (:username user))
(defn- list-accounts [accounts]
[:<>
(->> (map-indexed (fn [idx account]
^{:key idx} [user {:user account}]) accounts)
(interleave (repeat ", "))
(drop 1))])
(defn attachment [{:keys [attachment]}] (defn attachment [{:keys [attachment]}]
(case (:type attachment) (case (:type attachment)
"image" [:img {:src (:preview_url attachment) "image" [:img {:src (:preview_url attachment)
@ -309,23 +316,25 @@
(defn post [{:keys [post]}] (defn post [{:keys [post]}]
; TODO: handle (:sensitive post) ; TODO: handle (:sensitive post)
[:article [:article.post
[:div.users [:header.metadata
[user {:user (:account post)}] [:section.users
(when (seq (:mentions post)) [user {:user (:account post)}]
[:span.mentions (when (seq (:mentions post))
{:style #js {:color "#777"}} [:span.mentions
" (mentioning " (->> (map-indexed (fn [idx account] " (mentioning " [list-accounts (:mentions post)] ")"])]
^{:key idx} [user {:user account}]) [:section.post-info
(:mentions post)) [:time.date {:datetime (:created_at post)} (first (str/split (:created_at post) "T"))]]]
(interleave (repeat ", ")) [:section.content {:dangerouslySetInnerHTML (r/unsafe-html (:content post))}
(drop 1)) ")"])]
[:div.url [:a {:href (:url post)} (:url post)]]
[:div.content {:dangerouslySetInnerHTML (r/unsafe-html (:content post))}
(when (seq (:media_attachments post)) (when (seq (:media_attachments post))
[:div.attachments (map-indexed (fn [idx item] [:section.attachments
^{:key idx} [attachment {:attachment item}]) (map-indexed (fn [idx item]
(:media_attachments post))])] ^{:key idx} [attachment {:attachment item}])
(:media_attachments post))])]
[:nav
[:ul.controls
[:li.control-element.url
[:a {:href (:url post) :target "_blank"} "↗ Open original post"]]]]
#_[debug post]]) #_[debug post]])
(defn- refresh-displayed-posts! (defn- refresh-displayed-posts!