diff --git a/public/style.css b/public/style.css index 7cb8d12..b9eb6f9 100644 --- a/public/style.css +++ b/public/style.css @@ -304,11 +304,11 @@ form.savecomment { .morecomments a:hover { text-decoration: underline; } -.member { +.member, .block { display: inline-block; margin-bottom:3px; } -.member input { +.member input, .block input { font-size: 10px; font-weight: bold; display: inline-block; @@ -320,10 +320,10 @@ form.savecomment { bottom: 1px; cursor: pointer; } -.join input { +.join input, .block input { background-color: green; } -.leave input { +.leave input, .block.unblock input { background-color: #cf6165; } .pending input { diff --git a/routes.go b/routes.go index f914ab8..17c8355 100644 --- a/routes.go +++ b/routes.go @@ -119,9 +119,9 @@ var funcMap = template.FuncMap{ if re.MatchString(p.URL.String()) { return p.URL.String() + "?format=jpg&thumbnail=96" } - re = regexp.MustCompile(`^https:\/\/i.imgur.com\/([a-zA-Z0-9]+)\.([a-z]+)$`) + re = regexp.MustCompile(`^https:\/\/(i\.)?imgur.com\/([a-zA-Z0-9]{5,})(\.[a-zA-Z0-9]+)?`) if re.MatchString(p.URL.String()) { - return re.ReplaceAllString(p.URL.String(), "https://i.imgur.com/${1}s.$2") + return re.ReplaceAllString(p.URL.String(), "https://i.imgur.com/${2}s.jpg") } if p.URL.IsValid() { return "/_/static/link.png" @@ -139,14 +139,17 @@ var funcMap = template.FuncMap{ } converted := buf.String() converted = strings.Replace(converted, `!$1@$2 `) if os.Getenv("LEMMY_DOMAIN") == "" { + re = regexp.MustCompile(`href="\/(c\/[a-zA-Z0-9\-]+|(post|comment)\/\d+)`) + converted = re.ReplaceAllString(converted, `href="https://`+host+`/$1`) re := regexp.MustCompile(`href="https:\/\/([a-zA-Z0-9\.\-]+\/(c\/[a-zA-Z0-9]+|(post|comment)\/\d+))`) converted = re.ReplaceAllString(converted, `href="/$1`) + } else { + re := regexp.MustCompile(`href="https:\/\/` + os.Getenv("LEMMY_DOMAIN") + `\/(c\/[a-zA-Z0-9]+|(post|comment)\/\d+)`) + converted = re.ReplaceAllString(converted, `href="/$1`) } - re = regexp.MustCompile(`href="\/(c\/[a-zA-Z0-9\-]+|(post|comment)\/\d+)`) - converted = re.ReplaceAllString(converted, `href="/`+host+`/$1`) - re = regexp.MustCompile(` !([a-zA-Z0-9]+)@([a-zA-Z0-9\.\-]+) `) - converted = re.ReplaceAllString(converted, ` !$1@$2 `) re = regexp.MustCompile(`::: spoiler (.*?)\n([\S\s]*?):::`) converted = re.ReplaceAllString(converted, "
$1$2
") return template.HTML(converted) @@ -753,6 +756,18 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { CommunityID: communityid, Follow: true, }) + case "block": + communityid, _ := strconv.Atoi(r.FormValue("communityid")) + state.Client.BlockCommunity(context.Background(), types.BlockCommunity{ + CommunityID: communityid, + Block: true, + }) + case "unblock": + communityid, _ := strconv.Atoi(r.FormValue("communityid")) + state.Client.BlockCommunity(context.Background(), types.BlockCommunity{ + CommunityID: communityid, + Block: false, + }) case "logout": deleteCookie(w, state.Host, "jwt") deleteCookie(w, state.Host, "user") diff --git a/templates/frontpage.html b/templates/frontpage.html index 42434fa..b812252 100644 --- a/templates/frontpage.html +++ b/templates/frontpage.html @@ -2,7 +2,7 @@ {{ if and .Community (ne .Community.CommunityView.Community.Title "")}}{{.Community.CommunityView.Community.Title}}{{else if ne .CommunityName ""}}/c/{{.CommunityName}}{{ else if .User}}overview for {{.User.PersonView.Person.Name}}{{else}}{{ host .Host }}{{end}} - + diff --git a/templates/main.html b/templates/main.html index c4f5a9d..ed08e98 100644 --- a/templates/main.html +++ b/templates/main.html @@ -3,7 +3,7 @@ {{if and .Posts .PostID }}{{ (index .Posts 0).Post.Name}} : {{.CommunityName}}{{else if and .Community (ne .Community.CommunityView.Community.Title "")}}{{.Community.CommunityView.Community.Title}}{{else if ne .CommunityName ""}}/c/{{.CommunityName}}{{ else if .User}}overview for {{.User.PersonView.Person.Name}}{{else}}{{ host .Host }}{{end}} - +