Show magnet URI in message headers

parent 000a14f7
......@@ -99,11 +99,13 @@
;; Return the html page
[else
(define (header-entry key content)
`(div (@ (class "feedish-header-entry"))
(b (@ (class "header-key"))
`(tr (@ (class "feedish-header-entry"))
(th (@ (class "header-key")
(valign "top"))
,(string-append key ": "))
(span (@ (class "header-content"))
,content)))
(td (@ (class "header-content")
(valign "top"))
,content)))
;; Render a collection, but only one item from that collection
;; TODO: move this to the templates section?
(define (preview-collection col-sym col-name col-handler)
......@@ -120,9 +122,17 @@
(define object
(store-get-json (hash-ref activity 'object)))
`(div (@ (class "feedish-top-post feedish-post"))
(div (@ (class "feedish-header"))
,(header-entry "From" (hash-ref activity 'actor)))
(p ,(hash-ref object 'content)))])))
(div
(@ (class "feedish-entry-headers"))
(table ,(header-entry "From"
(let ([actor (hash-ref activity 'actor)])
`(a (@ (href ,actor))
,actor)))
,(header-entry "Id"
`(pre (@ (class "magnet-preview"))
,(pretty-format-magnet post-uri)))))
(div (@ (class "feedish-entry-content"))
(p ,(hash-ref object 'content))))])))
(render-ok
(generic-base-tmpl
`(div ,(post-note-form)
......
......@@ -387,3 +387,27 @@ pre.tombstone-ascii {
.header-tag-mention a {
color: #62317b;
}
.feedish-entry-headers table {
border-spacing: 4px;
margin: -4px;
}
.feedish-entry-headers {
border-bottom: medium dashed #dddddd;
padding-bottom: 4px;
margin-bottom: 8px;
width: 100%;
}
.feedish-entry-headers table th {
text-align: left;
}
pre {
font-family: 'Inconsolata', monospace;
}
pre.magnet-preview {
margin: 0px;
}
......@@ -3,6 +3,7 @@
(provide (all-defined-out))
(require json
net/url
html-writing
racket/runtime-path
web-server/http/response-structs)
......@@ -49,3 +50,14 @@
'()
(lambda (out-port)
(write-bytes #"405 Method Not Allowed :P" out-port))))
(define (pretty-format-magnet magnet-url)
(define q-params
(string-join
(for/list ([q-param (url-query magnet-url)])
(match q-param
[(cons key val)
(format "~a=~a"
key val)]))
"\n &"))
(string-append "magnet:?" q-params))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment