add missing handlers. fixes #31

This commit is contained in:
Ryan Stafford 2023-07-11 10:21:57 -04:00
parent 7ca1e23acf
commit 919a114f99
6 changed files with 19 additions and 9 deletions

View file

@ -74,6 +74,7 @@ summary {
color: #646464;
}
.comment .score {
clear:left;
margin-right: 4px;
overflow:hidden;
}
@ -82,6 +83,9 @@ summary {
overflow:hidden;
max-width: 840px;
}
.comment.hidden {
padding-bottom:5px;
}
.comment.hidden .score {
visibility: hidden;
}
@ -266,9 +270,6 @@ form.savecomment {
font-size: 10px;
margin-right: 2px;
}
.comment.hidden {
margin-bottom: 10px;
}
.comment.hidden .meta a {
color: gray;
font-weight: 400;
@ -283,6 +284,7 @@ form.savecomment {
.children .morecomments {
}
.morecomments {
clear: left;
margin: 0px 0px 10px 0px;
font-size: 10px;
}

View file

@ -55,6 +55,7 @@ function commentClick(e) {
request(targ.target || "", params,
function(res){
targ.outerHTML = res
setup()
},
function(res){
e.target.disabled = ""
@ -99,6 +100,7 @@ function commentClick(e) {
e.preventDefault()
request(e.target.href+"&xhr",false, function(res){
targ.outerHTML = res
setup()
})
return false
}
@ -172,6 +174,7 @@ function formSubmit(e) {
request(targ.target, params,
function(res){
targ.outerHTML = res
setup()
},
function(res){
e.submitter.disabled = ""

View file

@ -643,10 +643,14 @@ func SignUpOrLogin(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
q.Add("alert", alert)
r.URL.RawQuery = q.Encode()
http.Redirect(w, r, r.URL.String(), 301)
return
}
}
if token != "" {
state.GetUser(username)
if state.User == nil {
return
}
setCookie(w, state.Host, "jwt", token)
userid := strconv.Itoa(state.User.PersonView.Person.ID)
setCookie(w, state.Host, "user", state.User.PersonView.Person.Name+":"+userid)
@ -663,7 +667,7 @@ func GetLogin(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
return
}
state.GetSite()
if state.Site.SiteView.LocalSite.CaptchaEnabled {
if state.Site != nil && state.Site.SiteView.LocalSite.CaptchaEnabled {
state.GetCaptcha()
}
m, _ := url.ParseQuery(r.URL.RawQuery)

View file

@ -219,7 +219,8 @@ func (state *State) GetSite() {
resp, err := state.Client.Site(context.Background(), types.GetSite{})
if err != nil {
state.Status = http.StatusInternalServerError
state.Host = ""
state.Host = "."
state.Error = errors.New("site unreachable")
return
}
state.Client.Token = token

View file

@ -2,7 +2,7 @@
<head>
<title>{{ 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}}</title>
<link rel="shortcut icon" href="/{{.Host}}/icon.jpg">
<link rel="stylesheet" href="/_/static/style.css?v=17">
<link rel="stylesheet" href="/_/static/style.css?v=18">
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body {{ if .Dark }}class="dark"{{end}}>
@ -56,6 +56,6 @@
{{ template "sidebar.html" . }}
</main>
{{ end }}
<script src="/_/static/utils.js?v=12"></script>
<script src="/_/static/utils.js?v=13"></script>
</body>
</html>

View file

@ -3,7 +3,7 @@
<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 .Host }}{{end}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/{{.Host}}/icon.jpg">
<link rel="stylesheet" href="/_/static/style.css?v=17">
<link rel="stylesheet" href="/_/static/style.css?v=18">
</head>
<body{{ if .Dark }} class="dark"{{end}}>
<noscript>
@ -125,7 +125,7 @@
<input id="loadmore" type="submit" value="load more" data-page="2">
{{ end }}
<script src="/_/static/utils.js?v=12"></script>
<script src="/_/static/utils.js?v=13"></script>
{{ template "sidebar.html" . }}
</main>
{{ end }}