From 22b40b593544c1b2da7a35006b4d434a7540a555 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 16 Nov 2019 18:50:50 -0500 Subject: [PATCH] add option to switch to apple maps links --- docs/changelog.txt | 2 ++ docs/honk.1 | 9 +++++++++ honk.go | 1 + views/account.html | 2 ++ views/honk.html | 3 ++- views/honkfrags.html | 3 ++- views/honkpage.html | 3 ++- web.go | 19 +++++++++++++++++++ 8 files changed, 39 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index f750a3c..00f5c3d 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Option to switch map links to Apple. + -- 0.8.2 ++ Import command to preserve those embarssassing old posts from Twitter. diff --git a/docs/honk.1 b/docs/honk.1 index a34d65e..299802d 100644 --- a/docs/honk.1 +++ b/docs/honk.1 @@ -164,6 +164,15 @@ It also allows the import of external objects via URL, either individual posts or actor URLs, in which case their recent outbox is imported. .Ss Account It's all about you. +.Pp +Some options to customize the site appearance: +.Bl -tag -width skinny +.It skinny +Use a narrower column for the main display. +.It apple +Prefer Apple links for maps. +The default is OpenStreetMap. +.El .Sh ENVIRONMENT .Nm is designed to work with most browsers, but for optimal results it is diff --git a/honk.go b/honk.go index c38e71a..7b46f6c 100644 --- a/honk.go +++ b/honk.go @@ -48,6 +48,7 @@ type WhatAbout struct { type UserOptions struct { SkinnyCSS bool `json:",omitempty"` Avatar string `json:",omitempty"` + MapLink string `json:",omitempty"` } type KeyInfo struct { diff --git a/views/account.html b/views/account.html index 8b956ff..c6425eb 100644 --- a/views/account.html +++ b/views/account.html @@ -10,6 +10,8 @@

+

+

diff --git a/views/honk.html b/views/honk.html index 61e4e74..805b366 100644 --- a/views/honk.html +++ b/views/honk.html @@ -1,6 +1,7 @@

{{ $bonkcsrf := .BonkCSRF }} {{ $IsPreview := .IsPreview }} +{{ $maplink := .MapLink }} {{ with .Honk }}
{{ if $bonkcsrf }} @@ -60,7 +61,7 @@ in reply to: {{ .RID }} {{ if .Duration }}
Duration: {{ .Duration }}{{ end }} {{ end }} {{ with .Place }} -

Location: {{ with .Url }}{{ end }}{{ .Name }}{{ if .Url }}{{ end }}{{ if or .Latitude .Longitude }} {{ .Latitude }} {{ .Longitude }}{{ end }} +

Location: {{ with .Url }}{{ end }}{{ .Name }}{{ if .Url }}{{ end }}{{ if or .Latitude .Longitude }} {{ .Latitude }} {{ .Longitude }}{{ end }} {{ end }} {{ range .Donks }} {{ if .Local }} diff --git a/views/honkfrags.html b/views/honkfrags.html index 30f6a30..91cc004 100644 --- a/views/honkfrags.html +++ b/views/honkfrags.html @@ -1,8 +1,9 @@

{{ .TopHID }}
{{ $BonkCSRF := .HonkCSRF }} +{{ $MapLink := .MapLink }}

{{ .ServerMessage }}

{{ range .Honks }} -{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }} +{{ template "honk.html" map "Honk" . "MapLink" .MapLink "BonkCSRF" $BonkCSRF }} {{ end }}
diff --git a/views/honkpage.html b/views/honkpage.html index b3aeb5c..4f8aff6 100644 --- a/views/honkpage.html +++ b/views/honkpage.html @@ -22,8 +22,9 @@
{{ $BonkCSRF := .HonkCSRF }} {{ $IsPreview := .IsPreview }} +{{ $MapLink := .MapLink }} {{ range .Honks }} -{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF "IsPreview" $IsPreview }} +{{ template "honk.html" map "Honk" . "MapLink" $MapLink "BonkCSRF" $BonkCSRF "IsPreview" $IsPreview }} {{ end }}
diff --git a/web.go b/web.go index ea7bba8..5411f75 100644 --- a/web.go +++ b/web.go @@ -59,6 +59,18 @@ func getuserstyle(u *login.UserInfo) template.CSS { return "" } +func getmaplink(u *login.UserInfo) string { + if u == nil { + return "osm" + } + user, _ := butwhatabout(u.Username) + ml := user.Options.MapLink + if ml == "" { + ml = "osm" + } + return ml +} + func getInfo(r *http.Request) map[string]interface{} { u := login.GetUserInfo(r) templinfo := make(map[string]interface{}) @@ -1032,6 +1044,7 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo } reverbolate(userid, honks) templinfo["Honks"] = honks + templinfo["MapLink"] = getmaplink(u) if templinfo["TopHID"] == nil { if len(honks) > 0 { templinfo["TopHID"] = honks[0].ID @@ -1056,6 +1069,9 @@ func saveuser(w http.ResponseWriter, r *http.Request) { if r.FormValue("skinny") == "skinny" { options.SkinnyCSS = true } + if r.FormValue("maps") == "apple" { + options.MapLink = "apple" + } j, err := jsonify(options) if err == nil { _, err = db.Exec("update users set about = ?, options = ? where username = ?", whatabout, j, u.Username) @@ -1271,6 +1287,7 @@ func edithonkpage(w http.ResponseWriter, r *http.Request) { templinfo := getInfo(r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["Honks"] = honks + templinfo["MapLink"] = getmaplink(u) templinfo["Noise"] = noise templinfo["SavedPlace"] = honk.Place templinfo["ServerMessage"] = "honk edit" @@ -1557,6 +1574,7 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) { templinfo := getInfo(r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["Honks"] = honks + templinfo["MapLink"] = getmaplink(userinfo) templinfo["InReplyTo"] = r.FormValue("rid") templinfo["Noise"] = r.FormValue("noise") templinfo["SavedFile"] = donkxid @@ -2027,6 +2045,7 @@ func webhydra(w http.ResponseWriter, r *http.Request) { } reverbolate(userid, honks) templinfo["Honks"] = honks + templinfo["MapLink"] = getmaplink(u) w.Header().Set("Content-Type", "text/html; charset=utf-8") err := readviews.Execute(w, "honkfrags.html", templinfo) if err != nil {