Documentation ¶
Overview ¶
Neat Note. A notes sharing platform for university students. Copyright (C) 2020 Humaid AlQassimi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Neat Note. A notes sharing platform for university students. Copyright (C) 2020 Humaid AlQassimi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Neat Note. A notes sharing platform for university students. Copyright (C) 2020 Humaid AlQassimi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Neat Note. A notes sharing platform for university students. Copyright (C) 2020 Humaid AlQassimi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Neat Note. A notes sharing platform for university students. Copyright (C) 2020 Humaid AlQassimi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Neat Note. A notes sharing platform for university students. Copyright (C) 2020 Humaid AlQassimi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Index ¶
- func AddComment(c *Comment) (err error)
- func AddCourse(c *Course) (err error)
- func AddPost(p *Post) (err error)
- func AddUser(u *User) (err error)
- func DeleteComment(id string) (err error)
- func DeletePost(id string) (err error)
- func GetUserPostCount(user string) (i int64, err error)
- func HasUser(user string) (has bool)
- func SetupEngine() *xorm.Engine
- func UnvotePost(user string, post int64) (err error)
- func UpdateComment(c *Comment) (err error)
- func UpdatePost(p *Post) (err error)
- func UpdateUser(u *User) (err error)
- func UpdateUserCols(u *User, cols ...string) error
- func UpvotePost(user string, post int64) (err error)
- type Comment
- type Course
- type HotPosts
- type NewPosts
- type Post
- type TopPosts
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddComment ¶
AddComment adds a new Comment to the database.
func DeleteComment ¶
DeleteComment deletes a comment from the database.
func DeletePost ¶
DeletePost deletes a post from the database, including comments.
func GetUserPostCount ¶
GetUserPostCount returns number of posts by a specific user.
func SetupEngine ¶
SetupEngine sets up an XORM engine according to the database configuration and syncs the schema.
func UnvotePost ¶
func UpdateComment ¶
UpdateComment updates a comment in the database.
func UpdateUserCols ¶ added in v0.3.1
UpdatUserCols updates a user in the database including the specified columns, even if the fields are empty.
func UpvotePost ¶
Types ¶
type Comment ¶
type Comment struct { CommentID int64 `xorm:"pk autoincr"` PostID int64 `xorm:"notnull"` PosterID string `xorm:"notnull"` Poster *User `xorm:"-" json:"-"` Text string `xorm:"notnull"` FormattedText template.HTML `xorm:"-" json:"-"` CreatedUnix int64 `xorm:"created"` UpdatedUnix int64 `xorm:"updated"` }
Comment represents a comment on a Post. It keeps track of the poster and which post it is posted to.
func GetAllUserComments ¶ added in v0.3.1
GetAllUserComments returns all of the comments created by a specific user.
func GetComment ¶
GetComment gets a comment based on the ID. It will return the pointer to the Comment, and whether there was an error.
func (*Comment) LoadPoster ¶
LoadPoster loads the poster of a comment in the non-mapped field of the Comment struct.
type Course ¶
type Course struct { Code string `xorm:"pk varchar(64)"` Name string `xorm:"notnull text"` Visible bool `xorm:"notnull"` Locked bool `xorm:"notnull"` PostsCount int64 `xorm:"-" json:"-"` Posts []Post `xorm:"-" json:"-"` CreatedUnix int64 `xorm:"created"` UpdatedUnix int64 `xorm:"updated"` }
Course represents a sub-forum on a website, and is defined with a course code and a name. It keeps track of number of posts, whether that forum is locked, visible, and so on.
func GetCourse ¶
GetCourse gets a Course based on a course code. It will return a pointer to the Course struct, and whether there was an error or not.
func GetCourses ¶
func GetCourses() (courses []Course)
GetCourses returns a list of all courses in the database.
func (*Course) LoadPostsCount ¶
LoadPostsCount loads the posts count of a course in a non-mapped field.
type HotPosts ¶
type HotPosts []Post
HotPosts implements sort.Interface for []Post based on iota score diminished by time.
type NewPosts ¶
type NewPosts []Post
NewPosts implements sort.Interface for []Post based on new posts.
type Post ¶
type Post struct { PostID int64 `xorm:"pk autoincr"` CourseCode string `xorm:"text notnull"` PosterID string `xorm:"notnull"` Poster *User `xorm:"-" json:"-"` Locked bool `xorm:"notnull"` // Whether the comments are locked. Comments []Comment `xorm:"-" json:"-"` CommentsCount int64 `xorm:"-" json:"-"` Title string `xorm:"text notnull"` Text string `xorm:"text notnull"` CreatedUnix int64 `xorm:"created"` UpdatedUnix int64 `xorm:"updated"` Anonymous bool `xorm:"notnull"` AnonName string `xorm:"text null"` Iota int64 }
Post represents a post in one of the Courses by one of the Users. It keeps track of the poster, course, comments (and comment count), whether it is an anonymous post, and so on.
func GetAllUserPosts ¶
GetAllUserPosts returns all of the post created by a specific user.
func GetPost ¶
GetPost gets a Post based on the ID. It will return the pointer to the Post, and whether there was an error.
func (*Post) LoadComments ¶
LoadComments loads the comments of the post into a non-mapped field.
type TopPosts ¶
type TopPosts []Post
TopPosts implements sort.Interface for []Post based on highest iota.
type User ¶
type User struct { Username string `xorm:"pk"` FullName string `xorm:"text null"` Badge string `xorm:"text null"` IsAdmin bool `xorm:"bool"` Iota int64 CreatedUnix int64 `xorm:"created"` Upvoted []int64 // Post IDs which the user upvoted. Suspended bool `xorm:"notnull"` SuspendReason string `xorm:"text null"` }
User represents a website user. It keeps track of the iota, settings (such as badges), and whether they have administrative privileges.