M TODO => TODO +1 -1
@@ 2,12 2,12 @@ Setup fishbb.org (cloud provider)
FEATURES:
rate limit registration
+links on home and thread list should go to the post
Login/Reigster:
finish up oauth integration
admin/mod ability to delete / edit posts
Edit save should return to post
-links on home and thread list should go to the post
proper page titles
ts hover to show full TS + Timestamp into a template snippet
Notifications (Including integration with PWA / browser API)
M db.go => db.go +3 -3
@@ 181,11 181,11 @@ func prepareStatements(db *sql.DB) {
select
threads.id,
forums.slug,
- (select count(1) from threads where threads.id = threads.id) as count
- from posts
+ (select count(1) from posts where threads.id = posts.threadid and id < ?1) as count
+ from posts
left join threads on posts.threadid = threads.id
left join forums on threads.forumid = forums.id
- where posts.id = ?
+ where posts.id = ?1
`)
// very dumb atm. maybe improve?
stmtQueryPosts = prepare(db, "select 1")
M post.go => post.go +5 -4
@@ 29,6 29,7 @@ type PostSummary struct {
// TODO more sophisticated
const previewLength = 10
+// unused atm
func (p Post) Preview() string {
text := html2text.HTML2Text(p.Content)
if len(text) > previewLength-3 {
@@ 55,12 56,12 @@ func getPostSlug(postid int) (string, error) {
return "", err
}
// TODO fix bug here
- lastPage := ((count + 1) / config.PageSize) - 1
- fmt.Println(lastPage, count)
+ fmt.Println(count, config.PageSize, postid, threadid)
+ postPage := ((count) / config.PageSize) + 1
var url string
// TODO url builder
- if lastPage != 1 {
- url = fmt.Sprintf("/f/%s/%d?page=%d#%d", forumname, threadid, lastPage, postid)
+ if postPage != 1 {
+ url = fmt.Sprintf("/f/%s/%d?p=%d#%d", forumname, threadid, postPage, postid)
} else {
url = fmt.Sprintf("/f/%s/%d#%d", forumname, threadid, postid)
}
M util.go => util.go +1 -1
@@ 77,7 77,7 @@ func paginate(page int) (int, int) {
// pulls page from url param. 1-indexed
func page(r *http.Request) int {
- page, _ := strconv.Atoi(r.URL.Query().Get("page"))
+ page, _ := strconv.Atoi(r.URL.Query().Get("p"))
if page == 0 { // 1-indexing
page = 1
}
M views/pagelist.html => views/pagelist.html +3 -3
@@ 3,15 3,15 @@
{{ if ne $length 1 }}
<span style="padding-right:0.3rem;">
{{ if ne $.Page 1 }}
- <a href=?page={{ dec $.Page }}><</a>
+ <a href=?p={{ dec $.Page }}><</a>
{{ end }}
{{ range $pages }}
{{ if eq . $.Page }} <b>{{.}}</b>
{{ else }}
- <a href="?page={{.}}">{{.}}</a>
+ <a href="?p={{.}}">{{.}}</a>
{{ end }}{{ end }}
{{ if lt $.Page $length }}
- <a href=?page={{ inc $.Page }}>></a>
+ <a href=?p={{ inc $.Page }}>></a>
{{ end }}
</span>
{{ end }}
M web.go => web.go +6 -0
@@ 224,6 224,12 @@ func editPostPage(w http.ResponseWriter, r *http.Request) {
return
}
post.Content = content
+ slug, err := getPostSlug(pid)
+ if err != nil {
+ serverError(w, r, err)
+ return
+ }
+ http.Redirect(w, r, slug, http.StatusSeeOther)
// TODO redirect to post
}
tmpl["Post"] = post