allow pdf attachments. serious business only.
This commit is contained in:
parent
a81ec6f628
commit
0a04051c42
4 changed files with 38 additions and 17 deletions
|
|
@ -2,6 +2,8 @@ changelog
|
||||||
|
|
||||||
-- next
|
-- next
|
||||||
|
|
||||||
|
+ Allow PDF attachments. For serious business only.
|
||||||
|
|
||||||
+ "Untag" button to mute part of a thread.
|
+ "Untag" button to mute part of a thread.
|
||||||
|
|
||||||
++ Subscribe to hashtags.
|
++ Subscribe to hashtags.
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ to read this noise.
|
||||||
One may attach a file to a post.
|
One may attach a file to a post.
|
||||||
Images are automatically rescaled and reduced in size for federation.
|
Images are automatically rescaled and reduced in size for federation.
|
||||||
A description, or caption, is encouraged.
|
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.
|
Other formats are not supported.
|
||||||
.Pp
|
.Pp
|
||||||
One may also check in to a location.
|
One may also check in to a location.
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,9 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
||||||
{{ range .Donks }}
|
{{ range .Donks }}
|
||||||
{{ if .Local }}
|
{{ if .Local }}
|
||||||
{{ if eq .Media "text/plain" }}
|
{{ 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 }}
|
{{ else }}
|
||||||
<p><img src="/d/{{ .XID }}" title="{{ .Desc }}" alt="{{ .Desc }}">
|
<p><img src="/d/{{ .XID }}" title="{{ .Desc }}" alt="{{ .Desc }}">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
21
web.go
21
web.go
|
|
@ -1310,6 +1310,22 @@ func submithonk(w http.ResponseWriter, r *http.Request) {
|
||||||
name = xid + "." + format
|
name = xid + "." + format
|
||||||
xid = name
|
xid = name
|
||||||
} else {
|
} 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
|
maxsize := 100000
|
||||||
if len(data) > maxsize {
|
if len(data) > maxsize {
|
||||||
log.Printf("bad image: %s too much text: %d", err, len(data))
|
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"
|
media = "text/plain"
|
||||||
|
xid += ".txt"
|
||||||
name = filehdr.Filename
|
name = filehdr.Filename
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = xid + ".txt"
|
name = xid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xid += ".txt"
|
|
||||||
}
|
}
|
||||||
desc := strings.TrimSpace(r.FormValue("donkdesc"))
|
desc := strings.TrimSpace(r.FormValue("donkdesc"))
|
||||||
if desc == "" {
|
if desc == "" {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue