~aw/fishbb

3892a9c4f00df4f6ca3e246f817d91cfa2b295fd — alex wennerberg a month ago bced0ac
some bug fixes, restructure timeago links
7 files changed, 10 insertions(+), 9 deletions(-)

M TODO
M db.go
M forum.go
M thread.go
M views/forum.html
M views/index.html
M web.go
M TODO => TODO +3 -1
@@ 3,18 3,20 @@ Setup fishbb.org (cloud provider)
FEATURES:
rate limit registration
links on home and thread list should go to the post
proper page titles

Login/Reigster:
finish up oauth integration
admin/mod ability to delete / edit posts
proper page titles
ts hover to show full TS + Timestamp into a template snippet
Notifications (Including integration with PWA / browser API)
Search
time is link

----- alpha waterline ----- (may push lower to get something more complete out)

# DEFINITELY
block renaming of form
IP blocking / other antispam
split out config management for admins
implement change password / reset password

M db.go => db.go +1 -1
@@ 108,7 108,7 @@ func prepareStatements(db *sql.DB) {
	stmtGetForum = prepare(db, "select id, name, description, slug, permissions from forums where id = ?")
	stmtGetForumBySlug = prepare(db, "select id, name, description, slug, permissions from forums where slug = ?")
	stmtGetForumID = prepare(db, "select id from forums where slug = ?")
	stmtUpdateForum = prepare(db, "update forums set name = ?, description = ?, permissions = ? where id = ?")
	stmtUpdateForum = prepare(db, "update forums set name = ?, description = ?, permissions = ?, slug = ? where id = ?")
	stmtCreateForum = prepare(db, "insert into forums (name, description, slug) values (?, ?, ?)")
	stmtCreateUser = prepare(db, "insert into users (username, email, hash, role, active, oauth) values (?, ?, ?, ?, ?, ?)")
	stmtGetUser = prepare(db, `

M forum.go => forum.go +1 -1
@@ 27,7 27,7 @@ func getForum(id int) (Forum, error) {
}

func updateForum(id int, name, description string, role Role) error {
	_, err := stmtUpdateForum.Exec(name, description, role, id)
	_, err := stmtUpdateForum.Exec(name, description, role, slugify(name), id)
	return err
}


M thread.go => thread.go +0 -1
@@ 23,7 23,6 @@ func getThreadCount(forumID int) (int, error) {
	return c, err
}

// TODO fix case when no threads
func getThreads(forumID, page int) ([]Thread, error) {
	var threads []Thread
	limit, offset := paginate(page)

M views/forum.html => views/forum.html +2 -3
@@ 18,7 18,7 @@
		<div>
	  by <a href="/user/{{.Author.ID}}">{{.Author.Username}}</a> <span class="text-alt">{{ timeago .Created }}</span>
		</div>
	  {{ if $.User.Role.ModLevel }}
	  {{ if and $.User $.User.Role.ModLevel }}
	  <span>
		  <form style="display:inline;" method="POST" action="/f/{{$.ForumSlug}}/{{.ID}}/lock?s={{not .Locked}}"><button class="link-button" id="submit">{{ if .Locked}}Unl{{else}}L{{end}}ock</button></form>
		  <form style="display:inline;" method="POST" action="/f/{{$.ForumSlug}}/{{.ID}}/pin?s={{ not .Pinned}}"><button class="link-button" id="submit">{{ if .Pinned}}Unp{{else}}P{{end}}in</button></form>


@@ 28,9 28,8 @@
    </td>
	<td style="text-align:center;">{{.Replies}}</td>
    <td>
		<a href="/f/general/{{.ID}}#{{.Latest.ID}}">↗</a>
		<a href="/f/general/{{.ID}}#{{.Latest.ID}}">{{ timeago .Latest.Created }}</a>
		by <a href="/user/{{.Latest.Author.ID}}">{{.Latest.Author.Username}}</a>
	  <span class="text-alt">{{ timeago .Latest.Created }}</span>
    </td>
  </tr>
  {{ end }}

M views/index.html => views/index.html +2 -2
@@ 8,9 8,9 @@
      {{.Description}}
    </td>
    <td>
		<a href="/f/{{.Slug}}/{{.LastPost.ThreadID}}?p={{.LastPost.ID}}">↗</a> in <a href="/f/{{.Slug}}/{{.LastPost.ThreadID}}">{{.LastPost.ThreadTitle}}</a><br>
		<a href="/f/{{.Slug}}/{{.LastPost.ThreadID}}?p={{.LastPost.ID}}">{{ timeago .LastPost.Created }}</a> 
		by <a href="/user/{{.LastPost.Author.ID}}">{{.LastPost.Author.Username}}</a>
	  <span class="text-alt">{{ timeago .LastPost.Created }}</span>
		in <a href="/f/{{.Slug}}/{{.LastPost.ThreadID}}">{{.LastPost.ThreadTitle}}</a><br>
    </td>
  </tr>
  {{ end }}

M web.go => web.go +1 -0
@@ 516,6 516,7 @@ func editForumPage(w http.ResponseWriter, r *http.Request) {
		if err != nil {
			serverError(w, r, err)
		}
		http.Redirect(w, r, "/control", http.StatusSeeOther)
	}
	tmpl["Forum"], err = getForumBySlug(fs)
	serveHTML(w, r, "edit-forum", tmpl)