gosora/reply.go

59 lines
1.3 KiB
Go
Raw Normal View History

/* Copyright Azareal 2016 - 2017 */
2016-12-02 07:38:54 +00:00
package main
import "html/template"
2016-12-02 07:38:54 +00:00
type Reply struct /* Should probably rename this to ReplyUser and rename ReplyShort to Reply */
2016-12-02 07:38:54 +00:00
{
ID int
ParentID int
Content string
ContentHtml string
2016-12-02 07:38:54 +00:00
CreatedBy int
CreatedByName string
Group int
2016-12-02 07:38:54 +00:00
CreatedAt string
LastEdit int
LastEditBy int
Avatar string
Css template.CSS
ContentLines int
Tag string
URL string
URLPrefix string
URLName string
Level int
Dramatically improved Gosora's speed by two to four times. Admins and mods can now see the IP Addresses of users. The last IP Address of a user is now tracked. The IP Addresses a user used to create replies and topics are now tracked. Dramatically improved the speed of templates with the new Fragment System. More optimisations to come! Decreased the memory usage of compiled templates with the new Fragment System. build.bat now provides more information on what it's doing. Added the `go generate` command to the .bat files in preparation for the future. We're currently in the process of overhauling the benchmark system to run tests in parallel rather than serially. More news on that later. We're also looking into the best way of integrating pprof with the benchmarks for detailed profiling. The internal and notfound errors are now static pages. Internal Error pages are now served properly. Optimised most of the errors. Added an internal flag for checking if the plugins have been initialised yet. Mainly for tests. Decoupled the global initialisation code from the tests. Removed URL Tags from Tempra Simple. We're pondering over how to re-introduce this in a less intrusive way. Template file writing is now multi-threaded. The number of maximum open connections is now explicitly set. Removed the Name field from the page struct. Turned some of the most frequently hit queries into prepared statements. Added the [rand] BBCode. Converted the NoticeList map into a slice. Added the missing_tag error type to the [url] tag. error_notfound is now used for when the router can't find a route. Fixed a bug in the custom page route where both the page AND the error is served when the page doesn't exist. Removed some deferrals. Reduced the number of allocations on the topic page. run.bat now provides more information on what it's doing.
2017-01-17 07:55:46 +00:00
IpAddress string
Liked bool
LikeCount int
ActionType string
ActionIcon string
2016-12-02 07:38:54 +00:00
}
type ReplyShort struct
{
ID int
ParentID int
Content string
CreatedBy int
Group int
CreatedAt string
LastEdit int
LastEditBy int
ContentLines int
IpAddress string
Liked bool
LikeCount int
}
func get_reply(id int) (*ReplyShort, error) {
reply := ReplyShort{ID:id}
err := get_reply_stmt.QueryRow(id).Scan(&reply.ParentID, &reply.Content, &reply.CreatedBy, &reply.CreatedAt, &reply.LastEdit, &reply.LastEditBy, &reply.IpAddress, &reply.LikeCount)
return &reply, err
}
func get_user_reply(id int) (*ReplyShort, error) {
reply := ReplyShort{ID:id}
err := get_user_reply_stmt.QueryRow(id).Scan(&reply.ParentID, &reply.Content, &reply.CreatedBy, &reply.CreatedAt, &reply.LastEdit, &reply.LastEditBy, &reply.IpAddress)
return &reply, err
}