mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-05 06:43:21 +00:00
rewrite links
This commit is contained in:
parent
4f77234854
commit
4787f209c6
10
routes.go
10
routes.go
|
@ -109,12 +109,14 @@ var funcMap = template.FuncMap{
|
|||
if err := md.Convert([]byte(body), &buf); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
converted := strings.Replace(buf.String(), `href="https://`+host, `href="/`+host, -1)
|
||||
converted := buf.String()
|
||||
converted = strings.Replace(converted, `<img `, `<img loading="lazy" `, -1)
|
||||
re := regexp.MustCompile(`href="https:\/\/([a-zA-Z0-9\.]+\/(c\/[a-zA-Z0-9]+|(post|comment)\/\d+))`)
|
||||
converted = re.ReplaceAllString(converted, `href="/$1`)
|
||||
return template.HTML(converted)
|
||||
},
|
||||
"contains": strings.Contains,
|
||||
"sub": func(a int, b int) int {
|
||||
"sub": func(a int32, b int) int {
|
||||
return int(a) - b
|
||||
},
|
||||
}
|
||||
|
@ -522,7 +524,9 @@ func GetLogin(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||
return
|
||||
}
|
||||
state.GetSite()
|
||||
state.GetCaptcha()
|
||||
if state.Site.SiteView.LocalSite.CaptchaEnabled {
|
||||
state.GetCaptcha()
|
||||
}
|
||||
m, _ := url.ParseQuery(r.URL.RawQuery)
|
||||
if len(m["alert"]) > 0 {
|
||||
state.Alert = m["alert"][0]
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
<span> - </span>
|
||||
<a href="/{{.Host}}?listingType=All">all</a>
|
||||
|
|
||||
{{ $last := (sub (len .TopCommunities) 1) }}
|
||||
{{ $host := .Host }}
|
||||
{{ range $i, $c := .TopCommunities}}
|
||||
<a href="/{{$host}}/c/{{$c.Community.Name}}">{{$c.Community.Name}}</a>
|
||||
{{ if ne $i $last }}<span> - </span>{{end}}
|
||||
<span> - </span>
|
||||
{{ end }}
|
||||
<a href="/{{$host}}/search?searchtype=Communities" class="more">more »</a>
|
||||
</div>
|
||||
|
@ -54,7 +53,7 @@
|
|||
email
|
||||
<div><input {{ if and .Site .Site.SiteView.LocalSite.RequireEmailVerification }} required {{ end }}name="email" type="text"></div>
|
||||
</label>
|
||||
{{ if and .Site (eq .Site.SiteView.LocalSite.RegistrationMode "requireapplication") }}
|
||||
{{ if and .Site (or (eq .Site.SiteView.LocalSite.RegistrationMode "RequireApplication") (eq .Site.SiteView.LocalSite.RegistrationMode "requireapplication")) }}
|
||||
<div class="question">
|
||||
{{ markdown .Host .Site.SiteView.LocalSite.ApplicationQuestion.String }}
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>{{if ne .PostID 0}}{{ (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 }}{{end}}</title>
|
||||
<title>{{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 }}{{end}}</title>
|
||||
<link rel="shortcut icon" href="/{{.Host}}/icon.jpg">
|
||||
<link rel="stylesheet" href="/_/static/style.css">
|
||||
</head>
|
||||
|
@ -67,7 +67,7 @@
|
|||
{{ template "create_post.html" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .PostID }}
|
||||
{{ if and .PostID .Posts}}
|
||||
{{ if .CommentID}}
|
||||
<div class="warning">you are viewing a single comment's thread<br>
|
||||
<a href="../post/{{.PostID}}/#c{{.CommentID}}">view the rest of the comments</a>
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
<span> - </span>
|
||||
<a href="/{{.Host}}?listingType=All">all</a>
|
||||
|
|
||||
{{ $last := (sub (len .TopCommunities) 1) }}
|
||||
{{ $host := .Host }}
|
||||
{{ range $i, $c := .TopCommunities}}
|
||||
<a href="/{{$host}}/c/{{$c.Community.Name}}">{{$c.Community.Name}}</a>
|
||||
{{ if ne $i $last }}<span> - </span>{{end}}
|
||||
<span> - </span>
|
||||
{{ end }}
|
||||
<a href="/{{$host}}/search?searchtype=Communities" class="more">more »</a>
|
||||
</div>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
</form>
|
||||
{{ end }}
|
||||
|
||||
{{ if .PostID }}
|
||||
{{ if and .PostID .Posts }}
|
||||
<div class="stats">
|
||||
this post was submitted on {{ (index .Posts 0).Post.Published.Time.Format "01 Jan 2006" }}
|
||||
<div><b><span>{{ (index .Posts 0).Counts.Score }}</span> points</b> ({{likedPerc (index .Posts 0).Counts}}% liked)</div>
|
||||
|
|
Loading…
Reference in a new issue