diff --git a/README.md b/README.md index c2bde67..1362fea 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,5 @@ docker run -it -e LEMMY_DOMAIN='lemmydomain.com' -p "8080:8080" ghcr.io/rystaf/m | LISTING | All | | SORT | Hot | | COMMENT_SORT | Hot | +| LINKS_IN_NEW_WINDOW | false | diff --git a/routes.go b/routes.go index b926cd1..7b2dfc0 100644 --- a/routes.go +++ b/routes.go @@ -282,6 +282,11 @@ func Initialize(Host string, r *http.Request) (State, error) { if state.Listing == "" || state.Session == nil && state.Listing == "Subscribed" { state.Listing = getenv("LISTING", "All") } + if linksInNewWindow := getCookie(r, "LinksInNewWindow"); linksInNewWindow != "" { + state.LinksInNewWindow = linksInNewWindow != "0" + } else { + state.LinksInNewWindow = os.Getenv("LINKS_IN_NEW_WINDOW") != "" + } return state, nil } func GetTemplate(name string) (*template.Template, error) { @@ -765,6 +770,13 @@ func Settings(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { setCookie(w, "", "HideThumbnails", "0") state.HideInstanceNames = false } + if r.FormValue("linksInNewWindow") != "" { + setCookie(w, "", "LinksInNewWindow", "1") + state.LinksInNewWindow = true + } else { + setCookie(w, "", "LinksInNewWindow", "0") + state.LinksInNewWindow = false + } state.Listing = r.FormValue("DefaultListingType") state.Sort = r.FormValue("DefaultSortType") state.CommentSort = r.FormValue("DefaultCommentSortType") diff --git a/state.go b/state.go index 1b1d804..9d2cd23 100644 --- a/state.go +++ b/state.go @@ -105,6 +105,7 @@ type State struct { ShowNSFW bool HideInstanceNames bool HideThumbnails bool + LinksInNewWindow bool SubmitURL string SubmitTitle string SubmitBody string diff --git a/templates/post.html b/templates/post.html index b1ceae3..e6ad447 100644 --- a/templates/post.html +++ b/templates/post.html @@ -25,14 +25,20 @@ {{ if not .State.HideThumbnails }}