diff --git a/README.md b/README.md index c2bde67..ee99f9e 100644 --- a/README.md +++ b/README.md @@ -3,23 +3,14 @@ a familiar desktop experience for [lemmy](https://join-lemmy.org).  -## deployment +### deployment ```bash docker run -it -p "8080:8080" ghcr.io/rystaf/mlmym:latest ``` -## config +### config Set the environment variable `LEMMY_DOMAIN` to run in single instance mode ```bash docker run -it -e LEMMY_DOMAIN='lemmydomain.com' -p "8080:8080" ghcr.io/rystaf/mlmym:latest ``` -#### default user settings -| environment variable | default | -| -------------------- | ------- | -| DARK | false | -| HIDE_THUMBNAILS | false | -| LISTING | All | -| SORT | Hot | -| COMMENT_SORT | Hot | - diff --git a/public/style.css b/public/style.css index 7522f61..7b8a084 100644 --- a/public/style.css +++ b/public/style.css @@ -1110,7 +1110,7 @@ form.create input[type=file], form.create select { } .preferences label{ display: inline-block; - width: 150px; + width: 130px; margin-right: 5px; text-align: right; diff --git a/routes.go b/routes.go index d72d653..754739b 100644 --- a/routes.go +++ b/routes.go @@ -208,14 +208,6 @@ func RegReplace(input string, match string, replace string) string { return re.ReplaceAllString(input, replace) } -func getenv(key, fallback string) string { - value := os.Getenv(key) - if len(value) == 0 { - return fallback - } - return value -} - func Initialize(Host string, r *http.Request) (State, error) { state := State{ Host: Host, @@ -260,27 +252,18 @@ func Initialize(Host string, r *http.Request) (State, error) { state.Listing = getCookie(r, "DefaultListingType") state.Sort = getCookie(r, "DefaultSortType") state.CommentSort = getCookie(r, "DefaultCommentSortType") - if dark := getCookie(r, "Dark"); dark != "" { - state.Dark = dark != "0" - } else { - state.Dark = os.Getenv("DARK") != "" - } + state.Dark = getCookie(r, "Dark") != "" state.ShowNSFW = getCookie(r, "ShowNSFW") != "" state.HideInstanceNames = getCookie(r, "HideInstanceNames") != "" - if hide := getCookie(r, "HideThumbnails"); hide != "" { - state.HideThumbnails = hide != "0" - } else { - state.HideThumbnails = os.Getenv("HIDE_THUMBNAILS") != "" - } state.ParseQuery(r.URL.RawQuery) if state.Sort == "" { - state.Sort = getenv("SORT", "Hot") + state.Sort = "Hot" } if state.CommentSort == "" { - state.CommentSort = getenv("COMMENT_SORT", "Hot") + state.CommentSort = "Hot" } if state.Listing == "" || state.Session == nil && state.Listing == "Subscribed" { - state.Listing = getenv("LISTING", "All") + state.Listing = "All" } return state, nil } @@ -715,7 +698,8 @@ func Settings(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { setCookie(w, "", "Dark", "1") state.Dark = true } else { - setCookie(w, "", "Dark", "0") + deleteCookie(w, state.Host, "Dark") + deleteCookie(w, "", "Dark") state.Dark = false } if r.FormValue("shownsfw") != "" { @@ -733,13 +717,6 @@ func Settings(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { deleteCookie(w, "", "HideInstanceNames") state.HideInstanceNames = false } - if r.FormValue("hideThumbnails") != "" { - setCookie(w, "", "HideThumbnails", "1") - state.HideInstanceNames = true - } else { - setCookie(w, "", "HideThumbnails", "0") - state.HideInstanceNames = 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 1e2085a..b45dfc0 100644 --- a/state.go +++ b/state.go @@ -104,7 +104,6 @@ type State struct { Dark bool ShowNSFW bool HideInstanceNames bool - HideThumbnails bool } func (s State) Unknown() string { diff --git a/templates/post.html b/templates/post.html index 185e4b5..b3696be 100644 --- a/templates/post.html +++ b/templates/post.html @@ -23,13 +23,11 @@ {{ end }} {{ if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }} - {{ if not .State.HideThumbnails }}
- {{ end }}