Compare commits
9 commits
10bca44dc5
...
fd0aff3099
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd0aff3099 | ||
|
|
af4c98c07d | ||
|
|
20f2cb81f1 | ||
|
|
4e3e07d670 | ||
|
|
65c29304f2 | ||
|
|
0a3515268c | ||
|
|
e212f4eb1e | ||
|
|
372a274aa6 | ||
|
|
664f319b28 |
10 changed files with 53 additions and 8 deletions
28
backend.go
28
backend.go
|
|
@ -17,10 +17,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"humungus.tedunangst.com/r/webs/gate"
|
"humungus.tedunangst.com/r/webs/gate"
|
||||||
"humungus.tedunangst.com/r/webs/image"
|
"humungus.tedunangst.com/r/webs/image"
|
||||||
|
|
@ -55,7 +58,32 @@ func backendSockname() string {
|
||||||
return dataDir + "/backend.sock"
|
return dataDir + "/backend.sock"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSVG(data []byte) bool {
|
||||||
|
ct := http.DetectContentType(data)
|
||||||
|
if strings.HasPrefix(ct, "text/xml") {
|
||||||
|
return strings.Index(string(data), "<!DOCTYPE svg PUBLIC") != -1
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(ct, "text/plain") {
|
||||||
|
return bytes.HasPrefix(data, []byte("<svg "))
|
||||||
|
}
|
||||||
|
return ct == "image/svg+xml"
|
||||||
|
}
|
||||||
|
|
||||||
|
func imageFromSVG(data []byte) (*image.Image, error) {
|
||||||
|
if len(data) > 100000 {
|
||||||
|
return nil, errors.New("my svg is too big")
|
||||||
|
}
|
||||||
|
svg := &image.Image{
|
||||||
|
Data: data,
|
||||||
|
Format: "svg+xml",
|
||||||
|
}
|
||||||
|
return svg, nil
|
||||||
|
}
|
||||||
|
|
||||||
func shrinkit(data []byte) (*image.Image, error) {
|
func shrinkit(data []byte) (*image.Image, error) {
|
||||||
|
if isSVG(data) {
|
||||||
|
return imageFromSVG(data)
|
||||||
|
}
|
||||||
cl, err := rpc.Dial("unix", backendSockname())
|
cl, err := rpc.Dial("unix", backendSockname())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ func gethonksforme(userid int64, wanted int64) []*Honk {
|
||||||
func gethonksfromlongago(userid int64, wanted int64) []*Honk {
|
func gethonksfromlongago(userid int64, wanted int64) []*Honk {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
var honks []*Honk
|
var honks []*Honk
|
||||||
for i := 1; i <= 3; i++ {
|
for i := 1; i <= 4; i++ {
|
||||||
dt := time.Date(now.Year()-i, now.Month(), now.Day(), now.Hour(), now.Minute(),
|
dt := time.Date(now.Year()-i, now.Month(), now.Day(), now.Hour(), now.Minute(),
|
||||||
now.Second(), 0, now.Location())
|
now.Second(), 0, now.Location())
|
||||||
dt1 := dt.Add(-36 * time.Hour).UTC().Format(dbtimeformat)
|
dt1 := dt.Add(-36 * time.Hour).UTC().Format(dbtimeformat)
|
||||||
|
|
@ -548,6 +548,8 @@ func savefileandxid(name string, desc string, url string, media string, local bo
|
||||||
xid += ".png"
|
xid += ".png"
|
||||||
case "image/jpeg":
|
case "image/jpeg":
|
||||||
xid += ".jpg"
|
xid += ".jpg"
|
||||||
|
case "image/svg+xml":
|
||||||
|
xid += ".svg"
|
||||||
case "application/pdf":
|
case "application/pdf":
|
||||||
xid += ".pdf"
|
xid += ".pdf"
|
||||||
case "text/plain":
|
case "text/plain":
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
changelog
|
changelog
|
||||||
|
|
||||||
|
=== next
|
||||||
|
|
||||||
|
+ search can now load external posts
|
||||||
|
|
||||||
=== 0.9.91 One More Time
|
=== 0.9.91 One More Time
|
||||||
|
|
||||||
+ Swallow a follow bug.
|
+ Swallow a follow bug.
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@ The
|
||||||
page lists recently seen honkers that are not otherwise tracked.
|
page lists recently seen honkers that are not otherwise tracked.
|
||||||
It also allows the import of external objects via URL, either individual
|
It also allows the import of external objects via URL, either individual
|
||||||
posts or actor URLs, in which case their recent outbox is imported.
|
posts or actor URLs, in which case their recent outbox is imported.
|
||||||
|
Probably easier to use the search box for this.
|
||||||
.Ss Account
|
.Ss Account
|
||||||
It's all about you.
|
It's all about you.
|
||||||
An avatar may be selected from the
|
An avatar may be selected from the
|
||||||
|
|
|
||||||
3
fun.go
3
fun.go
|
|
@ -463,7 +463,7 @@ func memetize(honk *Honk) {
|
||||||
honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl)
|
honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]]+([ \n.,']|$)")
|
var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]_]+([ \n:;.,']|$)")
|
||||||
|
|
||||||
func quickrename(s string, userid int64) string {
|
func quickrename(s string, userid int64) string {
|
||||||
nonstop := true
|
nonstop := true
|
||||||
|
|
@ -479,6 +479,7 @@ func quickrename(s string, userid int64) string {
|
||||||
m = m[1:]
|
m = m[1:]
|
||||||
tail := ""
|
tail := ""
|
||||||
if last := m[len(m)-1]; last == ' ' || last == '\n' ||
|
if last := m[len(m)-1]; last == ' ' || last == '\n' ||
|
||||||
|
last == ':' || last == ';' ||
|
||||||
last == '.' || last == ',' || last == '\'' {
|
last == '.' || last == ',' || last == '\'' {
|
||||||
tail = m[len(m)-1:]
|
tail = m[len(m)-1:]
|
||||||
m = m[:len(m)-1]
|
m = m[:len(m)-1]
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -9,5 +9,5 @@ require (
|
||||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
|
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
|
||||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
|
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
||||||
humungus.tedunangst.com/r/webs v0.6.60
|
humungus.tedunangst.com/r/webs v0.6.61
|
||||||
)
|
)
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -25,5 +25,5 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
||||||
humungus.tedunangst.com/r/webs v0.6.60 h1:2PjVTVH3js4PXv8lrEw7nxtRmwwt1COl7t7tZMPxBPs=
|
humungus.tedunangst.com/r/webs v0.6.61 h1:Sgy0Htb8Y0jmmLPp73nYDuD4NebeUsgXftP+wB86wSg=
|
||||||
humungus.tedunangst.com/r/webs v0.6.60/go.mod h1:03R0N9BcT49HB4TDd1YmarpbiPvPzVDm74Mk4h1hYPc=
|
humungus.tedunangst.com/r/webs v0.6.61/go.mod h1:03R0N9BcT49HB4TDd1YmarpbiPvPzVDm74Mk4h1hYPc=
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
{{ if .LocalStyleParam }}
|
{{ if .LocalStyleParam }}
|
||||||
<link href="/local.css{{ .LocalStyleParam }}" rel="stylesheet">
|
<link href="/local.css{{ .LocalStyleParam }}" rel="stylesheet">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ .APAltLink }}
|
||||||
<link href="/icon.png" rel="icon">
|
<link href="/icon.png" rel="icon">
|
||||||
<meta name="theme-color" content="#305">
|
<meta name="theme-color" content="#305">
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<form action="/ximport" method="POST">
|
<form action="/ximport" method="POST">
|
||||||
<input type="hidden" name="CSRF" value="{{ .XCSRF }}">
|
<input type="hidden" name="CSRF" value="{{ .XCSRF }}">
|
||||||
<p><span class="title">import</span>
|
<p><span class="title">import</span>
|
||||||
<p><input tabindex=1 type="text" name="xid" autocomplete=off> - xid
|
<p><input tabindex=1 type="text" name="q" autocomplete=off> - xid
|
||||||
<p><button tabindex=1 name="fetch" value="fetch">fetch</button>
|
<p><button tabindex=1 name="fetch" value="fetch">fetch</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
12
web.go
12
web.go
|
|
@ -395,7 +395,7 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
case "Ping":
|
case "Ping":
|
||||||
id, _ := j.GetString("id")
|
id, _ := j.GetString("id")
|
||||||
ilog.Printf("ping from %s: %s", who, id)
|
ilog.Printf("ping from %s: %s", who, id)
|
||||||
pong(user, who, obj)
|
pong(user, who, id)
|
||||||
case "Pong":
|
case "Pong":
|
||||||
ilog.Printf("pong from %s: %s", who, obj)
|
ilog.Printf("pong from %s: %s", who, obj)
|
||||||
case "Follow":
|
case "Follow":
|
||||||
|
|
@ -549,7 +549,7 @@ func serveractor(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func ximport(w http.ResponseWriter, r *http.Request) {
|
func ximport(w http.ResponseWriter, r *http.Request) {
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
xid := strings.TrimSpace(r.FormValue("xid"))
|
xid := strings.TrimSpace(r.FormValue("q"))
|
||||||
xonk := getxonk(u.UserID, xid)
|
xonk := getxonk(u.UserID, xid)
|
||||||
if xonk == nil {
|
if xonk == nil {
|
||||||
p, _ := investigate(xid)
|
p, _ := investigate(xid)
|
||||||
|
|
@ -788,6 +788,10 @@ func showconvoy(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
func showsearch(w http.ResponseWriter, r *http.Request) {
|
func showsearch(w http.ResponseWriter, r *http.Request) {
|
||||||
q := r.FormValue("q")
|
q := r.FormValue("q")
|
||||||
|
if strings.HasPrefix(q, "https://") {
|
||||||
|
ximport(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
honks := gethonksbysearch(u.UserID, q, 0)
|
honks := gethonksbysearch(u.UserID, q, 0)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
|
|
@ -1075,6 +1079,7 @@ func showonehonk(w http.ResponseWriter, r *http.Request) {
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
templinfo["ServerMessage"] = "one honk maybe more"
|
templinfo["ServerMessage"] = "one honk maybe more"
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
|
templinfo["APAltLink"] = templates.Sprintf("<link href='%s' rel='alternate' type='application/activity+json'>", xid)
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1499,6 +1504,9 @@ func submitdonk(w http.ResponseWriter, r *http.Request) (*Donk, error) {
|
||||||
if format == "jpeg" {
|
if format == "jpeg" {
|
||||||
format = "jpg"
|
format = "jpg"
|
||||||
}
|
}
|
||||||
|
if format == "svg+xml" {
|
||||||
|
format = "svg"
|
||||||
|
}
|
||||||
name = xfiltrate() + "." + format
|
name = xfiltrate() + "." + format
|
||||||
} else {
|
} else {
|
||||||
ct := http.DetectContentType(data)
|
ct := http.DetectContentType(data)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue