allow pdf attachments. serious business only.
This commit is contained in:
parent
a81ec6f628
commit
0a04051c42
|
@ -2,6 +2,8 @@ changelog
|
|||
|
||||
-- next
|
||||
|
||||
+ Allow PDF attachments. For serious business only.
|
||||
|
||||
+ "Untag" button to mute part of a thread.
|
||||
|
||||
++ Subscribe to hashtags.
|
||||
|
|
|
@ -91,7 +91,7 @@ to read this noise.
|
|||
One may attach a file to a post.
|
||||
Images are automatically rescaled and reduced in size for federation.
|
||||
A description, or caption, is encouraged.
|
||||
Text files are also supported as attachments.
|
||||
Text files and PDFs are also supported as attachments.
|
||||
Other formats are not supported.
|
||||
.Pp
|
||||
One may also check in to a location.
|
||||
|
|
|
@ -65,7 +65,9 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
|||
{{ range .Donks }}
|
||||
{{ if .Local }}
|
||||
{{ if eq .Media "text/plain" }}
|
||||
<p><a href="/d/{{ .XID }}">Attachment: {{ .Name }}</a>
|
||||
<p><a href="/d/{{ .XID }}">Attachment: {{ .Name }}</a> {{ .Desc }}
|
||||
{{ else if eq .Media "application/pdf" }}
|
||||
<p><a href="/d/{{ .XID }}">Attachment: {{ .Name }}</a> {{ .Desc }}
|
||||
{{ else }}
|
||||
<p><img src="/d/{{ .XID }}" title="{{ .Desc }}" alt="{{ .Desc }}">
|
||||
{{ end }}
|
||||
|
|
21
web.go
21
web.go
|
@ -1310,6 +1310,22 @@ func submithonk(w http.ResponseWriter, r *http.Request) {
|
|||
name = xid + "." + format
|
||||
xid = name
|
||||
} else {
|
||||
ct := http.DetectContentType(data)
|
||||
switch ct {
|
||||
case "application/pdf":
|
||||
maxsize := 1000000
|
||||
if len(data) > maxsize {
|
||||
log.Printf("bad image: %s too much pdf: %d", err, len(data))
|
||||
http.Error(w, "didn't like your attachment", http.StatusUnsupportedMediaType)
|
||||
return
|
||||
}
|
||||
media = ct
|
||||
xid += ".pdf"
|
||||
name = filehdr.Filename
|
||||
if name == "" {
|
||||
name = xid
|
||||
}
|
||||
default:
|
||||
maxsize := 100000
|
||||
if len(data) > maxsize {
|
||||
log.Printf("bad image: %s too much text: %d", err, len(data))
|
||||
|
@ -1324,11 +1340,12 @@ func submithonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
media = "text/plain"
|
||||
xid += ".txt"
|
||||
name = filehdr.Filename
|
||||
if name == "" {
|
||||
name = xid + ".txt"
|
||||
name = xid
|
||||
}
|
||||
}
|
||||
xid += ".txt"
|
||||
}
|
||||
desc := strings.TrimSpace(r.FormValue("donkdesc"))
|
||||
if desc == "" {
|
||||
|
|
Loading…
Reference in New Issue