Skip to content

Commit

Permalink
Added the profile system.
Browse files Browse the repository at this point in the history
Added the profile comment system.
Added group tags.
Improved the avatar placement logic.
Users without avatars will now get noavatars. Customisable in config.go
Only admins can see the Control Panel link now.
Fixed a problem with Git not including /uploads/ which can crash the program.

Database changes:
Added active column to forums.
Added tag column to users_groups.
Added the users_replies table.
Commented out the replies_reports table.
  • Loading branch information
Azareal committed Dec 7, 2016
1 parent 30ecdf8 commit 72d7bee
Show file tree
Hide file tree
Showing 20 changed files with 781 additions and 396 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
uploads/*
uploads/avatar_*
bin/*
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Add a settings system.

Add a plugin system.

Revamp the system for serving static files to make it much faster.

Tweak the CSS to make it responsive.

Add a forum cache.
Nest the moderation routes to possibly speed routing up a little...?

Add a friend system.
6 changes: 4 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ var max_request_size = 5 * megabyte

// Misc
var default_route = route_topics
var staff_css = "background-color: #ffeaff;background-position: left;"
var uncategorised_forum_visible = true
var staff_css = "background-color: #ffeaff;"
var uncategorised_forum_visible = true
var siteurl = "localhost:8080"
var noavatar = "https://api.adorable.io/avatars/285/{id}@" + siteurl + ".png"
20 changes: 17 additions & 3 deletions data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ CREATE TABLE `users_groups`(
`permissions` text not null,
`is_admin` tinyint DEFAULT 0 not null,
`is_banned` tinyint DEFAULT 0 not null,
`tag` varchar(50) DEFAULT '' not null,
primary key(`gid`)
);

CREATE TABLE `forums`(
`fid` int not null AUTO_INCREMENT,
`name` varchar(100) not null,
`active` tinyint DEFAULT 1 not null,
`lastTopic` varchar(100) DEFAULT '' not null,
`lastTopicID` int DEFAULT 0 not null,
`lastReplyer` varchar(100) DEFAULT '' not null,
Expand Down Expand Up @@ -61,17 +63,29 @@ CREATE TABLE `replies`(
primary key(`rid`)
);

CREATE TABLE `replies_reports` (
CREATE TABLE `users_replies`(
`rid` int not null AUTO_INCREMENT,
`uid` int not null,
`content` text not null,
`parsed_content` text not null,
`createdAt` datetime not null,
`createdBy` int not null,
`lastEdit` int not null,
`lastEditBy` int not null,
primary key(`rid`)
);

/*CREATE TABLE `replies_reports` (
`rid` int not null AUTO_INCREMENT,
`reportedBy` int not null,
`reportedContent` text not null,
`resolved` tinyint DEFAULT 0 not null,
primary key(`rid`)
);
);*/

INSERT INTO users(`name`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`)
VALUES ('Admin',1,1,NOW(),NOW());
INSERT INTO users_groups(`name`,`permissions`,`is_admin`) VALUES ('Administrator','{}',1);
INSERT INTO users_groups(`name`,`permissions`,`is_admin`,`tag`) VALUES ('Admin','{}',1,"Admin");
INSERT INTO users_groups(`name`,`permissions`) VALUES ('Member','{}');
INSERT INTO forums(`name`,`lastTopicTime`) VALUES ('General',NOW());
INSERT INTO topics(`title`,`content`,`createdAt`,`lastReplyAt`,`createdBy`,`parentID`)
Expand Down
1 change: 1 addition & 0 deletions forum.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ type ForumSimple struct
{
ID int
Name string
Active bool
}
Binary file modified grosolo.exe
Binary file not shown.
Binary file modified grosolo.exe~
Binary file not shown.
1 change: 1 addition & 0 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type Group struct
Permissions string
Is_Admin bool
Is_Banned bool
Tag string
}
Binary file added images/admin-tags.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/profiles.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 30 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ var set_avatar_stmt *sql.Stmt
var set_username_stmt *sql.Stmt
var register_stmt *sql.Stmt
var username_exists_stmt *sql.Stmt
var create_profile_reply_stmt *sql.Stmt
var edit_profile_reply_stmt *sql.Stmt
var delete_profile_reply_stmt *sql.Stmt

var create_forum_stmt *sql.Stmt
var delete_forum_stmt *sql.Stmt
Expand Down Expand Up @@ -185,6 +188,24 @@ func init_database(err error) {
log.Fatal(err)
}

log.Print("Preparing create_profile_reply statement.")
create_profile_reply_stmt, err = db.Prepare("INSERT INTO users_replies(uid,content,parsed_content,createdAt,createdBy) VALUES(?,?,?,NOW(),?)")
if err != nil {
log.Fatal(err)
}

log.Print("Preparing edit_profile_reply statement.")
edit_profile_reply_stmt, err = db.Prepare("UPDATE users_replies SET content = ?, parsed_content = ? WHERE rid = ?")
if err != nil {
log.Fatal(err)
}

log.Print("Preparing delete_profile_reply statement.")
delete_profile_reply_stmt, err = db.Prepare("DELETE FROM users_replies WHERE rid = ?")
if err != nil {
log.Fatal(err)
}

log.Print("Preparing create_forum statement.")
create_forum_stmt, err = db.Prepare("INSERT INTO forums(name) VALUES(?)")
if err != nil {
Expand All @@ -204,15 +225,15 @@ func init_database(err error) {
}

log.Print("Loading the usergroups.")
rows, err := db.Query("SELECT gid,name,permissions,is_admin,is_banned FROM users_groups")
rows, err := db.Query("SELECT gid,name,permissions,is_admin,is_banned,tag FROM users_groups")
if err != nil {
log.Fatal(err)
}
defer rows.Close()

for rows.Next() {
group := Group{0,"","",false,false}
err := rows.Scan(&group.ID, &group.Name, &group.Permissions, &group.Is_Admin, &group.Is_Banned)
group := Group{0,"","",false,false,""}
err := rows.Scan(&group.ID, &group.Name, &group.Permissions, &group.Is_Admin, &group.Is_Banned, &group.Tag)
if err != nil {
log.Fatal(err)
}
Expand All @@ -224,15 +245,15 @@ func init_database(err error) {
}

log.Print("Loading the forums.")
rows, err = db.Query("SELECT fid, name, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime FROM forums")
rows, err = db.Query("SELECT fid, name, active, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime FROM forums")
if err != nil {
log.Fatal(err)
}
defer rows.Close()

for rows.Next() {
forum := Forum{0,"",true,"",0,"",0,""}
err := rows.Scan(&forum.ID, &forum.Name, &forum.LastTopic, &forum.LastTopicID, &forum.LastReplyer, &forum.LastReplyerID, &forum.LastTopicTime)
err := rows.Scan(&forum.ID, &forum.Name, &forum.Active, &forum.LastTopic, &forum.LastTopicID, &forum.LastReplyer, &forum.LastReplyerID, &forum.LastTopicTime)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -333,6 +354,10 @@ func main(){
http.HandleFunc("/user/edit/avatar/submit/", route_account_own_edit_avatar_submit)
http.HandleFunc("/user/edit/username/", route_account_own_edit_username)
http.HandleFunc("/user/edit/username/submit/", route_account_own_edit_username_submit)
http.HandleFunc("/user/", route_profile)
http.HandleFunc("/profile/reply/create/", route_profile_reply_create)
http.HandleFunc("/profile/reply/edit/submit/", route_profile_reply_edit_submit)
http.HandleFunc("/profile/reply/delete/submit/", route_profile_reply_delete_submit)
//http.HandleFunc("/user/:id/edit/", route_logout)
//http.HandleFunc("/user/:id/ban/", route_logout)

Expand Down
Loading

0 comments on commit 72d7bee

Please sign in to comment.